namespace PureGym open System open System.Net.Http open System.Threading.Tasks open RestEase /// The PureGym REST API. You probably want to instantiate one of these with `Api.make`. [] type IPureGymApi = /// Get the complete list of all gyms known to PureGym. [] abstract GetGyms : unit -> Task /// Get information about the PureGym human whose credentials this client is authenticated with. [] abstract GetMember : unit -> Task /// Get information about how full the given gym currently is. The gym ID can be found from `GetGyms`. [] abstract GetGymAttendance : [] gymId : int -> Task /// Get information about a specific gym. [] abstract GetGym : [] gymId : int -> Task /// Get information about the activities logged against the currently authenticated PureGym human. [] abstract GetMemberActivity : unit -> Task /// Get information about the individual visits to all PureGyms the currently-authenticated PureGym human has made. [] abstract GetSessions : [] fromDate : DateTime -> [] toDate : DateTime -> Task // [] // abstract GetMemberActivityAll : unit -> Task /// Methods for interacting with the PureGym REST API. [] module Dto = /// Create a REST client, authenticated as the specified user. let make (auth : Auth) : IPureGymApi Task = task { let! token = match auth with | Auth.Token t -> Task.FromResult<_> t | Auth.User cred -> AuthToken.get cred let client = new HttpClient () client.BaseAddress <- Uri "https://capi.puregym.com/api" client.DefaultRequestHeaders.Authorization <- Headers.AuthenticationHeaderValue ("Bearer", token.AccessToken) client.DefaultRequestHeaders.Add ("User-Agent", "PureGym/1523 CFNetwork/1312 Darwin/21.0.0") return RestClient.For client }