From 68279cb03f9e1b0a78ec993b5b346c5d161b9728 Mon Sep 17 00:00:00 2001 From: Douglas Mwangi Date: Mon, 25 Nov 2024 03:09:57 +0300 Subject: [PATCH 1/2] YODA-T-67 Rename "from" to "senderId" in bulk ``send()`` (method + test+readme) --- README.md | 6 +++--- lib/sms.js | 13 +++++++++++-- test/sms.js | 10 +++++----- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 911f6eef..17073689 100644 --- a/README.md +++ b/README.md @@ -81,12 +81,12 @@ All phone numbers use the international format. e.g. `+234xxxxxxxx`. ### `SMS` -- `send({ to, from, message, enqueue })`: Send an SMS to one or more phone numbers +- `send({ to, senderId, message, enqueue })`: Send an SMS to one or more phone numbers -- `send([{ to, from, message, enqueue }])`: Send multiple SMSes to one or more phone numbers +- `send([{ to, senderId, message, enqueue }])`: Send multiple SMSes to one or more phone numbers - `to`: Recipient(s) phone number. Can either a single phone number or an array of phone numbers `REQUIRED` - - `from`: Shortcode or alphanumeric ID that is registered with Africa's Talking account + - `senderId`: Shortcode or alphanumeric ID that is registered with Africa's Talking account - `message`: SMS content. `REQUIRED` - `enqueue`: Set to true if you would like to deliver as many messages to the API without waiting for an acknowledgement from telcos. diff --git a/lib/sms.js b/lib/sms.js index b8cd78a7..5fe80645 100644 --- a/lib/sms.js +++ b/lib/sms.js @@ -58,6 +58,9 @@ class SMS { from: { isString: true }, + senderId: { + isString: true + }, message: { presence: true } @@ -105,9 +108,15 @@ class SMS { to: params.to, message: params.message } - if (params.from) { - body.from = params.from + /** + * TO DO -> once the sandbox for new bulk SMS is live: + * - Remove "from" entirely + * - Change the endpoint to the new bulk SMS endpoint + */ + if (params.from || params.senderId) { + body.from = params.from || params.senderId } + if (isBulk) { body.bulkSMSMode = 1 if (params.enqueue) { diff --git a/test/sms.js b/test/sms.js index 2ecbff04..a564f6dc 100644 --- a/test/sms.js +++ b/test/sms.js @@ -31,9 +31,9 @@ describe('SMS', function () { return sms.send(options).should.be.rejected() }) - it('#send() must have to/from/message params', function () { + it('#send() must have to/senderId/message params', function () { options.to = fixtures.phoneNumber - options.from = null + options.senderId = null options.message = null return sms.send(options).should.be.rejected() @@ -172,18 +172,18 @@ describe('SMS', function () { { to: fixtures.phoneNumber, enqueue: true, - from: '34587', + senderId: '34587', message: 'This is mulitple recipients test' }, { to: [fixtures.phoneNumber], enqueue: true, - from: '34587', + senderId: '34587', message: 'Send message to multiple recipients' }, { to: fixtures.phoneNumber, - from: 1458, + senderId: 1458, enqueue: true, message: 'returns object with a message of not sent' } From a1ff49c3bda6a61bc98305a5c06d4bfb6d48607b Mon Sep 17 00:00:00 2001 From: Douglas Mwangi Date: Mon, 25 Nov 2024 19:06:32 +0300 Subject: [PATCH 2/2] Bump version to v0.7.1 in package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b0702e50..56913bf1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "africastalking", - "version": "0.7.0", + "version": "0.7.1", "description": "Official AfricasTalking node.js API wrapper", "main": "index.js", "scripts": {