UNPKG

smppjs

Version:
40 lines 2.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.replaceSmDTO = void 0; const helpers_1 = require("../helpers"); const types_1 = require("../types"); const helpers_2 = require("../helpers"); const MAX_LENGTH = { source_addr: 21, short_message: 256, schedule_delivery_time: 17, validity_period: 17, }; const DATE_TYPE = { schedule_delivery_time: types_1.DateType.ABSOLUTE_AND_RELATIVE, validity_period: types_1.DateType.ABSOLUTE_AND_RELATIVE, }; const replaceSmDTO = ({ messageId, sourceAddrTon, sourceAddrNpi, sourceAddr, scheduleDeliveryTime, validityPeriod, registeredDelivery, smDefaultMsgId, shortMessage, }) => { const dto = { command: { message_id: { type: 'Cstring', value: messageId }, source_addr_ton: { type: 'Int8', value: sourceAddrTon || 0 }, source_addr_npi: { type: 'Int8', value: sourceAddrNpi || 0 }, source_addr: { type: 'Cstring', value: sourceAddr || '' }, schedule_delivery_time: { type: 'Cstring', value: scheduleDeliveryTime ? (0, helpers_1.dateToAbsolute)(scheduleDeliveryTime) : '' }, validity_period: { type: 'Cstring', value: validityPeriod ? (0, helpers_1.dateToAbsolute)(validityPeriod) : '' }, registered_delivery: { type: 'Int8', value: registeredDelivery || 0 }, sm_default_msg_id: { type: 'Int8', value: smDefaultMsgId || 0 }, short_message: { type: 'Cstring', value: (shortMessage === null || shortMessage === void 0 ? void 0 : shortMessage.message) || Buffer.alloc(0, '', shortMessage === null || shortMessage === void 0 ? void 0 : shortMessage.encoding), encode: shortMessage === null || shortMessage === void 0 ? void 0 : shortMessage.encoding, setLength: true, }, }, }; (0, helpers_2.dtoValidation)({ dto, DATE_TYPE, MAX_LENGTH }); return dto; }; exports.replaceSmDTO = replaceSmDTO; //# sourceMappingURL=replace_sm.js.map