1.0.0 • Published 4 years ago

@smsglobaldev/smsglobal v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

Example

Check out the code examples

Smsglobal rest api credentials

Rest api credentials can be provided in the SMSGlobal client or node environment variables. The credential variables are SMSGLOBAL_API_KEY and SMSGLOBAL_API_SECRET

Installation

npm install --save smsglobal

Usage

  • Require smsglobal in your file
const apiKey = 'YOUR_API_KEY';
const apiSecret = 'YOUR_API_SECRET';
var smsglobal = require('smsglobal')(apiKey, secret);

To send a sms

var payload = {
    origin: 'from number',
    destination: 'destination',
    message: 'This is a test message'
}

smsglobal.sms.send(payload, function (error, response) {
    console.log(response);
});

To fetch a list outgoing sms

var promise = smsglobal.sms.getAll();

promise
    .then(function(response) {
        console.log(response)
    })
    .catch(function(error){
        console.log(error)
    });

To fetch an outgoing sms by id

var id = 'outgoing-sms-id';
var promise = smsglobal.sms.get(id);

promise
    .then(function(response) {
        console.log(response)
    })
    .catch(function(error){
        console.log(error)
    });

To fetch a list incoming sms

var promise = smsglobal.sms.incoming.getAll();

promise
    .then(function(response) {
        console.log(response)
    })
    .catch(function(error){
        console.log(error)
    });

To fetch an incoming sms by id

var id = 'incoming-sms-id';
var promise = smsglobal.sms.incoming.get(id);

promise
    .then(function(response) {
        console.log(response)
    })
    .catch(function(error){
        console.log(error)
    });

All method returns promise if no callback is given

Running tests

Run the tests:

npm test

To run test with code coverage report

npm run mocha-only

Following endpoints are covered

  • sms
  • sms-incoming

Reference

Rest api documentation

1.0.0

4 years ago