Skip to content

Commit

Permalink
Merge pull request #131 from AfricasTalkingLtd/develop
Browse files Browse the repository at this point in the history
Publish v0.7.1 on NPM
  • Loading branch information
DaggieBlanqx authored Nov 25, 2024
2 parents 8e67b47 + a1ff49c commit bc43134
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
13 changes: 11 additions & 2 deletions lib/sms.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class SMS {
from: {
isString: true
},
senderId: {
isString: true
},
message: {
presence: true
}
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
10 changes: 5 additions & 5 deletions test/sms.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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'
}
Expand Down

0 comments on commit bc43134

Please sign in to comment.