Add all-gyms
This commit is contained in:
@@ -21,14 +21,17 @@ module GymSelector =
|
||||
let canonicalId (client : IPureGymApi) (gym : GymSelector) : int Task =
|
||||
match gym with
|
||||
| GymSelector.Home ->
|
||||
task {
|
||||
let! self = client.GetMember ()
|
||||
async {
|
||||
let! ct = Async.CancellationToken
|
||||
let! self = Async.AwaitTask (client.GetMember ct)
|
||||
return self.HomeGymId
|
||||
}
|
||||
|> Async.StartAsTask
|
||||
| GymSelector.Id i -> Task.FromResult<_> i
|
||||
| GymSelector.Name name ->
|
||||
task {
|
||||
let! allGyms = client.GetGyms ()
|
||||
async {
|
||||
let! ct = Async.CancellationToken
|
||||
let! allGyms = Async.AwaitTask (client.GetGyms ct)
|
||||
|
||||
if allGyms.IsEmpty then
|
||||
return failwith "PureGym API returned no gyms!"
|
||||
@@ -46,3 +49,4 @@ module GymSelector =
|
||||
|
||||
return bestGym.Id
|
||||
}
|
||||
|> Async.StartAsTask
|
||||
|
Reference in New Issue
Block a user