-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlist.ts
28 lines (20 loc) · 1.08 KB
/
list.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
import { Conversation } from '@sinch/sdk-core';
import { getPrintFormat, initConversationService, printFullResponse } from '../../config';
(async () => {
console.log('******************************');
console.log('* Templates_v2_ListTemplates *');
console.log('******************************');
const requestData: Conversation.V2ListTemplatesRequestData = {
};
const conversationService = initConversationService();
const response = await conversationService.templatesV2.list(requestData);
const printFormat = getPrintFormat(process.argv);
if (printFormat === 'pretty') {
console.log(`Templates:\n${response.templates?.map((template) => formatPrettyMessage(template)).join('\n')}`);
} else {
printFullResponse(response);
}
})();
const formatPrettyMessage = (template: Conversation.V2TemplateResponse) => {
return ` - ID: ${template.id} - Default translation: ${template.default_translation} - Version: ${template.version} - Available translations: ${template.translations?.map((translation) => translation.language_code + '(' +translation.version + ')').join(', ')}`;
};