Add visits info
This commit is contained in:
@@ -260,6 +260,74 @@ type MemberActivityDto =
|
||||
LastRefreshed = this.LastRefreshed
|
||||
}
|
||||
|
||||
type SessionsAggregate =
|
||||
{
|
||||
/// Number of gym "activities" within some query-defined time period; presumably this is like classes?
|
||||
/// It's always 0 for me.
|
||||
Activities : int
|
||||
/// Number of visits to the gym within some query-defined time period.
|
||||
Visits : int
|
||||
/// In minutes: total time spent in gym during the query-defined time period.
|
||||
Duration : int
|
||||
}
|
||||
|
||||
/// The DTO for gym info returned from the Sessions endpoint.
|
||||
type VisitGym =
|
||||
{
|
||||
// Omitting Location, GymAccess, ContactInfo, TimeZone because these were all null for me
|
||||
/// The PureGym ID of this gym, e.g. 19
|
||||
Id : int
|
||||
/// E.g. "London Oval", the canonical name of this gym
|
||||
Name : string
|
||||
/// For some reason this always seems to be "Blocked"
|
||||
Status : string
|
||||
}
|
||||
|
||||
/// Summary of a single visit to a gym.
|
||||
type Visit =
|
||||
{
|
||||
// Omitted Name because it always was null for me
|
||||
/// Whether the Duration field is estimated.
|
||||
IsDurationEstimated : bool
|
||||
/// When the visit began.
|
||||
StartTime : DateTime
|
||||
/// In minutes.
|
||||
Duration : int
|
||||
/// Which gym was visited
|
||||
Gym : VisitGym
|
||||
}
|
||||
|
||||
/// Human-readable non-round-trip representation.
|
||||
override this.ToString () =
|
||||
let startTime = this.StartTime.ToString "yyyy-MM-dd HH:mm"
|
||||
$"%s{this.Gym.Name}: %s{startTime} (%i{this.Duration} minutes)"
|
||||
|
||||
/// Aggregate statistics for gym visits across a time period.
|
||||
type SessionsSummary =
|
||||
{
|
||||
/// Aggregate stats for gym visits within the query-dependent time period.
|
||||
Total : SessionsAggregate
|
||||
/// Aggregate stats for gym visits "this week", whatever that means to PureGym.
|
||||
ThisWeek : SessionsAggregate
|
||||
}
|
||||
|
||||
/// Human-readable non-round-trip representation.
|
||||
override this.ToString () =
|
||||
$"%i{this.Total.Visits} visits, totalling %i{this.Total.Duration} minutes"
|
||||
|
||||
type Sessions =
|
||||
{
|
||||
Summary : SessionsSummary
|
||||
Visits : Visit list
|
||||
}
|
||||
|
||||
/// Human-readable non-round-trip representation.
|
||||
override this.ToString () =
|
||||
let summary = string<SessionsSummary> this.Summary
|
||||
let visits = this.Visits |> Seq.map string<Visit> |> String.concat "\n"
|
||||
|
||||
$"%s{summary}\n%s{visits}"
|
||||
|
||||
/// The PureGym REST API. You probably want to instantiate one of these with `Api.make`.
|
||||
[<Header("User-Agent", "PureGym/1523 CFNetwork/1312 Darwin/21.0.0")>]
|
||||
type IPureGymApi =
|
||||
@@ -283,6 +351,10 @@ type IPureGymApi =
|
||||
[<Get "v1/member/activity">]
|
||||
abstract GetMemberActivity : unit -> Task<MemberActivityDto>
|
||||
|
||||
/// Get information about the individual visits to all PureGyms the currently-authenticated PureGym human has made.
|
||||
[<Get "v2/gymSessions/member">]
|
||||
abstract GetSessions : [<Query>] fromDate : DateTime -> [<Query>] toDate : DateTime -> Task<Sessions>
|
||||
|
||||
// [<Get "v1/member/activity/history">]
|
||||
// abstract GetMemberActivityAll : unit -> Task<string>
|
||||
|
||||
|
Reference in New Issue
Block a user