From f70cd0609afcaf53df43d0fb8839b3dc352b6eb0 Mon Sep 17 00:00:00 2001 From: mohsin-plivo Date: Tue, 11 Jul 2023 20:56:17 +0530 Subject: [PATCH 1/3] SMS-6010: Add DLT Params to Send and Get Message APIs --- Makefile | 4 ++++ lib/resources/messages.js | 24 ++++++++++++++++++++++++ lib/rest/request-test.js | 15 ++++++++++++--- test/messages.js | 22 ++++++++++++++++++++++ 4 files changed, 62 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index e3a0eb54..d7d18431 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,10 @@ build: docker-compose up --build --remove-orphans +start: + docker-compose up --build --remove-orphans --detach + docker attach $(shell docker-compose ps -q nodeSDK) + test: @[ "${CONTAINER}" ] && \ (docker exec -it $$CONTAINER /bin/bash -c "npm install request --no-save && npm test") || \ diff --git a/lib/resources/messages.js b/lib/resources/messages.js index 2c1d0b3f..879ff388 100644 --- a/lib/resources/messages.js +++ b/lib/resources/messages.js @@ -51,6 +51,9 @@ export class MessageGetResponse { this.requesterIP = params.requesterIp; this.isDomestic = params.isDomestic; this.replacedSender = params.replacedSender; + this.dltEntityID = params.dltEntityId; + this.dltTemplateID = params.dltTemplateId; + this.dltTemplateCategory = params.dltTemplateCategory; } } @@ -76,6 +79,9 @@ export class MessageListResponse { this.requesterIP = params.requesterIp; this.isDomestic = params.isDomestic; this.replacedSender = params.replacedSender; + this.dltEntityID = params.dltEntityId; + this.dltTemplateID = params.dltTemplateId; + this.dltTemplateCategory = params.dltTemplateCategory; } } @@ -169,6 +175,9 @@ export class MessageInterface extends PlivoResourceInterface { * @param {list} [optionalParams.media_urls] For sending mms, specify the media urls in list of string * @param {int} [optionalParams.message_expiry] The method used to expiry the message specified time. * @param {boolean} [optionalParams.log] If set to false, the content of this message will not be logged on the Plivo infrastructure and the dst value will be masked (e.g., 141XXXXX528). Default is set to true. + * @param {string} [optionalParams.dltEntityID] This is the DLT entity id passed in the message request. + * @param {string} [optionalParams.dltTemplateID] This is the DLT template id passed in the message request. + * @param {string} [optionalParams.dltTemplateCategory] This is the DLT template category passed in the message request. * @promise {object} return {@link PlivoGenericMessage} object if success * @fail {Error} return Error */ @@ -189,6 +198,9 @@ export class MessageInterface extends PlivoResourceInterface { * @param {string} [optionalParams.method] The method used to call the url. Defaults to POST. * @param {boolean} [optionalParams.log] If set to false, the content of this message will not be logged on the Plivo infrastructure and the dst value will be masked (e.g., 141XXXXX528). Default is set to true. * @param {Array} [optionalParams.media_urls] For sending mms, specify the media urls in list of string + * @param {string} [optionalParams.dltEntityID] This is the DLT entity id passed in the message request. + * @param {string} [optionalParams.dltTemplateID] This is the DLT template id passed in the message request. + * @param {string} [optionalParams.dltTemplateCategory] This is the DLT template category passed in the message request. * @promise {object} return {@link PlivoGenericMessage} object if success * @fail {Error} return Error */ @@ -206,6 +218,9 @@ export class MessageInterface extends PlivoResourceInterface { var log = src.log; var trackable = src.trackable; var messageExpiry = src.messageExpiry; + var dlt_entity_id = src.dlt_entity_id; + var dlt_template_id = src.dlt_template_id; + var dlt_template_category = src.dlt_template_category; var src = src.src; } @@ -261,6 +276,15 @@ export class MessageInterface extends PlivoResourceInterface { if (messageExpiry){ params.message_expiry = messageExpiry; } + if (dlt_entity_id) { + params.dlt_entity_id = dlt_entity_id + } + if (dlt_template_id) { + params.dlt_template_id = dlt_template_id + } + if (dlt_template_category) { + params.dlt_template_category = dlt_template_category + } } if (src) { diff --git a/lib/rest/request-test.js b/lib/rest/request-test.js index eec1f959..b60a06cc 100644 --- a/lib/rest/request-test.js +++ b/lib/rest/request-test.js @@ -1953,7 +1953,10 @@ export function Request(config) { total_rate: '0.00350', units: 1, requester_ip: '192.168.1.2', - is_domestic: false + is_domestic: false, + dlt_entity_id: "9876", + dlt_template_id: "5432", + dlt_template_category: "transactional" } }); } @@ -1983,7 +1986,10 @@ export function Request(config) { total_rate: '0.00350', units: 1, requester_ip: "192.168.1.1", - is_domestic: false + is_domestic: false, + dlt_entity_id: "2233", + dlt_template_id: "4455", + dlt_template_category: "service_implicit" }, { error_code: '200', @@ -1999,7 +2005,10 @@ export function Request(config) { total_rate: '0.00350', units: 1, requester_ip: "192.168.1.2", - is_domestic: false + is_domestic: false, + dlt_entity_id: null, + dlt_template_id: null, + dlt_template_category: null } ] } diff --git a/test/messages.js b/test/messages.js index 52007a0c..586812a4 100644 --- a/test/messages.js +++ b/test/messages.js @@ -24,6 +24,15 @@ describe('message', function () { }) }); + it('should have dlt parameter in get message', function () { + return client.messages.get(1) + .then(function (message) { + assert.equal(message.dltEntityID, "9876"); + assert.equal(message.dltTemplateID, "5432"); + assert.equal(message.dltTemplateCategory, "transactional"); + }) + }); + it('list messages', function () { return client.messages.list() .then(function (messages) { @@ -39,6 +48,19 @@ describe('message', function () { }) }); + it('should have dlt parameters in first listed message only', function () { + return client.messages.list() + .then(function (messages) { + assert.equal(messages[0].dltEntityID, "2233") + assert.equal(messages[0].dltTemplateID, "4455") + assert.equal(messages[0].dltTemplateCategory, "service_implicit") + + assert.equal(messages[1].dltEntityID, null) + assert.equal(messages[1].dltTemplateID, null) + assert.equal(messages[1].dltTemplateCategory, null) + }) + }); + it('should create message via interface', function () { return client.messages.create({src:'src', dst:'dst', text:'text',powerpackUUID: null}) .then(function (message) { From f6b9c72dd0a8aef38d0173e7922e199e6521d906 Mon Sep 17 00:00:00 2001 From: mohsin-plivo Date: Tue, 11 Jul 2023 21:01:09 +0530 Subject: [PATCH 2/3] Fix method comments --- lib/resources/messages.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/resources/messages.js b/lib/resources/messages.js index 879ff388..2ced8547 100644 --- a/lib/resources/messages.js +++ b/lib/resources/messages.js @@ -175,9 +175,9 @@ export class MessageInterface extends PlivoResourceInterface { * @param {list} [optionalParams.media_urls] For sending mms, specify the media urls in list of string * @param {int} [optionalParams.message_expiry] The method used to expiry the message specified time. * @param {boolean} [optionalParams.log] If set to false, the content of this message will not be logged on the Plivo infrastructure and the dst value will be masked (e.g., 141XXXXX528). Default is set to true. - * @param {string} [optionalParams.dltEntityID] This is the DLT entity id passed in the message request. - * @param {string} [optionalParams.dltTemplateID] This is the DLT template id passed in the message request. - * @param {string} [optionalParams.dltTemplateCategory] This is the DLT template category passed in the message request. + * @param {string} [optionalParams.dlt_entity_id] This is the DLT entity id passed in the message request. + * @param {string} [optionalParams.dlt_template_id] This is the DLT template id passed in the message request. + * @param {string} [optionalParams.dlt_template_category] This is the DLT template category passed in the message request. * @promise {object} return {@link PlivoGenericMessage} object if success * @fail {Error} return Error */ @@ -198,9 +198,9 @@ export class MessageInterface extends PlivoResourceInterface { * @param {string} [optionalParams.method] The method used to call the url. Defaults to POST. * @param {boolean} [optionalParams.log] If set to false, the content of this message will not be logged on the Plivo infrastructure and the dst value will be masked (e.g., 141XXXXX528). Default is set to true. * @param {Array} [optionalParams.media_urls] For sending mms, specify the media urls in list of string - * @param {string} [optionalParams.dltEntityID] This is the DLT entity id passed in the message request. - * @param {string} [optionalParams.dltTemplateID] This is the DLT template id passed in the message request. - * @param {string} [optionalParams.dltTemplateCategory] This is the DLT template category passed in the message request. + * @param {string} [optionalParams.dlt_entity_id] This is the DLT entity id passed in the message request. + * @param {string} [optionalParams.dlt_template_id] This is the DLT template id passed in the message request. + * @param {string} [optionalParams.dlt_template_category] This is the DLT template category passed in the message request. * @promise {object} return {@link PlivoGenericMessage} object if success * @fail {Error} return Error */ From a690815a63fe7712dcad05e247fb4a80e713dcf3 Mon Sep 17 00:00:00 2001 From: mohsin-plivo Date: Thu, 3 Aug 2023 14:56:49 +0530 Subject: [PATCH 3/3] Version update --- CHANGELOG.md | 21 +++++++++++++-------- package.json | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fcfd1fd9..fab94ebd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,19 @@ # Change Log -## [4.52.0](https://github.com/plivo/plivo-python/tree/v4.52.0) (2023-07-31) +## [4.53.0](https://github.com/plivo/plivo-node/tree/v4.53.0) (2023-08-03) +**Feature - DLT parameters** +- Added new params `DLTEntityID`, `DLTTemplateID`, `DLTTemplateCategory` to the [send message API](https://www.plivo.com/docs/sms/api/message/send-a-message/) +- Added new params `DLTEntityID`, `DLTTemplateID`, `DLTTemplateCategory` to the response for the [list all messages API](https://www.plivo.com/docs/sms/api/message/list-all-messages/) and the [get message details API](https://www.plivo.com/docs/sms/api/message#retrieve-a-message) + +## [4.52.0](https://github.com/plivo/plivo-node/tree/v4.52.0) (2023-07-31) **Feature - Number Masking** - Added Create, Delete, Update, Get and List Masking Session API -## [v4.51.0](https://github.com/plivo/plivo-go/tree/v4.51.0) (2023-07-07) +## [v4.51.0](https://github.com/plivo/plivo-node/tree/v4.51.0) (2023-07-07) **Fix Intermediate GET request failure** - GET API request body removed -## [v4.50.0](https://github.com/plivo/plivo-go/tree/v4.50.0) (2023-06-28) +## [v4.50.0](https://github.com/plivo/plivo-node/tree/v4.50.0) (2023-06-28) **Feature - Audio Streaming** - `Audio Stream over Call` added API to start and stop streaming on a live call and get details of running or stopped streams. Also implemented the ability to generate stream XML. @@ -82,23 +87,23 @@ **Brand Usecase Request** - Brand Usecase Request endpoint added -## [v4.34.3](https://github.com/plivo/plivo-go/tree/v4.34.3) (2022-11-07) +## [v4.34.3](https://github.com/plivo/plivo-node/tree/v4.34.3) (2022-11-07) **Bug fix - List all Endpoint** - Removed duplicate responses -## [v4.34.2](https://github.com/plivo/plivo-go/tree/v4.34.2) (2022-10-17) +## [v4.34.2](https://github.com/plivo/plivo-node/tree/v4.34.2) (2022-10-17) **List Endpoint query param support** - Adding limit and offset to fetch list of endpoints. -## [v4.34.1](https://github.com/plivo/plivo-go/tree/v4.34.1) (2022-09-28) +## [v4.34.1](https://github.com/plivo/plivo-node/tree/v4.34.1) (2022-09-28) **10DLC campaign creation** - Adding more attributes to campaign creation request. -## [v4.34.0](https://github.com/plivo/plivo-go/tree/v4.34.0) (2022-08-07) +## [v4.34.0](https://github.com/plivo/plivo-node/tree/v4.34.0) (2022-08-07) **Feature - Token Creation** - `JWT Token Creation API` added API to create a new JWT token. -## [v4.33.0](https://github.com/plivo/plivo-go/tree/v4.33.0) (2022-07-11) +## [v4.33.0](https://github.com/plivo/plivo-node/tree/v4.33.0) (2022-07-11) **Feature - STIR Attestation** - Add stir attestation param as part of Get CDR and Get live call APIs Response diff --git a/package.json b/package.json index f2e5a8d3..7f2e3c12 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plivo", - "version": "4.52.0", + "version": "4.53.0", "description": "A Node.js SDK to make voice calls and send SMS using Plivo and to generate Plivo XML", "homepage": "https://github.com/plivo/plivo-node", "files": [