0.0.2 • Published 7 years ago

ebulksms v0.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

ebulksms

Node module for use with https://ebulksms.com

Installation

npm i -S ebulksms

Usage

var ebulksms = require('ebulksms')(EBULKSMS_USERNAME, EBULKSMS_APIKEY, { senderId: SENDER_ID /* Optional. Default 'EbulkSMS' */ } );

Send SMS

ebulksms.send('2348118......', 'This is a test message', 'my_generated_unique_id', {
  flash: false, // (Optional) Default false
  senderId: 'kb' // (Optional) This will override SENDER_ID if set
})
  .then(function(response) {
    // Was successful
    console.log(response);
    /*
    Sample response
    {
      "response": {
        "status": "STATUS_STRING",
        "totalsent": "<number of recipients>",
        "cost": "<units charged>"
      }
    }
    */
  })
  .catch(function(error) {
    // Something happened
    console.log(error);
    /*
    {
      "response": {
        "status": "STATUS_STRING",
        "totalsent": "0",
        "cost": "0"
      }
    }
    */
  })

The first parameter can also be an array of objects in the form [{ recipient: '2348181......', messageId: '101292'}, ...]. Here messageId is optional as well and will be autogenerated if not provided

Check Balance

ebulksms.balance()
  .then(function(res) {
    console.log(res);
    // { balance: 1.0 }
  })

ebulksms.report(messageId /* Optional */)
  .then(function(res) {
    console.log(res)
  })
  .catch(function(error) {
    console.log(error)
  })