-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget.ts
26 lines (19 loc) · 960 Bytes
/
get.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
import { Conversation } from '@sinch/sdk-core';
import { getPrintFormat, getTemplateIdFromConfig, initConversationService, printFullResponse } from '../../config';
(async () => {
console.log('*************************');
console.log('* Templates_GetTemplate *');
console.log('*************************');
const templateId = getTemplateIdFromConfig();
const requestData: Conversation.GetTemplateRequestData = {
template_id: templateId,
};
const conversationService = initConversationService();
const response = await conversationService.templatesV1.get(requestData);
const printFormat = getPrintFormat(process.argv);
if (printFormat === 'pretty') {
console.log(`Template retrieved from id '${response.id}'.\nDefault translation: ${response.default_translation}\nList of translations: ${response.translations?.map((translation) => translation.language_code).join(', ')}`);
} else {
printFullResponse(response);
}
})();