The plugin provides the access to the API functions of the Ukrainian service of SMS-sending Alphasms.ua
Add this line to your application's Gemfile:
gem 'alphasms', git: 'https://github.com/andrad/alphasms-api'
And then execute:
$ bundle
There's a generator that generates the default configuration file into config/initializers directory. Run the following generator command, then edit the generated file.
rails g alphasms:initializer
Options:
api_key
- your api keysender
- custom sendertype
- type of sms (default is :xml, 0 - usual message, 1 - flash message, 2 - wap-push message)
To check the balance, use .balance method
Alphasms.balance
if you want to use another api_key
Alphasms.balance({ api_key: 'some key' })
you cat also pass a block
Alphasms.balance({api_key: 'some key'}) { |b| "#{b.amount} #{b.currency}"} # => "123.98 UAH"
To send the sms, use .deliver method
Alphasms.deliver({ recipient: '380000000000', message: 'The message' })
you can also send several sms
Alphasms.deliver([{ recipient: '380000000000', message: 'The message' }, { recipient: '380000000001', message: 'Some text' }])
and you can use custom options
Alphasms.deliver({ recipient: '380000000000', message: 'The message' }, { api_key: 'some key', sender: 'sender', type: 0 })
To check status of sms, use .status method
Alphasms.status('id_sms')
or
Alphasms.status(['id_sms', 'id_sms'])
0.0.2 - Gem started
is licensed under the MIT license.
Copyright (C) 2015 by andrad (Andrey Radzun)