From b2ea72f5acf3299223b8d5d677c99bc9d7064543 Mon Sep 17 00:00:00 2001 From: Smaug123 <3138005+Smaug123@users.noreply.github.com> Date: Fri, 31 May 2024 22:19:47 +0100 Subject: [PATCH 1/2] Bump stuff --- .config/dotnet-tools.json | 2 +- .editorconfig | 1 - PureGym.Test/PureGym.Test.fsproj | 2 +- PureGym.Test/TestJson.fs | 5 + PureGym/GeneratedClient.fs | 138 +++++----- PureGym/GeneratedDto.fs | 438 +++++++++++++++---------------- flake.lock | 12 +- flake.nix | 30 +-- nix/deps.nix | 162 +++--------- nix/fetchDeps.sh | 73 ------ 10 files changed, 328 insertions(+), 535 deletions(-) delete mode 100755 nix/fetchDeps.sh diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 2a80148..2351a50 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "fantomas": { - "version": "6.2.0", + "version": "6.3.4", "commands": [ "fantomas" ] diff --git a/.editorconfig b/.editorconfig index 9ef5fed..e207c42 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,7 +2,6 @@ root=true [*] charset=utf-8 -end_of_line=crlf trim_trailing_whitespace=true insert_final_newline=true indent_style=space diff --git a/PureGym.Test/PureGym.Test.fsproj b/PureGym.Test/PureGym.Test.fsproj index 1624b9b..ccb86d2 100644 --- a/PureGym.Test/PureGym.Test.fsproj +++ b/PureGym.Test/PureGym.Test.fsproj @@ -14,7 +14,7 @@ - + diff --git a/PureGym.Test/TestJson.fs b/PureGym.Test/TestJson.fs index 1e97558..f706433 100644 --- a/PureGym.Test/TestJson.fs +++ b/PureGym.Test/TestJson.fs @@ -1,7 +1,12 @@ namespace PureGym.Test open System +open System.IO +open System.Reflection.Metadata +open System.Reflection.PortableExecutable +open System.Text.Json open System.Text.Json.Nodes +open System.Text.Json.Serialization open NUnit.Framework open FsUnitTyped open PureGym 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 f81c848..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,30 +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 -> None - | v -> v.AsValue().GetValue () |> Some + | 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") ) ) @@ -265,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") ) ) @@ -277,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") ) ) @@ -288,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") ) ) @@ -324,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 @@ -376,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 @@ -582,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 @@ -705,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 @@ -794,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 @@ -843,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 @@ -892,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") ) ) @@ -909,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 @@ -955,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") ) ) @@ -973,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 @@ -991,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 @@ -1010,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/flake.lock b/flake.lock index e0fb3ff..a2e89bf 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1701680307, - "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1703792911, - "narHash": "sha256-BzCq3IiOlTghYtgPngIUnJDeGlRdz4RJGyS9faONrOE=", + "lastModified": 1717189619, + "narHash": "sha256-oPvX7QAu/7R+OOXPeXMj9qTm7fo1+S1Yw34ed+GI+WA=", "owner": "nixos", "repo": "nixpkgs", - "rev": "1d17e304ac93dde75178d7ad47abbecc0357c937", + "rev": "ee19df781051348c4b1aaf895779ab47f50b7c26", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 61e31c6..4b02ce2 100644 --- a/flake.nix +++ b/flake.nix @@ -6,7 +6,7 @@ }; }; - outputs = inputs @ { + outputs = { self, nixpkgs, flake-utils, @@ -39,38 +39,16 @@ runHook postInstall ''; }; - fantomas = dotnetTool "fantomas" (builtins.fromJSON (builtins.readFile ./.config/dotnet-tools.json)).tools.fantomas.version "sha256-83RodORaC3rkYfbFMHsYLEtl0+8+akZXcKoSJdgwuUo="; + fantomas = dotnetTool "fantomas" (builtins.fromJSON (builtins.readFile ./.config/dotnet-tools.json)).tools.fantomas.version (builtins.head (builtins.filter (elem: elem.pname == "fantomas") ((import ./nix/deps.nix) {fetchNuGet = x: x;}))).sha256; in { packages = { fantomas = fantomas; - fetchDeps = let - flags = []; - runtimeIds = ["win-x64"] ++ map (system: pkgs.dotnetCorePackages.systemToDotnetRid system) dotnet-sdk.meta.platforms; - in - pkgs.writeShellScriptBin "fetch-${pname}-deps" (builtins.readFile (pkgs.substituteAll { - src = ./nix/fetchDeps.sh; - pname = pname; - binPath = pkgs.lib.makeBinPath [pkgs.coreutils dotnet-sdk (pkgs.nuget-to-nix.override {inherit dotnet-sdk;})]; - projectFiles = toString (pkgs.lib.toList projectFile); - testProjectFiles = toString (pkgs.lib.toList testProjectFile); - rids = pkgs.lib.concatStringsSep "\" \"" runtimeIds; - packages = dotnet-sdk.packages; - storeSrc = pkgs.srcOnly { - src = ./.; - pname = pname; - version = version; - }; - })); default = pkgs.buildDotnetModule { - pname = pname; + inherit pname version projectFile testProjectFile dotnet-sdk dotnet-runtime; name = "puregym"; - version = version; src = ./.; - projectFile = projectFile; - nugetDeps = ./nix/deps.nix; + nugetDeps = ./nix/deps.nix; # `nix build .#default.passthru.fetch-deps && ./result` and put the result here doCheck = true; - dotnet-sdk = dotnet-sdk; - dotnet-runtime = dotnet-runtime; }; }; apps = { diff --git a/nix/deps.nix b/nix/deps.nix index ec682d2..29fc652 100644 --- a/nix/deps.nix +++ b/nix/deps.nix @@ -1,11 +1,6 @@ # This file was automatically generated by passthru.fetch-deps. -# Please don't edit it manually, your changes might get overwritten! +# Please dont edit it manually, your changes might get overwritten! {fetchNuGet}: [ - (fetchNuGet { - pname = "fantomas"; - version = "6.2.0"; - sha256 = "sha256-83RodORaC3rkYfbFMHsYLEtl0+8+akZXcKoSJdgwuUo="; - }) (fetchNuGet { pname = "ApiSurface"; version = "4.0.12"; @@ -21,6 +16,11 @@ version = "3.2.0"; sha256 = "1qxpv8v10p5wn162lzdm193gdl6c5f81zadj8h889dprlnj3g8yr"; }) + (fetchNuGet { + pname = "fantomas"; + version = "6.3.4"; + sha256 = "1bf57pzvl0i1bgic2vf08mqlzzbd5kys1ip9klrhm4f155ksm9fm"; + }) (fetchNuGet { pname = "Fastenshtein"; version = "1.0.0.8"; @@ -28,19 +28,14 @@ }) (fetchNuGet { pname = "FsCheck"; - version = "2.16.6"; - sha256 = "176rwky6b5rk8dzldiz4068p7m9c5y9ygzbhadrs14jkl94pc56n"; + version = "3.0.0-rc1"; + sha256 = "0s7ks13gwdzzjpzqqshyg72q8max3b6a7yb91jkzyg597m7anrwk"; }) (fetchNuGet { pname = "FSharp.Core"; version = "6.0.1"; sha256 = "0qks2aadkhsffg9a6xq954ll9xacnph852avd7ljh9n2g6vj06qj"; }) - (fetchNuGet { - pname = "FSharp.Core"; - version = "8.0.100"; - sha256 = "06z3vg8yj7i83x6gmnzl2lka1bp4hzc07h6mrydpilxswnmy2a0l"; - }) (fetchNuGet { pname = "FsUnit"; version = "5.6.1"; @@ -48,58 +43,28 @@ }) (fetchNuGet { pname = "Microsoft.AspNetCore.App.Ref"; - version = "6.0.25"; - sha256 = "1vrmqn5j6ibwkqasbf7x7n4w5jdclnz3giymiwvym2wa0y5zc59q"; + version = "6.0.30"; + sha256 = "17k3l8xd5bsyk69bm5q4nxbpb4i0izw1kzmzi7j3p8pmm9prgrpy"; }) (fetchNuGet { pname = "Microsoft.AspNetCore.App.Runtime.linux-arm64"; - version = "6.0.25"; - sha256 = "0mgcs4si7mwd0f555s1vg17pf4nqfaijd1pci359l1pgrmv70rrg"; - }) - (fetchNuGet { - pname = "Microsoft.AspNetCore.App.Runtime.linux-arm64"; - version = "8.0.0"; - sha256 = "05y1xb5fw8lzvb4si77a5qwfwfz1855crqbphrwky6x9llivbhkx"; + version = "6.0.30"; + sha256 = "1n4v5przbrjhzj01b6qijpdc2jbsxr66ijvd0483qxh4s0b4jppr"; }) (fetchNuGet { pname = "Microsoft.AspNetCore.App.Runtime.linux-x64"; - version = "6.0.25"; - sha256 = "0wvzhqhlmlbnpa18qp8m3wcrlcgj3ckvp3iv2n7g8vb60c3238aq"; - }) - (fetchNuGet { - pname = "Microsoft.AspNetCore.App.Runtime.linux-x64"; - version = "8.0.0"; - sha256 = "18zdbcb2bn7wy1dp14z5jyqiiwr9rkad1lcb158r5ikjfq1rg5iw"; + version = "6.0.30"; + sha256 = "18v0l07q74m5xxaf6y6dkmr6and8ivya0nslffnr4djrxcbiygdr"; }) (fetchNuGet { pname = "Microsoft.AspNetCore.App.Runtime.osx-arm64"; - version = "6.0.25"; - sha256 = "1pywgvb8ck1d5aadmijd5s3z6yclchd9pa6dsahijmm55ibplx36"; - }) - (fetchNuGet { - pname = "Microsoft.AspNetCore.App.Runtime.osx-arm64"; - version = "8.0.0"; - sha256 = "1nbxzmj6cnccylxis67c54c0ik38ma4rwdvgg6sxd6r04219maqm"; + version = "6.0.30"; + sha256 = "0p53lyqmr5n2ym202pbgmsd9b9aa6jar7ic04dcq86h2g77r5jqk"; }) (fetchNuGet { pname = "Microsoft.AspNetCore.App.Runtime.osx-x64"; - version = "6.0.25"; - sha256 = "1zlf0w7i6r02719dv3nw4jy14sa0rs53i89an5alz5qmywdy3f1d"; - }) - (fetchNuGet { - pname = "Microsoft.AspNetCore.App.Runtime.osx-x64"; - version = "8.0.0"; - sha256 = "1wqkbjd1ywv9w397l7rsb89mijc5n0hv7jq9h09xfz6wn9qsp152"; - }) - (fetchNuGet { - pname = "Microsoft.AspNetCore.App.Runtime.win-x64"; - version = "6.0.25"; - sha256 = "1fbsnm4056cpd4avgpi5sq05m1yd9k4x229ckxpr4q7yc94sncwy"; - }) - (fetchNuGet { - pname = "Microsoft.AspNetCore.App.Runtime.win-x64"; - version = "8.0.0"; - sha256 = "08vlmswmiyp2nxlr9d77716hk7kz7h9x5bl8wh76xzbj5id1xlb2"; + version = "6.0.30"; + sha256 = "009srl8vazkjnd93xr6k1m353spbki9gn1yzp4zgazgbrini6rqc"; }) (fetchNuGet { pname = "Microsoft.CodeCoverage"; @@ -113,103 +78,48 @@ }) (fetchNuGet { pname = "Microsoft.NETCore.App.Host.linux-arm64"; - version = "6.0.25"; - sha256 = "052388yjivzkfllkss0nljbzmjx787jqdjsbb6ls855sp6wh9xfd"; - }) - (fetchNuGet { - pname = "Microsoft.NETCore.App.Host.linux-arm64"; - version = "8.0.0"; - sha256 = "0bpg3v9dnalz7yh7lsgriw9rnm9jx37mqhhvf7snznb3sfk7rgwb"; + version = "6.0.30"; + sha256 = "0l3gjhmnjd5n67w83smqyhmfcwzszafjgcbq8kdwxiwwh2m6nh2i"; }) (fetchNuGet { pname = "Microsoft.NETCore.App.Host.linux-x64"; - version = "6.0.25"; - sha256 = "103xy6kncjwbbchfnpqvsjpjy92x3dralcg9pw939jp0dwggwarz"; - }) - (fetchNuGet { - pname = "Microsoft.NETCore.App.Host.linux-x64"; - version = "8.0.0"; - sha256 = "1c7l68bm05d94x5wk1y33mnd4v8m196vyprgrzqnh94yrqy6fkf7"; + version = "6.0.30"; + sha256 = "0ss3108c2h7afypvliyqixv4dll60sq9iwqy90k1p132znpszrmb"; }) (fetchNuGet { pname = "Microsoft.NETCore.App.Host.osx-arm64"; - version = "6.0.25"; - sha256 = "13m14pdx5xfxky07xgxf6hjd7g9l4k6k40wvp9znhvn27pa0wdxv"; + version = "6.0.30"; + sha256 = "08k5v35mvcs712kb0vcfjd1dsas5rgwrmv8rn87mzjb2p6ajl3n3"; }) (fetchNuGet { pname = "Microsoft.NETCore.App.Host.osx-x64"; - version = "6.0.25"; - sha256 = "132pgjhv42mqzx4007sd59bkds0fwsv5xaz07y2yffbn3lzr228k"; - }) - (fetchNuGet { - pname = "Microsoft.NETCore.App.Host.osx-x64"; - version = "8.0.0"; - sha256 = "0jmzf58vv45j0hqlxq8yalpjwi328vp2mjr3h0pdg0qr143iivnr"; - }) - (fetchNuGet { - pname = "Microsoft.NETCore.App.Host.win-x64"; - version = "6.0.25"; - sha256 = "039433rm4w37h9qri11v3lrpddpz7zcly9kq8vmk6w1ixzlqwf01"; - }) - (fetchNuGet { - pname = "Microsoft.NETCore.App.Host.win-x64"; - version = "8.0.0"; - sha256 = "1n8yr13df2f6jhxpfazs6rxahfqm18fhjvfm16g5d60c3za1hwnk"; + version = "6.0.30"; + sha256 = "02x38c68xan8hlr59mindcl4rcx49bbh4bibh6fw1l4rrijb38lw"; }) (fetchNuGet { pname = "Microsoft.NETCore.App.Ref"; - version = "6.0.25"; - sha256 = "0jfhmfxpx1h4f3axgf60gc8d4cnlvbb853400kag6nk0875hr0x1"; + version = "6.0.30"; + sha256 = "1wqqjhhlqz4dmijcx3kg3hnwq0s0jzqsddaksskzhq8avr4ziy18"; }) (fetchNuGet { pname = "Microsoft.NETCore.App.Runtime.linux-arm64"; - version = "6.0.25"; - sha256 = "0jpcmva1l8z36r4phz055l7fz9s6z8pv8pqc4ia69mhhgvr0ks7y"; - }) - (fetchNuGet { - pname = "Microsoft.NETCore.App.Runtime.linux-arm64"; - version = "8.0.0"; - sha256 = "0gwqmkmr7jy3sjh9gha82amlry41gp8nwswy2iqfw54f28db63n7"; + version = "6.0.30"; + sha256 = "0xfhcig3gj3986rxp3dhnd8hvnj4nvyhz1fz7kpx342d3g53wb37"; }) (fetchNuGet { pname = "Microsoft.NETCore.App.Runtime.linux-x64"; - version = "6.0.25"; - sha256 = "012jml0bqxbspahf1j4bvvd91pz85hsbcyhq00gxczcazhxpkhz4"; - }) - (fetchNuGet { - pname = "Microsoft.NETCore.App.Runtime.linux-x64"; - version = "8.0.0"; - sha256 = "042cjvnwrrjs3mw5q8q5kinh0cwkks33i3n1vyifaid2jbr3wlc0"; + version = "6.0.30"; + sha256 = "1s81sj8lnb8szqawxh3vc8wi815ln12cyhrl3f7hwcpay57xgswx"; }) (fetchNuGet { pname = "Microsoft.NETCore.App.Runtime.osx-arm64"; - version = "6.0.25"; - sha256 = "0wgwxpyy1n550sw7npjg69zpxknwn0ay30m2qybvqb5mj857qzxi"; - }) - (fetchNuGet { - pname = "Microsoft.NETCore.App.Runtime.osx-arm64"; - version = "8.0.0"; - sha256 = "06ndp4wh1cap01dql3nixka4g56bf6ipmqys7xaxvg4xisf79x8d"; + version = "6.0.30"; + sha256 = "0s71k92daakzwish65gmn4nniy6bf2hv34c0sb6m1hv3criqxmp4"; }) (fetchNuGet { pname = "Microsoft.NETCore.App.Runtime.osx-x64"; - version = "6.0.25"; - sha256 = "08vr7c5bg5x3w35l54z1azif7ysfc2yiyz50ip1dl0mpqywvlswr"; - }) - (fetchNuGet { - pname = "Microsoft.NETCore.App.Runtime.osx-x64"; - version = "8.0.0"; - sha256 = "1kh5bnaf6h9mr4swcalrp304625frjiw6mlz1052rxwzsdq98a96"; - }) - (fetchNuGet { - pname = "Microsoft.NETCore.App.Runtime.win-x64"; - version = "6.0.25"; - sha256 = "03snpmx204xvc9668riisvvdjjgdqhwj7yjp85w5lh8j8ygrqkif"; - }) - (fetchNuGet { - pname = "Microsoft.NETCore.App.Runtime.win-x64"; - version = "8.0.0"; - sha256 = "054icf5jjnwnswrnv1r05x3pfjvacbz6g3dj8caar1zp53k49rkk"; + version = "6.0.30"; + sha256 = "0xybqg2wd240r1nm2vrbn2qbfqfnqsmxn1012zzwjn17wa2si9a1"; }) (fetchNuGet { pname = "Microsoft.NETCore.Platforms"; diff --git a/nix/fetchDeps.sh b/nix/fetchDeps.sh deleted file mode 100755 index e15b822..0000000 --- a/nix/fetchDeps.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash - -# This file was adapted from -# https://github.com/NixOS/nixpkgs/blob/b981d811453ab84fb3ea593a9b33b960f1ab9147/pkgs/build-support/dotnet/build-dotnet-module/default.nix#L173 -set -euo pipefail -export PATH="@binPath@" -for arg in "$@"; do - case "$arg" in - --keep-sources|-k) - keepSources=1 - shift - ;; - --help|-h) - echo "usage: $0 [--keep-sources] [--help] " - echo " The path to write the lockfile to. A temporary file is used if this is not set" - echo " --keep-sources Don't remove temporary directories upon exit, useful for debugging" - echo " --help Show this help message" - exit - ;; - esac -done -tmp=$(mktemp -td "@pname@-tmp-XXXXXX") -export tmp -HOME=$tmp/home -exitTrap() { - test -n "${ranTrap-}" && return - ranTrap=1 - if test -n "${keepSources-}"; then - echo -e "Path to the source: $tmp/src\nPath to the fake home: $tmp/home" - else - rm -rf "$tmp" - fi - # Since mktemp is used this will be empty if the script didnt succesfully complete - if ! test -s "$depsFile"; then - rm -rf "$depsFile" - fi -} -trap exitTrap EXIT INT TERM -dotnetRestore() { - local -r project="${1-}" - local -r rid="$2" - dotnet restore "${project-}" \ - -p:ContinuousIntegrationBuild=true \ - -p:Deterministic=true \ - --packages "$tmp/nuget_pkgs" \ - --runtime "$rid" \ - --no-cache \ - --force -} -declare -a projectFiles=( @projectFiles@ ) -declare -a testProjectFiles=( @testProjectFiles@ ) -export DOTNET_NOLOGO=1 -export DOTNET_CLI_TELEMETRY_OPTOUT=1 -depsFile=$(realpath "${1:-$(mktemp -t "@pname@-deps-XXXXXX.nix")}") -mkdir -p "$tmp/nuget_pkgs" -storeSrc="@storeSrc@" -src="$tmp/src" -cp -rT "$storeSrc" "$src" -chmod -R +w "$src" -cd "$src" -echo "Restoring project..." -rids=("@rids@") -for rid in "${rids[@]}"; do - (( ${#projectFiles[@]} == 0 )) && dotnetRestore "" "$rid" - for project in "${projectFiles[@]-}" "${testProjectFiles[@]-}"; do - dotnetRestore "$project" "$rid" - done -done -echo "Successfully restored project" -echo "Writing lockfile..." -echo -e "# This file was automatically generated by passthru.fetch-deps.\n# Please don't edit it manually, your changes might get overwritten!\n" > "$depsFile" -nuget-to-nix "$tmp/nuget_pkgs" "@packages@" >> "$depsFile" -echo "Successfully wrote lockfile to $depsFile" -- 2.51.0 From 550fb4de6c9fb639d095f2131ebb90630a2c88fb Mon Sep 17 00:00:00 2001 From: Smaug123 <3138005+Smaug123@users.noreply.github.com> Date: Sat, 1 Jun 2024 00:35:24 +0100 Subject: [PATCH 2/2] Format --- .fantomasignore | 1 + PureGym/GeneratedClient.fs | 138 ++++++------ PureGym/GeneratedDto.fs | 438 ++++++++++++++++++++----------------- 3 files changed, 302 insertions(+), 275 deletions(-) create mode 100644 .fantomasignore diff --git a/.fantomasignore b/.fantomasignore new file mode 100644 index 0000000..9b42106 --- /dev/null +++ b/.fantomasignore @@ -0,0 +1 @@ +.direnv/ diff --git a/PureGym/GeneratedClient.fs b/PureGym/GeneratedClient.fs index 8110c6d..1b95858 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 e17c915..f81c848 100644 --- a/PureGym/GeneratedDto.fs +++ b/PureGym/GeneratedDto.fs @@ -12,34 +12,36 @@ 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 @@ -47,33 +49,35 @@ 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 @@ -81,19 +85,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 @@ -102,13 +106,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 () @@ -120,13 +124,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 @@ -135,21 +139,23 @@ 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 @@ -157,64 +163,66 @@ 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 @@ -222,30 +230,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 -> None - | v -> v.AsValue().GetValue() |> Some + | 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") ) ) @@ -257,7 +265,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") ) ) @@ -269,7 +277,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") ) ) @@ -280,32 +288,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") ) ) @@ -316,49 +324,51 @@ 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 @@ -366,203 +376,205 @@ 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 @@ -570,120 +582,122 @@ 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 @@ -691,86 +705,88 @@ 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 @@ -778,46 +794,48 @@ 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 @@ -825,46 +843,48 @@ 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 @@ -872,13 +892,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") ) ) @@ -889,43 +909,45 @@ 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 @@ -933,13 +955,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") ) ) @@ -951,14 +973,17 @@ 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 @@ -966,17 +991,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 @@ -985,13 +1010,14 @@ 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 + } -- 2.51.0