From 52b173817a18dc4f7c534a7b597f9a2cde28ba6b Mon Sep 17 00:00:00 2001 From: Smaug123 Date: Fri, 2 Feb 2024 16:00:38 +0000 Subject: [PATCH] Make reopen date optional --- PureGym.Test/TestJson.fs | 2 +- PureGym/Dto.fs | 2 +- PureGym/GeneratedClient.fs | 138 +++++------ PureGym/GeneratedDto.fs | 449 +++++++++++++++++------------------- PureGym/SurfaceBaseline.txt | 6 +- PureGym/version.json | 2 +- 6 files changed, 283 insertions(+), 316 deletions(-) diff --git a/PureGym.Test/TestJson.fs b/PureGym.Test/TestJson.fs index 0b8df68..1e97558 100644 --- a/PureGym.Test/TestJson.fs +++ b/PureGym.Test/TestJson.fs @@ -124,7 +124,7 @@ module TestJson = Latitude = 51.480401 } TimeZone = "Europe/London" - ReopenDate = "2021-04-12T00:00:00+01 Europe/London" + ReopenDate = Some "2021-04-12T00:00:00+01 Europe/London" } [ ovalJson, oval ] |> List.map TestCaseData diff --git a/PureGym/Dto.fs b/PureGym/Dto.fs index 175cb97..0ee7a25 100644 --- a/PureGym/Dto.fs +++ b/PureGym/Dto.fs @@ -125,7 +125,7 @@ type Gym = [] TimeZone : string /// This is a date-time in the format yyyy-MM-ddTHH:mm:ss+01 Europe/London - ReopenDate : string + ReopenDate : string option } /// Human-readable representation of the most important information about this gym diff --git a/PureGym/GeneratedClient.fs b/PureGym/GeneratedClient.fs index 1b95858..8110c6d 100644 --- a/PureGym/GeneratedClient.fs +++ b/PureGym/GeneratedClient.fs @@ -19,214 +19,214 @@ open RestEase [] module PureGymApi = /// Create a REST client. The input functions will be re-evaluated on every HTTP request to obtain the required values for the corresponding header properties. - let make (authHeader : unit -> string) (client : System.Net.Http.HttpClient) : IPureGymApi = + let make (authHeader: unit -> string) (client: System.Net.Http.HttpClient) : IPureGymApi = { new IPureGymApi with - member _.AuthHeader : string = authHeader () + member _.AuthHeader: string = authHeader () - member this.GetGyms (ct : CancellationToken option) = + member this.GetGyms(ct: CancellationToken option) = async { let! ct = Async.CancellationToken let uri = - System.Uri ( + System.Uri( (match client.BaseAddress with | null -> System.Uri "https://capi.puregym.com/api/" | v -> v), - System.Uri ("v1/gyms/", System.UriKind.Relative) + System.Uri("v1/gyms/", System.UriKind.Relative) ) let httpMessage = - new System.Net.Http.HttpRequestMessage ( + new System.Net.Http.HttpRequestMessage( Method = System.Net.Http.HttpMethod.Get, RequestUri = uri ) - do httpMessage.Headers.Add ("Authorization", this.AuthHeader.ToString ()) - do httpMessage.Headers.Add ("User-Agent", "PureGym/1523 CFNetwork/1312 Darwin/21.0.0") - let! response = client.SendAsync (httpMessage, ct) |> Async.AwaitTask - let response = response.EnsureSuccessStatusCode () + do httpMessage.Headers.Add("Authorization", this.AuthHeader.ToString()) + do httpMessage.Headers.Add("User-Agent", "PureGym/1523 CFNetwork/1312 Darwin/21.0.0") + let! response = client.SendAsync(httpMessage, ct) |> Async.AwaitTask + let response = response.EnsureSuccessStatusCode() let! responseStream = response.Content.ReadAsStreamAsync ct |> Async.AwaitTask let! jsonNode = - System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) + System.Text.Json.Nodes.JsonNode.ParseAsync(responseStream, cancellationToken = ct) |> Async.AwaitTask - return jsonNode.AsArray () |> Seq.map (fun elt -> Gym.jsonParse elt) |> List.ofSeq + return jsonNode.AsArray() |> Seq.map (fun elt -> Gym.jsonParse elt) |> List.ofSeq } - |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) + |> (fun a -> Async.StartAsTask(a, ?cancellationToken = ct)) - member this.GetMember (ct : CancellationToken option) = + member this.GetMember(ct: CancellationToken option) = async { let! ct = Async.CancellationToken let uri = - System.Uri ( + System.Uri( (match client.BaseAddress with | null -> System.Uri "https://capi.puregym.com/api/" | v -> v), - System.Uri ("v1/member", System.UriKind.Relative) + System.Uri("v1/member", System.UriKind.Relative) ) let httpMessage = - new System.Net.Http.HttpRequestMessage ( + new System.Net.Http.HttpRequestMessage( Method = System.Net.Http.HttpMethod.Get, RequestUri = uri ) - do httpMessage.Headers.Add ("Authorization", this.AuthHeader.ToString ()) - do httpMessage.Headers.Add ("User-Agent", "PureGym/1523 CFNetwork/1312 Darwin/21.0.0") - let! response = client.SendAsync (httpMessage, ct) |> Async.AwaitTask - let response = response.EnsureSuccessStatusCode () + do httpMessage.Headers.Add("Authorization", this.AuthHeader.ToString()) + do httpMessage.Headers.Add("User-Agent", "PureGym/1523 CFNetwork/1312 Darwin/21.0.0") + let! response = client.SendAsync(httpMessage, ct) |> Async.AwaitTask + let response = response.EnsureSuccessStatusCode() let! responseStream = response.Content.ReadAsStreamAsync ct |> Async.AwaitTask let! jsonNode = - System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) + System.Text.Json.Nodes.JsonNode.ParseAsync(responseStream, cancellationToken = ct) |> Async.AwaitTask return Member.jsonParse jsonNode } - |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) + |> (fun a -> Async.StartAsTask(a, ?cancellationToken = ct)) - member this.GetGymAttendance (gymId : int, ct : CancellationToken option) = + member this.GetGymAttendance(gymId: int, ct: CancellationToken option) = async { let! ct = Async.CancellationToken let uri = - System.Uri ( + System.Uri( (match client.BaseAddress with | null -> System.Uri "https://capi.puregym.com/api/" | v -> v), - System.Uri ( + System.Uri( "v1/gyms/{gym_id}/attendance" - .Replace ("{gym_id}", gymId.ToString () |> System.Web.HttpUtility.UrlEncode), + .Replace("{gym_id}", gymId.ToString() |> System.Web.HttpUtility.UrlEncode), System.UriKind.Relative ) ) let httpMessage = - new System.Net.Http.HttpRequestMessage ( + new System.Net.Http.HttpRequestMessage( Method = System.Net.Http.HttpMethod.Get, RequestUri = uri ) - do httpMessage.Headers.Add ("Authorization", this.AuthHeader.ToString ()) - do httpMessage.Headers.Add ("User-Agent", "PureGym/1523 CFNetwork/1312 Darwin/21.0.0") - let! response = client.SendAsync (httpMessage, ct) |> Async.AwaitTask - let response = response.EnsureSuccessStatusCode () + do httpMessage.Headers.Add("Authorization", this.AuthHeader.ToString()) + do httpMessage.Headers.Add("User-Agent", "PureGym/1523 CFNetwork/1312 Darwin/21.0.0") + let! response = client.SendAsync(httpMessage, ct) |> Async.AwaitTask + let response = response.EnsureSuccessStatusCode() let! responseStream = response.Content.ReadAsStreamAsync ct |> Async.AwaitTask let! jsonNode = - System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) + System.Text.Json.Nodes.JsonNode.ParseAsync(responseStream, cancellationToken = ct) |> Async.AwaitTask return GymAttendance.jsonParse jsonNode } - |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) + |> (fun a -> Async.StartAsTask(a, ?cancellationToken = ct)) - member this.GetGym (gymId : int, ct : CancellationToken option) = + member this.GetGym(gymId: int, ct: CancellationToken option) = async { let! ct = Async.CancellationToken let uri = - System.Uri ( + System.Uri( (match client.BaseAddress with | null -> System.Uri "https://capi.puregym.com/api/" | v -> v), - System.Uri ( + System.Uri( "v1/gyms/{gym_id}" - .Replace ("{gym_id}", gymId.ToString () |> System.Web.HttpUtility.UrlEncode), + .Replace("{gym_id}", gymId.ToString() |> System.Web.HttpUtility.UrlEncode), System.UriKind.Relative ) ) let httpMessage = - new System.Net.Http.HttpRequestMessage ( + new System.Net.Http.HttpRequestMessage( Method = System.Net.Http.HttpMethod.Get, RequestUri = uri ) - do httpMessage.Headers.Add ("Authorization", this.AuthHeader.ToString ()) - do httpMessage.Headers.Add ("User-Agent", "PureGym/1523 CFNetwork/1312 Darwin/21.0.0") - let! response = client.SendAsync (httpMessage, ct) |> Async.AwaitTask - let response = response.EnsureSuccessStatusCode () + do httpMessage.Headers.Add("Authorization", this.AuthHeader.ToString()) + do httpMessage.Headers.Add("User-Agent", "PureGym/1523 CFNetwork/1312 Darwin/21.0.0") + let! response = client.SendAsync(httpMessage, ct) |> Async.AwaitTask + let response = response.EnsureSuccessStatusCode() let! responseStream = response.Content.ReadAsStreamAsync ct |> Async.AwaitTask let! jsonNode = - System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) + System.Text.Json.Nodes.JsonNode.ParseAsync(responseStream, cancellationToken = ct) |> Async.AwaitTask return Gym.jsonParse jsonNode } - |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) + |> (fun a -> Async.StartAsTask(a, ?cancellationToken = ct)) - member this.GetMemberActivity (ct : CancellationToken option) = + member this.GetMemberActivity(ct: CancellationToken option) = async { let! ct = Async.CancellationToken let uri = - System.Uri ( + System.Uri( (match client.BaseAddress with | null -> System.Uri "https://capi.puregym.com/api/" | v -> v), - System.Uri ("v1/member/activity", System.UriKind.Relative) + System.Uri("v1/member/activity", System.UriKind.Relative) ) let httpMessage = - new System.Net.Http.HttpRequestMessage ( + new System.Net.Http.HttpRequestMessage( Method = System.Net.Http.HttpMethod.Get, RequestUri = uri ) - do httpMessage.Headers.Add ("Authorization", this.AuthHeader.ToString ()) - do httpMessage.Headers.Add ("User-Agent", "PureGym/1523 CFNetwork/1312 Darwin/21.0.0") - let! response = client.SendAsync (httpMessage, ct) |> Async.AwaitTask - let response = response.EnsureSuccessStatusCode () + do httpMessage.Headers.Add("Authorization", this.AuthHeader.ToString()) + do httpMessage.Headers.Add("User-Agent", "PureGym/1523 CFNetwork/1312 Darwin/21.0.0") + let! response = client.SendAsync(httpMessage, ct) |> Async.AwaitTask + let response = response.EnsureSuccessStatusCode() let! responseStream = response.Content.ReadAsStreamAsync ct |> Async.AwaitTask let! jsonNode = - System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) + System.Text.Json.Nodes.JsonNode.ParseAsync(responseStream, cancellationToken = ct) |> Async.AwaitTask return MemberActivityDto.jsonParse jsonNode } - |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) + |> (fun a -> Async.StartAsTask(a, ?cancellationToken = ct)) - member this.GetSessions (fromDate : DateOnly, toDate : DateOnly, ct : CancellationToken option) = + member this.GetSessions(fromDate: DateOnly, toDate: DateOnly, ct: CancellationToken option) = async { let! ct = Async.CancellationToken let uri = - System.Uri ( + System.Uri( (match client.BaseAddress with | null -> System.Uri "https://capi.puregym.com/api/" | v -> v), - System.Uri ( + System.Uri( ("v2/gymSessions/member" + "?fromDate=" - + ((fromDate.ToString "yyyy-MM-dd") |> System.Web.HttpUtility.UrlEncode) - + "&toDate=" - + ((toDate.ToString "yyyy-MM-dd") |> System.Web.HttpUtility.UrlEncode)), + + ((fromDate.ToString "yyyy-MM-dd") |> System.Web.HttpUtility.UrlEncode) + + "&toDate=" + + ((toDate.ToString "yyyy-MM-dd") |> System.Web.HttpUtility.UrlEncode)), System.UriKind.Relative ) ) let httpMessage = - new System.Net.Http.HttpRequestMessage ( + new System.Net.Http.HttpRequestMessage( Method = System.Net.Http.HttpMethod.Get, RequestUri = uri ) - do httpMessage.Headers.Add ("Authorization", this.AuthHeader.ToString ()) - do httpMessage.Headers.Add ("User-Agent", "PureGym/1523 CFNetwork/1312 Darwin/21.0.0") - let! response = client.SendAsync (httpMessage, ct) |> Async.AwaitTask - let response = response.EnsureSuccessStatusCode () + do httpMessage.Headers.Add("Authorization", this.AuthHeader.ToString()) + do httpMessage.Headers.Add("User-Agent", "PureGym/1523 CFNetwork/1312 Darwin/21.0.0") + let! response = client.SendAsync(httpMessage, ct) |> Async.AwaitTask + let response = response.EnsureSuccessStatusCode() let! responseStream = response.Content.ReadAsStreamAsync ct |> Async.AwaitTask let! jsonNode = - System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) + System.Text.Json.Nodes.JsonNode.ParseAsync(responseStream, cancellationToken = ct) |> Async.AwaitTask return Sessions.jsonParse jsonNode } - |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) - } + |> (fun a -> Async.StartAsTask(a, ?cancellationToken = ct)) } + diff --git a/PureGym/GeneratedDto.fs b/PureGym/GeneratedDto.fs index 4452ee9..e17c915 100644 --- a/PureGym/GeneratedDto.fs +++ b/PureGym/GeneratedDto.fs @@ -12,36 +12,34 @@ namespace PureGym [] module GymOpeningHours = /// Parse from a JSON node. - let jsonParse (node : System.Text.Json.Nodes.JsonNode) : GymOpeningHours = + let jsonParse (node: System.Text.Json.Nodes.JsonNode) : GymOpeningHours = let OpeningHours = (match node.["openingHours"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("openingHours") ) ) | v -> v) - .AsArray () - |> Seq.map (fun elt -> elt.AsValue().GetValue ()) + .AsArray() + |> Seq.map (fun elt -> elt.AsValue().GetValue()) |> List.ofSeq let IsAlwaysOpen = (match node.["isAlwaysOpen"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("isAlwaysOpen") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() - { - IsAlwaysOpen = IsAlwaysOpen - OpeningHours = OpeningHours - } + { IsAlwaysOpen = IsAlwaysOpen + OpeningHours = OpeningHours } namespace PureGym /// Module containing JSON parsing methods for the GymAccessOptions type @@ -49,35 +47,33 @@ namespace PureGym [] module GymAccessOptions = /// Parse from a JSON node. - let jsonParse (node : System.Text.Json.Nodes.JsonNode) : GymAccessOptions = + let jsonParse (node: System.Text.Json.Nodes.JsonNode) : GymAccessOptions = let QrCodeAccess = (match node.["qrCodeAccess"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("qrCodeAccess") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let PinAccess = (match node.["pinAccess"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("pinAccess") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() - { - PinAccess = PinAccess - QrCodeAccess = QrCodeAccess - } + { PinAccess = PinAccess + QrCodeAccess = QrCodeAccess } namespace PureGym /// Module containing JSON parsing methods for the GymLocation type @@ -85,19 +81,19 @@ namespace PureGym [] module GymLocation = /// Parse from a JSON node. - let jsonParse (node : System.Text.Json.Nodes.JsonNode) : GymLocation = + let jsonParse (node: System.Text.Json.Nodes.JsonNode) : GymLocation = let Latitude = try (match node.["latitude"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("latitude") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() with :? System.InvalidOperationException as exc -> if exc.Message.Contains "cannot be converted to" then if @@ -106,13 +102,13 @@ module GymLocation = (match node.["latitude"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("latitude") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() |> System.Double.Parse else reraise () @@ -124,13 +120,13 @@ module GymLocation = (match node.["longitude"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("longitude") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() with :? System.InvalidOperationException as exc -> if exc.Message.Contains "cannot be converted to" then if @@ -139,23 +135,21 @@ module GymLocation = (match node.["longitude"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("longitude") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() |> System.Double.Parse else reraise () else reraise () - { - Longitude = Longitude - Latitude = Latitude - } + { Longitude = Longitude + Latitude = Latitude } namespace PureGym /// Module containing JSON parsing methods for the GymAddress type @@ -163,66 +157,64 @@ namespace PureGym [] module GymAddress = /// Parse from a JSON node. - let jsonParse (node : System.Text.Json.Nodes.JsonNode) : GymAddress = + let jsonParse (node: System.Text.Json.Nodes.JsonNode) : GymAddress = let Postcode = (match node.["postcode"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("postcode") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let County = match node.["county"] with | null -> None - | v -> v.AsValue().GetValue () |> Some + | v -> v.AsValue().GetValue() |> Some let Town = (match node.["town"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("town") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let AddressLine3 = match node.["addressLine3"] with | null -> None - | v -> v.AsValue().GetValue () |> Some + | v -> v.AsValue().GetValue() |> Some let AddressLine2 = match node.["addressLine2"] with | null -> None - | v -> v.AsValue().GetValue () |> Some + | v -> v.AsValue().GetValue() |> Some let AddressLine1 = (match node.["addressLine1"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("addressLine1") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() - { - AddressLine1 = AddressLine1 - AddressLine2 = AddressLine2 - AddressLine3 = AddressLine3 - Town = Town - County = County - Postcode = Postcode - } + { AddressLine1 = AddressLine1 + AddressLine2 = AddressLine2 + AddressLine3 = AddressLine3 + Town = Town + County = County + Postcode = Postcode } namespace PureGym /// Module containing JSON parsing methods for the Gym type @@ -230,37 +222,30 @@ namespace PureGym [] module Gym = /// Parse from a JSON node. - let jsonParse (node : System.Text.Json.Nodes.JsonNode) : Gym = + let jsonParse (node: System.Text.Json.Nodes.JsonNode) : Gym = let ReopenDate = - (match node.["reopenDate"] with - | null -> - raise ( - System.Collections.Generic.KeyNotFoundException ( - sprintf "Required key '%s' not found on JSON object" ("reopenDate") - ) - ) - | v -> v) - .AsValue() - .GetValue () + match node.["reopenDate"] with + | null -> None + | v -> v.AsValue().GetValue() |> Some let TimeZone = (match node.["timeZone"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("timeZone") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let Location = GymLocation.jsonParse ( match node.["location"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("location") ) ) @@ -272,7 +257,7 @@ module Gym = match node.["accessOptions"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("accessOptions") ) ) @@ -284,7 +269,7 @@ module Gym = match node.["gymOpeningHours"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("gymOpeningHours") ) ) @@ -295,32 +280,32 @@ module Gym = (match node.["emailAddress"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("emailAddress") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let PhoneNumber = (match node.["phoneNumber"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("phoneNumber") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let Address = GymAddress.jsonParse ( match node.["address"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("address") ) ) @@ -331,51 +316,49 @@ module Gym = (match node.["status"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("status") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let Id = (match node.["id"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("id") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let Name = (match node.["name"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("name") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() - { - Name = Name - Id = Id - Status = Status - Address = Address - PhoneNumber = PhoneNumber - EmailAddress = EmailAddress - GymOpeningHours = GymOpeningHours - AccessOptions = AccessOptions - Location = Location - TimeZone = TimeZone - ReopenDate = ReopenDate - } + { Name = Name + Id = Id + Status = Status + Address = Address + PhoneNumber = PhoneNumber + EmailAddress = EmailAddress + GymOpeningHours = GymOpeningHours + AccessOptions = AccessOptions + Location = Location + TimeZone = TimeZone + ReopenDate = ReopenDate } namespace PureGym /// Module containing JSON parsing methods for the Member type @@ -383,205 +366,203 @@ namespace PureGym [] module Member = /// Parse from a JSON node. - let jsonParse (node : System.Text.Json.Nodes.JsonNode) : Member = + let jsonParse (node: System.Text.Json.Nodes.JsonNode) : Member = let MemberStatus = (match node.["memberStatus"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("memberStatus") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let SuspendedReason = (match node.["suspendedReason"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("suspendedReason") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let MembershipLevel = (match node.["membershipLevel"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("membershipLevel") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let MembershipName = (match node.["membershipName"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("membershipName") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let Postcode = (match node.["postCode"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("postCode") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let MobileNumber = (match node.["mobileNumber"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("mobileNumber") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let DateOfBirth = (match node.["dateofBirth"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("dateofBirth") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() |> System.DateOnly.Parse let GymAccessPin = (match node.["gymAccessPin"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("gymAccessPin") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let EmailAddress = (match node.["emailAddress"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("emailAddress") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let HomeGymName = (match node.["homeGymName"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("homeGymName") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let HomeGymId = (match node.["homeGymId"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("homeGymId") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let LastName = (match node.["lastName"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("lastName") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let FirstName = (match node.["firstName"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("firstName") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let CompoundMemberId = (match node.["compoundMemberId"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("compoundMemberId") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let Id = (match node.["id"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("id") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() - { - Id = Id - CompoundMemberId = CompoundMemberId - FirstName = FirstName - LastName = LastName - HomeGymId = HomeGymId - HomeGymName = HomeGymName - EmailAddress = EmailAddress - GymAccessPin = GymAccessPin - DateOfBirth = DateOfBirth - MobileNumber = MobileNumber - Postcode = Postcode - MembershipName = MembershipName - MembershipLevel = MembershipLevel - SuspendedReason = SuspendedReason - MemberStatus = MemberStatus - } + { Id = Id + CompoundMemberId = CompoundMemberId + FirstName = FirstName + LastName = LastName + HomeGymId = HomeGymId + HomeGymName = HomeGymName + EmailAddress = EmailAddress + GymAccessPin = GymAccessPin + DateOfBirth = DateOfBirth + MobileNumber = MobileNumber + Postcode = Postcode + MembershipName = MembershipName + MembershipLevel = MembershipLevel + SuspendedReason = SuspendedReason + MemberStatus = MemberStatus } namespace PureGym /// Module containing JSON parsing methods for the GymAttendance type @@ -589,122 +570,120 @@ namespace PureGym [] module GymAttendance = /// Parse from a JSON node. - let jsonParse (node : System.Text.Json.Nodes.JsonNode) : GymAttendance = + let jsonParse (node: System.Text.Json.Nodes.JsonNode) : GymAttendance = let MaximumCapacity = (match node.["maximumCapacity"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("maximumCapacity") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let LastRefreshedPeopleInClasses = (match node.["lastRefreshedPeopleInClasses"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("lastRefreshedPeopleInClasses") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() |> System.DateTime.Parse let LastRefreshed = (match node.["lastRefreshed"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("lastRefreshed") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() |> System.DateTime.Parse let AttendanceTime = (match node.["attendanceTime"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("attendanceTime") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() |> System.DateTime.Parse let IsApproximate = (match node.["isApproximate"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("isApproximate") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let TotalPeopleSuffix = match node.["totalPeopleSuffix"] with | null -> None - | v -> v.AsValue().GetValue () |> Some + | v -> v.AsValue().GetValue() |> Some let TotalPeopleInClasses = (match node.["totalPeopleInClasses"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("totalPeopleInClasses") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let TotalPeopleInGym = (match node.["totalPeopleInGym"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("totalPeopleInGym") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let Description = (match node.["description"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("description") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() - { - Description = Description - TotalPeopleInGym = TotalPeopleInGym - TotalPeopleInClasses = TotalPeopleInClasses - TotalPeopleSuffix = TotalPeopleSuffix - IsApproximate = IsApproximate - AttendanceTime = AttendanceTime - LastRefreshed = LastRefreshed - LastRefreshedPeopleInClasses = LastRefreshedPeopleInClasses - MaximumCapacity = MaximumCapacity - } + { Description = Description + TotalPeopleInGym = TotalPeopleInGym + TotalPeopleInClasses = TotalPeopleInClasses + TotalPeopleSuffix = TotalPeopleSuffix + IsApproximate = IsApproximate + AttendanceTime = AttendanceTime + LastRefreshed = LastRefreshed + LastRefreshedPeopleInClasses = LastRefreshedPeopleInClasses + MaximumCapacity = MaximumCapacity } namespace PureGym /// Module containing JSON parsing methods for the MemberActivityDto type @@ -712,88 +691,86 @@ namespace PureGym [] module MemberActivityDto = /// Parse from a JSON node. - let jsonParse (node : System.Text.Json.Nodes.JsonNode) : MemberActivityDto = + let jsonParse (node: System.Text.Json.Nodes.JsonNode) : MemberActivityDto = let LastRefreshed = (match node.["lastRefreshed"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("lastRefreshed") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() |> System.DateTime.Parse let IsEstimated = (match node.["isEstimated"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("isEstimated") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let TotalClasses = (match node.["totalClasses"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("totalClasses") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let TotalVisits = (match node.["totalVisits"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("totalVisits") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let AverageDuration = (match node.["averageDuration"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("averageDuration") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let TotalDuration = (match node.["totalDuration"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("totalDuration") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() - { - TotalDuration = TotalDuration - AverageDuration = AverageDuration - TotalVisits = TotalVisits - TotalClasses = TotalClasses - IsEstimated = IsEstimated - LastRefreshed = LastRefreshed - } + { TotalDuration = TotalDuration + AverageDuration = AverageDuration + TotalVisits = TotalVisits + TotalClasses = TotalClasses + IsEstimated = IsEstimated + LastRefreshed = LastRefreshed } namespace PureGym /// Module containing JSON parsing methods for the SessionsAggregate type @@ -801,48 +778,46 @@ namespace PureGym [] module SessionsAggregate = /// Parse from a JSON node. - let jsonParse (node : System.Text.Json.Nodes.JsonNode) : SessionsAggregate = + let jsonParse (node: System.Text.Json.Nodes.JsonNode) : SessionsAggregate = let Duration = (match node.["Duration"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("Duration") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let Visits = (match node.["Visits"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("Visits") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let Activities = (match node.["Activities"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("Activities") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() - { - Activities = Activities - Visits = Visits - Duration = Duration - } + { Activities = Activities + Visits = Visits + Duration = Duration } namespace PureGym /// Module containing JSON parsing methods for the VisitGym type @@ -850,48 +825,46 @@ namespace PureGym [] module VisitGym = /// Parse from a JSON node. - let jsonParse (node : System.Text.Json.Nodes.JsonNode) : VisitGym = + let jsonParse (node: System.Text.Json.Nodes.JsonNode) : VisitGym = let Status = (match node.["Status"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("Status") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let Name = (match node.["Name"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("Name") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let Id = (match node.["Id"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("Id") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() - { - Id = Id - Name = Name - Status = Status - } + { Id = Id + Name = Name + Status = Status } namespace PureGym /// Module containing JSON parsing methods for the Visit type @@ -899,13 +872,13 @@ namespace PureGym [] module Visit = /// Parse from a JSON node. - let jsonParse (node : System.Text.Json.Nodes.JsonNode) : Visit = + let jsonParse (node: System.Text.Json.Nodes.JsonNode) : Visit = let Gym = VisitGym.jsonParse ( match node.["Gym"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("Gym") ) ) @@ -916,45 +889,43 @@ module Visit = (match node.["Duration"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("Duration") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() let StartTime = (match node.["StartTime"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("StartTime") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() |> System.DateTime.Parse let IsDurationEstimated = (match node.["IsDurationEstimated"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("IsDurationEstimated") ) ) | v -> v) .AsValue() - .GetValue () + .GetValue() - { - IsDurationEstimated = IsDurationEstimated - StartTime = StartTime - Duration = Duration - Gym = Gym - } + { IsDurationEstimated = IsDurationEstimated + StartTime = StartTime + Duration = Duration + Gym = Gym } namespace PureGym /// Module containing JSON parsing methods for the SessionsSummary type @@ -962,13 +933,13 @@ namespace PureGym [] module SessionsSummary = /// Parse from a JSON node. - let jsonParse (node : System.Text.Json.Nodes.JsonNode) : SessionsSummary = + let jsonParse (node: System.Text.Json.Nodes.JsonNode) : SessionsSummary = let ThisWeek = SessionsAggregate.jsonParse ( match node.["ThisWeek"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("ThisWeek") ) ) @@ -980,17 +951,14 @@ module SessionsSummary = match node.["Total"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("Total") ) ) | v -> v ) - { - Total = Total - ThisWeek = ThisWeek - } + { Total = Total; ThisWeek = ThisWeek } namespace PureGym /// Module containing JSON parsing methods for the Sessions type @@ -998,17 +966,17 @@ namespace PureGym [] module Sessions = /// Parse from a JSON node. - let jsonParse (node : System.Text.Json.Nodes.JsonNode) : Sessions = + let jsonParse (node: System.Text.Json.Nodes.JsonNode) : Sessions = let Visits = (match node.["Visits"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("Visits") ) ) | v -> v) - .AsArray () + .AsArray() |> Seq.map (fun elt -> Visit.jsonParse elt) |> List.ofSeq @@ -1017,14 +985,13 @@ module Sessions = match node.["Summary"] with | null -> raise ( - System.Collections.Generic.KeyNotFoundException ( + System.Collections.Generic.KeyNotFoundException( sprintf "Required key '%s' not found on JSON object" ("Summary") ) ) | v -> v ) - { - Summary = Summary - Visits = Visits - } + { Summary = Summary; Visits = Visits } + + diff --git a/PureGym/SurfaceBaseline.txt b/PureGym/SurfaceBaseline.txt index c707f17..5fc5f6f 100644 --- a/PureGym/SurfaceBaseline.txt +++ b/PureGym/SurfaceBaseline.txt @@ -39,7 +39,7 @@ PureGym.AuthTokenModule inherit obj PureGym.AuthTokenModule.get [static method]: PureGym.UsernamePin -> System.Threading.CancellationToken -> PureGym.AuthToken System.Threading.Tasks.Task PureGym.AuthTokenModule.ofBearerToken [static method]: string -> PureGym.AuthToken PureGym.Gym inherit obj, implements PureGym.Gym System.IEquatable, System.Collections.IStructuralEquatable, PureGym.Gym System.IComparable, System.IComparable, System.Collections.IStructuralComparable -PureGym.Gym..ctor [constructor]: (string, int, int, PureGym.GymAddress, string, string, PureGym.GymOpeningHours, PureGym.GymAccessOptions, PureGym.GymLocation, string, string) +PureGym.Gym..ctor [constructor]: (string, int, int, PureGym.GymAddress, string, string, PureGym.GymOpeningHours, PureGym.GymAccessOptions, PureGym.GymLocation, string, string option) PureGym.Gym.AccessOptions [property]: [read-only] PureGym.GymAccessOptions PureGym.Gym.Address [property]: [read-only] PureGym.GymAddress PureGym.Gym.EmailAddress [property]: [read-only] string @@ -51,7 +51,7 @@ PureGym.Gym.get_Id [method]: unit -> int PureGym.Gym.get_Location [method]: unit -> PureGym.GymLocation PureGym.Gym.get_Name [method]: unit -> string PureGym.Gym.get_PhoneNumber [method]: unit -> string -PureGym.Gym.get_ReopenDate [method]: unit -> string +PureGym.Gym.get_ReopenDate [method]: unit -> string option PureGym.Gym.get_Status [method]: unit -> int PureGym.Gym.get_TimeZone [method]: unit -> string PureGym.Gym.GymOpeningHours [property]: [read-only] PureGym.GymOpeningHours @@ -59,7 +59,7 @@ PureGym.Gym.Id [property]: [read-only] int PureGym.Gym.Location [property]: [read-only] PureGym.GymLocation PureGym.Gym.Name [property]: [read-only] string PureGym.Gym.PhoneNumber [property]: [read-only] string -PureGym.Gym.ReopenDate [property]: [read-only] string +PureGym.Gym.ReopenDate [property]: [read-only] string option PureGym.Gym.Status [property]: [read-only] int PureGym.Gym.TimeZone [property]: [read-only] string PureGym.GymAccessOptions inherit obj, implements PureGym.GymAccessOptions System.IEquatable, System.Collections.IStructuralEquatable, PureGym.GymAccessOptions System.IComparable, System.IComparable, System.Collections.IStructuralComparable diff --git a/PureGym/version.json b/PureGym/version.json index d0e7d61..7bf95a3 100644 --- a/PureGym/version.json +++ b/PureGym/version.json @@ -1,5 +1,5 @@ { - "version": "4.0", + "version": "5.0", "publicReleaseRefSpec": [ "^refs/heads/main$" ],