Skip to content

This is a wrapper for AWS.SNS, SMSC API, Mobizon API

License

Notifications You must be signed in to change notification settings

borodayev/sms-sender

Repository files navigation

sms-sender

travis build codecov coverage

Commitizen friendly

semantic-release

This is a wrapper for AWS.SNS and SMSC API.

Installation

yarn add @frankast/sms-sender

Example

There are two providers Smsc.js (default) and Sns.js. If you want to use Sns.js do not forget to add aws-sdk optional dependency.

Here is an example for using this wrapper with RegExp:

// @flow

import Smsc from '../../src/transporters/Smsc';
import Sns from '../../src/transporters/Sns';

// don't forget to put your credentials
const providers = {
  smsc: new Smsc({
    login: '',
    password: '',
  }),

// put here or in ~/.aws/credentials
  sns: new Sns({
    region: '',
    accessKeyId: '',
    secretAccessKey: '',
  }),
};

function getProvider(providerName: string, defaultName?: string = 'smsc'): any {
  const regexp = RegExp(providerName, 'g');
  let provider;
  Object.keys(providers).forEach(name => {
    if (regexp.test(name)) {
      provider = providers[name];
    } else {
      provider = providers[defaultName];
    }
  });

  return provider;
}

const provider = getProvider('sm');

provider.sendSms('77718637484', 'test').then(res => console.log(res));

Other examples are available in ./examples.

Contribution

Feel free to submit pull request to us. Also, be sure all tests has passed otherwise pull request won't be accepted.

License

MIT