@ingestkorea/client-sens
Version:
INGESTKOREA SDK Naver Cloud Platform SENS Client for Node.js.
67 lines (66 loc) • 2.71 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.de_Template = exports.de_ListAlimtalkTemplatesCommand = exports.se_ListAlimtalkTemplatesCommand = void 0;
const util_http_handler_1 = require("@ingestkorea/util-http-handler");
const constants_js_1 = require("./constants.js");
const se_ListAlimtalkTemplatesCommand = async (input, config) => {
const hostname = "sens.apigw.ntruss.com";
const path = "/alimtalk/v2/services/" + config.serviceId.kakao + "/templates";
const headers = {
host: hostname,
};
const query = {
channelId: input.channelId,
};
return new util_http_handler_1.HttpRequest({
protocol: "https:",
method: "GET",
hostname: hostname,
path: path,
query: query,
headers: headers,
});
};
exports.se_ListAlimtalkTemplatesCommand = se_ListAlimtalkTemplatesCommand;
const de_ListAlimtalkTemplatesCommand = async (response, config) => {
if (response.statusCode >= 300)
await (0, constants_js_1.parseErrorBody)(response);
const data = await (0, constants_js_1.parseBody)(response);
const contents = de_ListAlimtalkTemplatesResult(data);
return {
$metadata: (0, constants_js_1.deserializeMetadata)(response),
...(0, constants_js_1.compact)(contents),
};
};
exports.de_ListAlimtalkTemplatesCommand = de_ListAlimtalkTemplatesCommand;
const de_ListAlimtalkTemplatesResult = (output) => {
return {
templates: Array.isArray(output) ? de_TemplateList(output) : [],
};
};
const de_TemplateList = (output) => {
return (output || [])
.filter((e) => e != null)
.map((entry) => (0, exports.de_Template)(entry))
.sort((a, b) => {
var _a, _b;
// 생성 날짜 기준 내림차순
const dateA = ((_a = a.createTime) !== null && _a !== void 0 ? _a : "").replace(/\.\d{3}Z?$/, "");
const dateB = ((_b = b.createTime) !== null && _b !== void 0 ? _b : "").replace(/\.\d{3}Z?$/, "");
if (dateB < dateA)
return -1;
if (dateB > dateA)
return 1;
return 0;
});
};
const de_Template = (output) => {
return {
createTime: output.createTime ? (0, constants_js_1.convertToUtc)(output.createTime) : undefined,
updateTime: output.updateTime ? (0, constants_js_1.convertToUtc)(output.updateTime) : undefined,
channelId: output.channelId != undefined ? output.channelId : undefined,
templateCode: output.templateCode != undefined ? output.templateCode : undefined,
templateName: output.templateName != undefined ? output.templateName : undefined,
};
};
exports.de_Template = de_Template;