smppjs
Version:
Modern approach to smpp protocol.
53 lines • 2.95 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.submitSmDTO = void 0;
const helpers_1 = require("../helpers");
const types_1 = require("../types");
const helpers_2 = require("../helpers");
const MAX_LENGTH = {
service_type: 6,
source_addr: 21,
destination_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 submitSmDTO = ({ destinationAddr, dataCoding, esmClass, systemTypeValue, sourceAddrTon, sourceAddrNpi, sourceAddr, destAddrTon, destAddrNpi, protocolId, priorityFlag, scheduleDeliveryTime, validityPeriod, registeredDelivery, replaceIfPresentFlag, smDefaultMsgId, shortMessage, tlvs, }) => {
const dto = {
command: {
service_type: { type: 'Cstring', value: systemTypeValue || '' },
source_addr_ton: { type: 'Int8', value: sourceAddrTon || 0 },
source_addr_npi: { type: 'Int8', value: sourceAddrNpi || 0 },
source_addr: { type: 'Cstring', value: sourceAddr || '' },
dest_addr_ton: { type: 'Int8', value: destAddrTon || 0 },
dest_addr_npi: { type: 'Int8', value: destAddrNpi || 0 },
destination_addr: { type: 'Cstring', value: destinationAddr },
esm_class: { type: 'Int8', value: esmClass },
protocol_id: { type: 'Int8', value: protocolId || 0 },
priority_flag: { type: 'Int8', value: priorityFlag || 0 },
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 },
replace_if_present_flag: { type: 'Int8', value: replaceIfPresentFlag || 0 },
data_coding: { type: 'Int8', value: dataCoding },
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,
},
},
tlvs: {
message_payload: { type: 'Cstring', value: (tlvs === null || tlvs === void 0 ? void 0 : tlvs.messagePayload) || '', encode: 'ascii' },
},
};
(0, helpers_2.dtoValidation)({ dto, DATE_TYPE, MAX_LENGTH });
return dto;
};
exports.submitSmDTO = submitSmDTO;
//# sourceMappingURL=submit_sm.js.map