Files
puregym-unofficial-dotnet/PureGym.App/Sessions.fs
Smaug123 77ceafde0b
All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/all-checks-complete Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/all-checks-complete Pipeline was successful
Add visits info
2023-11-01 16:43:33 +00:00

50 lines
1.4 KiB
Forth

namespace PureGym.App
open Argu
open PureGym
open System
type SessionsArgsFragment =
| [<Mandatory ; EqualsAssignmentOrSpaced>] From_Date of string
| [<Mandatory ; EqualsAssignmentOrSpaced>] To_Date of string
interface IArgParserTemplate with
member s.Usage =
match s with
| From_Date _ -> "start of date range (inclusive) for query, which needs to parse as a DateTime"
| To_Date _ -> "end of date range (inclusive) for query, which needs to parse as a DateTime"
type SessionsArgs =
{
Creds : Auth
FromDate : DateTime
ToDate : DateTime
}
static member Parse
(auth : Auth)
(args : SessionsArgsFragment ParseResults)
: Result<SessionsArgs, ArguParseException>
=
let fromDate = args.GetResult SessionsArgsFragment.From_Date
let toDate = args.GetResult SessionsArgsFragment.To_Date
{
Creds = auth
FromDate = DateTime.Parse fromDate
ToDate = DateTime.Parse toDate
}
|> Ok
[<RequireQualifiedAccess>]
module Sessions =
let run (args : SessionsArgs) =
task {
let! client = Api.make args.Creds
let! activity = client.GetSessions args.FromDate args.ToDate
System.Console.WriteLine (string<Sessions> activity)
return 0
}