diff --git a/ConsumePlugin/ConsumePlugin.fsproj b/ConsumePlugin/ConsumePlugin.fsproj index 6e9c951..808c436 100644 --- a/ConsumePlugin/ConsumePlugin.fsproj +++ b/ConsumePlugin/ConsumePlugin.fsproj @@ -1,41 +1,41 @@  - - net8.0 - false - - - - + + net8.0 + false + + + + - - - - - RecordFile.fs - - - - JsonRecord.fs - - - - PureGymDto.fs - - - - RestApiExample.fs - - - runmyriad.sh - - + + + + + RecordFile.fs + + + + JsonRecord.fs + + + + PureGymDto.fs + + + + RestApiExample.fs + + + runmyriad.sh + + - - - - - - + + + + + + diff --git a/ConsumePlugin/GeneratedRestClient.fs b/ConsumePlugin/GeneratedRestClient.fs index 6c44f90..7e8facb 100644 --- a/ConsumePlugin/GeneratedRestClient.fs +++ b/ConsumePlugin/GeneratedRestClient.fs @@ -51,7 +51,8 @@ module PureGymApi = System.Uri ( client.BaseAddress, System.Uri ( - "v1/gyms/{gym_id}/attendance".Replace ("{gym_id}", gymId.ToString ()), + "v1/gyms/{gym_id}/attendance" + .Replace ("{gym_id}", gymId.ToString () |> System.Web.HttpUtility.UrlEncode), System.UriKind.Relative ) ) @@ -107,7 +108,8 @@ module PureGymApi = System.Uri ( client.BaseAddress, System.Uri ( - "v1/gyms/{gym_id}".Replace ("{gym_id}", gymId.ToString ()), + "v1/gyms/{gym_id}" + .Replace ("{gym_id}", gymId.ToString () |> System.Web.HttpUtility.UrlEncode), System.UriKind.Relative ) ) @@ -189,4 +191,31 @@ module PureGymApi = return Sessions.jsonParse node } |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) + + member _.GetPathParam (parameter : string, ct : CancellationToken option) = + async { + let! ct = Async.CancellationToken + + let uri = + System.Uri ( + client.BaseAddress, + System.Uri ( + "endpoint/{param}" + .Replace ("{param}", parameter.ToString () |> System.Web.HttpUtility.UrlEncode), + System.UriKind.Relative + ) + ) + + let httpMessage = + new System.Net.Http.HttpRequestMessage ( + Method = System.Net.Http.HttpMethod.Get, + RequestUri = uri + ) + + let! response = client.SendAsync (httpMessage, ct) |> Async.AwaitTask + let response = response.EnsureSuccessStatusCode () + let! node = response.Content.ReadAsStringAsync ct |> Async.AwaitTask + return node + } + |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) } diff --git a/ConsumePlugin/RestApiExample.fs b/ConsumePlugin/RestApiExample.fs index c1ccc68..df33809 100644 --- a/ConsumePlugin/RestApiExample.fs +++ b/ConsumePlugin/RestApiExample.fs @@ -26,3 +26,6 @@ type IPureGymApi = [] abstract GetSessions : [] fromDate : DateOnly * [] toDate : DateOnly * ?ct : CancellationToken -> Task + + [] + abstract GetPathParam : [] parameter : string * ?ct : CancellationToken -> Task diff --git a/Directory.Build.props b/Directory.Build.props index a77d3a7..8a619c2 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -10,9 +10,9 @@ embedded - - - + + + - + - - - - - - - - + + + + + + + + True \