Simple Ruby wrapper for the SMSlist API. SMSlist is a service for mass sending sms messages.
gem install smslist
You can configure this gem in an initializer:
Smslist.configure do |c|
c.sender = '79101234567'
# you can use the token
c.token = 'your_api_token'
# or authenticate with login and password
c.login = 'username'
c.password = 'secret'
end
Or simply:
client = Smslist.new(sender: '79101234567', token: 'your_api_token')
balance = client.balance
remaining = client.remaining_sms
recipients = %w(79031234567 79032345678 79033456789)
response = client.send_sms('Your text message', recipients)
If can pass optional param, to send a flash sms message:
response = client.send_sms('Your text message', recipients, flash: true)
You will get a hash for each number, with status, message id (to retrieve status later) and number of parts:
{
'79031234567' => { status: :ok, id: 1001, parts: 2 },
...
'79033456789' => { error: 'Номер телефона присутствует в стоп-листе.' }
}
Status :ok means, that the message was successfully placed in a queue.
message_ids = %w(1001 1002 1003 1004)
response = client.state(message_ids)
You will get a hash for id, with state and datetime, or error message.
This library aims to support and is tested against the following Ruby implementations:
- Ruby 1.9.2
- Ruby 1.9.3
- Ruby 2.0.0
If something doesn't work on one of these Ruby versions, it's a bug.
This library may inadvertently work (or seem to work) on other Ruby implementations, however support will only be provided for the versions listed above.
Smslist was inspired by Octokit.
Copyright (c) 2013 Yury Lebedev. See LICENSE for details.