1.2.0 • Published 2 years ago

spryng-sms v1.2.0

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

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);
  });
1.2.0

2 years ago

1.1.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago