spryng-sms

1.2.0 • Public • Published

Node.js client for the Spryng SMS Gateway API

npm install --save spryng-sms

Usage

This sample shows how to initiate the client and send a text message:

// ES5
const SmsApiClient = require('spryng-sms').SmsApiClient;

// ES6
import { SmsApiClient } from 'spryng-sms';

const client = new SmsApiClient({
  username: 'my-account',
  password: 'my-password'
});

const request = {
  allowLong: true,
  destination: '32123456789',
  route: 'BUSINESS', // or ECONOMY
  body: 'Hi there, this is a message.',
  sender: '0032111111111',
  reference: '1234567890'
};

client.send(request)
  .then(() => {
    console.log('SMS message has been sent.');
  })
  .catch(err => {
    console.log('Error sending SMS:', err);
  });

Sending to multiple destinations

You can also specify multiple destinations:

const request = {
  allowLong: true,
  destination: [ '32123456789', '32987654321' ],
  route: 'BUSINESS', // or ECONOMY
  body: 'Hi there, this is a message.',
  sender: '0032111111111',
  reference: '1234567890'
};

client.send(request)
  .then(() => {
    console.log('SMS message has been sent.');
  })
  .catch(err => {
    console.log('Error sending SMS:', err);
  });

Checking your credit

client.getRemainingCredit()
  .then((credit) => {
    console.log('Remaining credit:', credit);
  })
  .catch(err => {
    console.log(err);
  });

Dependents (0)

Package Sidebar

Install

npm i spryng-sms

Weekly Downloads

1

Version

1.2.0

License

MIT

Unpacked Size

18.6 kB

Total Files

10

Last publish

Collaborators

  • sandrinodimattia