0.1.4 • Published 10 years ago

submail-sms v0.1.4

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

submail-sms

npm version npm downloads Build Status js-standard-style

Wrapper for Submail SMS-sending REST APIs.

Install

$ npm install submail-sms --save

How to use

var SMS = require('submail-sms')
var sms = new SMS('your_key', 'your_secret')

// call set methods separately or chain them together
sms.setProject('y6t7uO').addRecipient('18513993882', {var1: 'foo'})
sms.addRecipient('15831998328', {var1: 'bar'})

sms.getProject() // -> 'y6t7uO'
sms.getRecipients() // -> [ {to: '18513993882', vars: {var1: 'foo'}}, {to: '15831998328', vars: {var1: 'bar'}} ]

// the promise way
sms.send()
  .then(function (res) {
    /**
     * do something with the response here
     * see section below for response details
     */
  })
  .catch(function (err) {
    /* handle errors (more like exceptions) */
  })

// or with a callback
sms.send(function (err, res) {
  if (err) {
    /* handle errors */
    return
  }

  /* do something with response */
})

Sample response

The success response from Submail is an array of mixed successes and failures. An example:

[ { status: 'success',
    to: '18513993882',
    send_id: 'aba33c824223587ed47988ebfe49b07d',
    fee: 1,
    sms_credits: '33' },
  { status: 'error',
    to: '00000000000',
    code: 252,
    msg: 'Incorrect recipient message address' } ]

Test

$ npm test
0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago