-
Notifications
You must be signed in to change notification settings - Fork 0
/
add.ts
41 lines (34 loc) · 1.1 KB
/
add.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import {Flags} from '@oclif/core';
import {Command, T} from '../../../base-command';
export type Schedule = {
success: boolean;
schedule: T.Schedule;
};
export default class Add extends Command<Schedule> {
static description = 'Add call to schedule.';
protected permitKeyAuth = true;
static examples = [
'<%= config.bin %> <%= command.id %> --schedule-id ag9zfmFwaW1ldHJpY3MtcWNyFQsSCFNjaGVkdWxlGICA4Pbn4ZILDA --call-id ag9zfmFwaW1ldHJpY3MtcWNyFwsSClRlc3RTZXR1cDIYgIDg9f3DuAoM',
];
static aliases = ['calls:schedules:add'];
static flags = {
'schedule-id': Flags.string({
description: 'ID of schedule to modify.',
char: 's',
required: true,
}),
'call-id': Flags.string({
description: 'ID of call to add.',
char: 'c',
required: true,
}),
};
public async run(): Promise<Schedule> {
const {flags} = await this.parse(Add);
const schedule = await this.api.post<T.Schedule>(
`schedules/${flags['schedule-id']}/call/${flags['call-id']}`,
{} // No body for this POST request
);
return {success: true, schedule: schedule};
}
}