Sending and receiving SMSs with Ruby through pluggable backends.
Supported Ruby versions: 2.0.0 or higher
Licensed under the MIT license, see LICENSE for more information.
Add this line to your application's Gemfile:
gem 'cellular'
And then execute:
$ bundle
Or install it yourself as:
$ gem install cellular
Cellular.configure do |config|
config.username = 'username'
config.password = 'password'
config.backend = Cellular::Backends::Sendega
config.sender = 'Default custom sender'
config.country_code = 'NO'
end
The options supported may differ between backends.
sms = Cellular::SMS.new(
recipient: '47xxxxxxxx',
sender: 'Custom sender',
message: 'This is an SMS message',
price: 0,
country_code: 'NO' # defaults to Cellular.config.country_code
)
sms.deliver
For use with multiple recipients in one request use:
sms = Cellular::SMS.new(
recipients: ['47xxxxxxx1','47xxxxxxx2','47xxxxxxx3'],
sender: 'Custom sender',
message: 'This is an SMS message',
price: 0,
country_code: 'NO' # defaults to Cellular.config.country_code
)
sms.deliver
You can also use Sidekiq to send texts, which is great if you're in a Rails app
and are concerned that it might time out or something. Actually, if you have
Sidekiq at your disposal, it's a great idea anyway! To use it, just call
deliver_later
instead of deliver
on the SMS object:
sms = Cellular::SMS.new(
recipient: '47xxxxxxxx',
sender: 'Custom sender',
message: 'This is an SMS message'
)
sms.deliver_later
This will create a Sidekiq job for you on the cellular queue, so make sure that Sidekiq is processing that queue.
Using Sidekiq, Cellular allows you to schedule the time when an SMS will be sent.
Just call deliver_at(timestamp)
on the SMS object:
sms = Cellular::SMS.new(
recipient: '47xxxxxxxx',
sender: 'Custom sender',
message: 'This is an SMS message'
)
sms.deliver_at 3.hours.from_now
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create pull request
Hyper made this. We're a digital communications agency with a passion for good code, and if you're using this library we probably want to hire you.