This is a wrapper for AWS.SNS and SMSC API.
yarn add @frankast/sms-sender
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.
Feel free to submit pull request to us. Also, be sure all tests has passed otherwise pull request won't be accepted.