-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate.ts
38 lines (31 loc) · 1.04 KB
/
update.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
import { SmsService, Sms } from '@sinch/sdk-core';
import { getGroupIdFromConfig, getPrintFormat, printFullResponse } from '../../../config';
export const update = async(smsService: SmsService) => {
console.log('***************');
console.log('* UpdateGroup *');
console.log('***************');
const groupId = getGroupIdFromConfig();
const requestData: Sms.UpdateGroupRequestData = {
group_id: groupId,
updateGroupRequestBody: {
name: `update_${new Date().getTime()}`,
add: [
'+123456789',
'+987654321',
],
},
};
let response;
try {
response = await smsService.groups.update(requestData);
} catch (error) {
console.error(`ERROR: Impossible to update the group ${requestData.group_id}`);
throw error;
}
const printFormat = getPrintFormat(process.argv);
if (printFormat === 'pretty') {
console.log(`The group ${response.id} has been updated and has now the name '${response.name}' and contains ${response.size} member(s)`);
} else {
printFullResponse(response);
}
};