Skip to content

Commit

Permalink
Merge pull request #91 from seamapi/default_value_for_since_in_events…
Browse files Browse the repository at this point in the history
…_list

Set default value for 'since' param while executing events/list
  • Loading branch information
kainpets authored Feb 19, 2024
2 parents f5b718f + e922d36 commit ceed216
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ async function cli(args: ParsedArgs) {
} else if (isEqual(selectedCommand, ["select", "workspace"])) {
await interactForWorkspaceId()
return
} else if (isEqual(selectedCommand, ["events", "list"])) {
if (!commandParams.since) {
const date = new Date()
date.setMonth(date.getMonth() - 1)
commandParams.since = date.toISOString()
}
} else if (isEqual(selectedCommand, ["select", "server"])) {
if (args.server) {
config.set("server", args.server)
Expand All @@ -166,7 +172,6 @@ async function cli(args: ParsedArgs) {
await interactForServerSelection()
return
}

// TODO - do this using the OpenAPI spec for the command rather than
// explicitly encoding the property names
if (commandParams.accepted_providers) {
Expand Down Expand Up @@ -201,6 +206,10 @@ async function cli(args: ParsedArgs) {

const apiPath = `/${selectedCommand.join("/").replace(/-/g, "_")}`

if (apiPath.includes("/events/list") && params.between) {
delete params.since
}

console.log(`\n\n${chalk.green(apiPath)}`)
console.log(`Request Params:`)
console.log(params)
Expand Down

0 comments on commit ceed216

Please sign in to comment.