@ingestkorea/client-sens
Version:
INGESTKOREA SDK Naver Cloud Platform SENS Client for Node.js.
52 lines (51 loc) • 3.4 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.deserializeIngestkorea_restJson_SendSMSOutput = exports.deserializeIngestkorea_restJson_SendSMSCommand = exports.serializeIngestkorea_restJson_SendSMSCommand = void 0;
const util_http_handler_1 = require("@ingestkorea/util-http-handler");
const constants_1 = require("./constants");
const serializeIngestkorea_restJson_SendSMSCommand = (input, config) => __awaiter(void 0, void 0, void 0, function* () {
const hostname = "sens.apigw.ntruss.com";
const path = "/sms/v2/services/" + config.serviceId.sms + "/messages";
const headers = {
"content-type": "application/json; charset=utf-8",
host: hostname,
};
const body = JSON.stringify(Object.assign(Object.assign(Object.assign({ from: input.from, content: input.content, messages: input.messages, type: input.type != undefined ? input.type : "SMS" }, (input.contentType != undefined && { contentType: input.contentType })), (input.countryCode != undefined && { countryCode: input.countryCode })), (input.subject != undefined && input.type === "LMS" && { subject: input.subject })));
return new util_http_handler_1.HttpRequest({
protocol: "https:",
method: "POST",
hostname: hostname,
path: path,
headers: headers,
body: body,
});
});
exports.serializeIngestkorea_restJson_SendSMSCommand = serializeIngestkorea_restJson_SendSMSCommand;
const deserializeIngestkorea_restJson_SendSMSCommand = (response) => __awaiter(void 0, void 0, void 0, function* () {
const { response: httpResponse, output } = response;
if (httpResponse.statusCode > 300)
yield (0, constants_1.parseErrorBody)(httpResponse);
const data = yield (0, constants_1.parseBody)(httpResponse); // SendSMSOutput
let contents = {};
contents = yield (0, exports.deserializeIngestkorea_restJson_SendSMSOutput)(data);
return Object.assign({ $metadata: Object.assign(Object.assign({}, (0, constants_1.deserializeMetadata)(httpResponse)), output.$metadata) }, contents);
});
exports.deserializeIngestkorea_restJson_SendSMSCommand = deserializeIngestkorea_restJson_SendSMSCommand;
const deserializeIngestkorea_restJson_SendSMSOutput = (output) => __awaiter(void 0, void 0, void 0, function* () {
return {
requestId: output.requestId ? output.requestId : undefined,
requestTime: output.requestTime ? output.requestTime : undefined,
statusCode: output.statusCode ? output.statusCode : undefined,
statusName: output.statusName ? output.statusName : undefined,
};
});
exports.deserializeIngestkorea_restJson_SendSMSOutput = deserializeIngestkorea_restJson_SendSMSOutput;