Giter VIP home page Giter VIP logo

sms-sender's Introduction

sms-sender ✉️ 🚀

travis build codecov coverage npm Commitizen friendly Greenkeeper badge semantic-release

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

Installation

yarn add @frankast/sms-sender

API

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

Sending SMS

To send an SMS you have to create an instance of provider and call sendSms() method:

import { Smsc } from '@frankast/sms-sender';

const smsc = new Smsc({
  login: YOUR_SMSC_LOGIN,
  password: YOUR_SMSC_PASSSWORD,
});

// You can use Promises as well.
const response = await smsc.sendSms('phone_number', 'message');

// The response object will contain `messageId` and `rawResponse`:
// response = { messageId: 'id-phone_number', rawResponse: { cnt: 1, id: 50 }}

Get delivery status of SMS

To check the delivery status of SMS call getStatus() method:

const response = await smsc.getStatus('40-77718637484'); // takes messageId (id-phone_number)

// The response object will contain 'rawResponse' with general info and 'status':
// response = {
//   rawResponse: {
//     cost: '0.00',
//     country: 'Казахстан',
//     last_date: '13.03.2018 15:50:50',
//     last_timestamp: 1520934650,
//     message: 'hello',
//     operator: 'Beeline',
//     phone: '77718637484',
//     region: '',
//     send_date: '13.03.2018 15:50:46',
//     send_timestamp: 1520934646,
//     sender_id: 'SMS-CENTRE',
//     status: 1,
//     status_name: 'Доставлено',
//     type: 0,
//   },
//   status: 'ok',
// }

P.S. You can get status codes here or in SMSC docs.

Get cost of SMS

To get a cost of SMS call getCost() method:

const response = await smsc.getCost('phone_number','message');

// The response object will contain 'rawResponse' and 'cost':
// response = { cost: '0', rawResponse: { cnt: 1, cost: '25' } };

getCost() is not available for Mobizon provider.

Get current balance

To get the current balance on your account call getBalance() method:

  const response = await smsc.getBalance();

// The response object will contain 'balance' and 'currency':
// response = { balance: '84.75', currency: 'KZT' };

Examples

Here is an example of usage with RegExp:

// @flow

import { Smsc, Sns, Mobizon } from '@frankast/sms-sender';

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

  sns: new Sns({
    region: '',
    accessKeyId: '',
    secretAccessKey: '',
  }),
  
  mobizon: new Mobizon({
    apiKey: '',
  }),
};

async function send(phone: string, message: string): Promise<Object> {
  const regexp = RegExp('7708', 'g');
  let provider;
  if (regexp.test(phone)) {
    provider = providers.smsc;
  } else {
    provider = providers.sns;
  }
  const res = await provider.sendSms(phone, message);
  return res;
}

send('+77081113344', 'hello world').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

sms-sender's People

Contributors

artistyle avatar borodayev avatar damix96 avatar greenkeeper[bot] avatar nodkz avatar yozhikm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sms-sender's Issues

An in-range update of aws-sdk is breaking the build 🚨

The optionalDependency aws-sdk was updated from 2.320.0 to 2.321.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

aws-sdk is a optionalDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for Release v2.321.0

See changelog for more information.

Commits

The new version differs by 1 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of semantic-release is breaking the build 🚨

The devDependency semantic-release was updated from 15.13.11 to 15.13.12.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

semantic-release is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for v15.13.12

15.13.12 (2019-04-15)

Bug Fixes

  • package: update resolve-from to version 5.0.0 (6f3c21a)
Commits

The new version differs by 1 commits.

  • 6f3c21a fix(package): update resolve-from to version 5.0.0

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two-Factor Authentication, make configure the auth-only level is supported. semantic-release cannot publish with the default auth-and-writes level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot 📦🚀

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


The push permission to the Git repository is required.

semantic-release cannot push the version tag to the branch master on remote Git repository.

Please refer to the authentication configuration documentation to configure the Git credentials on your CI environment.


Good luck with your project ✨

Your semantic-release bot 📦🚀

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of mongoose is breaking the build 🚨

The dependency mongoose was updated from 5.4.13 to 5.4.14.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

mongoose is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 18 commits.

  • 35b90d2 chore: release 5.4.14
  • 8dc47a5 docs(schema): add examples for remaining functions
  • 764735b fix(documentarray): report validation errors that occur in an array subdoc created using create() and then set()
  • 3fec456 test(documentarray): repro #7504
  • 660fe60 chore: remove unnecessary print statements
  • 13c7a00 docs(schema): add examples to schema functions
  • 270732e docs(migrating_to_5): link to migrating to 5 docs on the mongoosejs.com website
  • db79cfc Merge branch 'master' of github.com:Automattic/mongoose
  • 67754bd style: fix lint
  • 8e30004 Merge pull request #7530 from sarpik/master
  • 3e44bc2 Merge branch 'master' of github.com:Automattic/mongoose
  • aa43200 docs: add MongooseError to API docs and add list of error names
  • 0daf626 Merge pull request #7521 from nocksapp/master
  • 8752502 fix anchor tag
  • b5f1723 chore: now working on 5.4.14

There are 18 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of nodemon is breaking the build 🚨

The devDependency nodemon was updated from 1.18.5 to 1.18.6.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

nodemon is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for v1.18.6

1.18.6 (2018-11-05)

Bug Fixes

Commits

The new version differs by 1 commits.

  • 521eb1e fix: restart on change for non-default signals (#1409) (#1430)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.