Promotexter
A Ruby gem for consuming the Promotexter API for sending mesages
Requirements
Ruby 2.x.x
Installation
$ gem install promotexter
Or add it to your Gemfile
:
gem promotexter
Then generate initializer:
$ rails g promotexter:install initializer
then edit the file in config/initializer/promotexter.rb
and supply the necessary details.
Usage
Construct a Promotexter::Client object and use the #send_message method to
send a message. For example:
require 'promotexter'
client = Promotexter::Client.new
client.send_message(text: 'This is a test', to: '639171234567')
Promotexter::Client.send_message(text: 'This is a test', to: '639171234567')
client = Promotexter::Client.new(api_key:'key', api_secret:'secret', sender_id:'xxxxxx')
client.send_message(text: 'This is a test', to:'639171234567')
client = Promotexter::Client.new
client.send_message(text: 'Override sender_id on demand', to: '639171234567', sender_id: 'Sample')
If you want to use the delivery reports, head over to your initializer and uncomment the dlr_callback & dlr_reports lines
Reports
require 'promotexter'
Promotexter::Report.balance
reports = Promotexter::Report.new
reports.sms_transactions
Available filters:
Params | Required | Description |
---|
after | No | Filter transactions with creation date greater than this value. |
before | No | Filter transactions with creation date less than this value. |
transaction_id | No | Specific transactionId lookup |
reference_id | No | Specific referenceId lookup |
category_id | No | Specific categoryId lookup |
request_id | No | Specific requestId lookup |
from | No | Filter transactions with creation date greater than or equal to this value. |
to | No | Filter transactions with creation date less than or equal to this value. |
example:
reports = Promotexter::Report.new
reports.sms_transactions(from: '2018-10-03T14:44:23.186Z', to: '2018-11-03T14:44:23.186Z')
Promotexter::Report.sms_transactions(from: '2018-10-03T14:44:23.186Z', to: '2018-11-03T14:44:23.186Z')
Production environment variables
Best practice for storing credentials for external services in production is
to use environment variables, as described by 12factor.net/config.
Promotexter::Client defaults to extracting the client_id, secret_key and shortcode it needs from the
PROMOTEXTER_API_KEY, PROMOTEXTER_API_SECRET and PROMOTEXTER_SENDER_ID environment variables if the
options were not specified explicitly.
Contributing
- Fork it
- Create your feature branch (
git checkout -b new-feature
) - Commit your changes (
git commit -am 'Added awesome new features'
) - Push to the branch (
git push origin new-feature
) - Create new Pull Request
MIT Open Source License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Acknowledgement
Originally created by Nujian Den Mark Meralpis. Updated by Scrambled Eggs Software Inc.
Thanks to all awesome contributors. Cheers!
2016-2018