diff --git a/.travis.yml b/.travis.yml index f2f99b1..91d3ffe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,5 +22,5 @@ after_success: - if [[ "$TRAVIS_JOB_NUMBER" == *.1 && "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" ]]; then bash <(curl -s https://codecov.io/bash); fi - if [[ "$TRAVIS_JOB_NUMBER" == *.1 && "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" ]]; then npm run semantic-release; fi branches: - only: - - prod + except: + - /^v\d+\.\d+\.\d+$/ diff --git a/README.md b/README.md index 7cfe865..9bf3919 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,70 @@ [![npm](https://img.shields.io/npm/dt/graphql-compose-json.svg)](http://www.npmtrends.com/graphql-compose-json) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) [![Greenkeeper badge](https://badges.greenkeeper.io/graphql-compose/graphql-compose-json.svg)](https://greenkeeper.io/) -[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) ---> +[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) --> -This is a wrapper for AWS.SNS and SMSC API + +This is a wrapper for [AWS.SNS](https://aws.amazon.com/sns/) and [SMSC API](https://smsc.ru). + +## Installation + + +```bash +yarn add 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 example for using this wrapper with RegExp: + +```js +// @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](https://github.com/FrankAst/sms-sender/tree/master/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](https://github.com/FrankAst/sms-sender/blob/master/LICENSE.md) diff --git a/package.json b/package.json index de70f48..60d4bd9 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,7 @@ "scripts": { "demo-db": "./node_modules/.bin/babel-node ./examples/with_db/index.js", "demo-regexp": "./node_modules/.bin/babel-node ./examples/by_regexp/index.js", + "demo-retry-another": "./node_modules/.bin/babel-node ./examples/retry_another/index.js", "build": "npm run build-cjs && npm run build-flow", "build-cjs": "rimraf lib && babel src --ignore __tests__,__mocks__,__fixtures__ -d lib", "build-flow": "find ./src -name '*.js' -not -path '*/__*' | while read filepath; do cp $filepath `echo $filepath | sed 's/\\/src\\//\\/lib\\//g'`.flow; done",