Class: Simplesol::Client
- Inherits:
-
Object
- Object
- Simplesol::Client
- Includes:
- Configuration
- Defined in:
- lib/simplesol/client.rb
Constant Summary
Constants included from Configuration
Simplesol::Configuration::DEFAULT_API_KEY, Simplesol::Configuration::DEFAULT_API_SERVER, Simplesol::Configuration::DEFAULT_DEBUG, Simplesol::Configuration::DEFAULT_LOGIN, Simplesol::Configuration::VALID_OPTIONS_KEYS
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #balance ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
-
#message_price(recipients, message) ⇒ Object
param:recipients is array of mobile phones strings param:message is text of sms message.
-
#message_status(messages_id) ⇒ Object
param:messages_id array of messages ids.
-
#send_message(recipients, message, options = {}) ⇒ Object
param:recipients is array of mobile phones strings param:message is text of sms message options: => ‘Sender’, :test => 0, :test can be 0, 1.
Methods included from Configuration
#configure, #configured?, #options, #reset
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/simplesol/client.rb', line 11 def initialize reset configure { yield(self) } if block_given? @connection = Faraday::Connection.new(:url => api_server) do |c| c.request :url_encoded c.response :rashify c.response :dates c.response :json c.adapter Faraday.default_adapter end end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
9 10 11 |
# File 'lib/simplesol/client.rb', line 9 def connection @connection end |
Instance Method Details
#balance ⇒ Object
25 26 27 |
# File 'lib/simplesol/client.rb', line 25 def balance call('user/balance') end |
#message_price(recipients, message) ⇒ Object
param:recipients is array of mobile phones strings param:message is text of sms message
45 46 47 |
# File 'lib/simplesol/client.rb', line 45 def (recipients, ) call('message/price', { :recipients => recipients.join(','), :message => }) end |
#message_status(messages_id) ⇒ Object
param:messages_id array of messages ids
39 40 41 |
# File 'lib/simplesol/client.rb', line 39 def () call('message/status', { :messages_id => .join(',') }) end |
#send_message(recipients, message, options = {}) ⇒ Object
param:recipients is array of mobile phones strings param:message is text of sms message options: => ‘Sender’, :test => 0, :test can be 0, 1
34 35 36 |
# File 'lib/simplesol/client.rb', line 34 def (recipients, , = {}) call('message/send', { :recipients => recipients.join(','), :message => }.merge()) end |