-
Notifications
You must be signed in to change notification settings - Fork 1
/
create.ts
36 lines (31 loc) · 1.02 KB
/
create.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
import { Sms, SmsService } from '@sinch/sdk-core';
import { getPrintFormat, printFullResponse } from '../../../config';
export const create = async(smsService: SmsService) => {
console.log('***************');
console.log('* CreateGroup *');
console.log('***************');
const requestData: Sms.CreateGroupRequestData = {
createGroupRequestBody: {
name: `Group_${new Date().getTime()}`,
members: [
'+11111111100',
'+22222222200',
'+33333333300',
],
},
};
let response;
try {
response = await smsService.groups.create(requestData);
} catch (error) {
console.error('ERROR: Impossible to create a new group');
throw error;
}
const printFormat = getPrintFormat(process.argv);
if (printFormat === 'pretty') {
console.log(`New group created! Group ID: ${response.id} - Group name: ${response.name}`);
} else {
printFullResponse(response);
}
console.log(`You may want to update your .env file with the following value: GROUP_ID=${response.id}`);
};