// dotnet run -- me | pull-orders | invoices // Settings: SLFLO_TOKEN, SLFLO_BASE (default https://api.slflo.com/api/integration/v1), STATE_DIR. using System.Text.Json; using Slflo.Samples; var api = SlfloClient.FromEnvironment(); try { object result = (args.FirstOrDefault() ?? "me") switch { "me" => await Me(api), "pull-orders" => await PullOrders.RunAsync(api), "invoices" => await InvoicesBySeq.RunAsync(api), var other => throw new ArgumentException($"Unknown sample '{other}': me, pull-orders or invoices"), }; Console.WriteLine(JsonSerializer.Serialize(result)); return 0; } catch (TokenRefusedException refused) { // Stop the job and alert someone: retrying won't help. Console.WriteLine(JsonSerializer.Serialize(new { ok = false, refused = refused.Code })); return 3; } static async Task Me(SlfloClient api) { var me = (await api.GetAsync("/me"))["data"]!; return new { ok = true, client = me["client"]!["name"]!.GetValue(), token_prefix = me["client"]!["token_prefix"]!.GetValue(), company = me["company"]!["code"]!.GetValue(), }; }