Class: Simplesol::Client

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Methods included from Configuration

#configure, #configured?, #options, #reset

Constructor Details

#initializeClient

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

#connectionObject (readonly)

Returns the value of attribute connection.



9
10
11
# File 'lib/simplesol/client.rb', line 9

def connection
  @connection
end

Instance Method Details

#balanceObject



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 message_price(recipients, message)
  call('message/price', { :recipients => recipients.join(','), :message => 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 message_status(messages_id)
  call('message/status', { :messages_id => 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 send_message(recipients, message, options = {})
  call('message/send', { :recipients => recipients.join(','), :message => message }.merge(options))
end