Class: CleverElements::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/clever_elements/client.rb

Constant Summary collapse

API_VERSION =
"1.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_id, api_key, mode = 'test') ⇒ Client

Returns a new instance of Client.



7
8
9
10
# File 'lib/clever_elements/client.rb', line 7

def initialize user_id, api_key, mode = 'test'
  @savon = Savon::Client.new "http://api.sendcockpit.com/server.php?wsdl"
  @user_id, @api_key, @mode = user_id, api_key, mode
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



5
6
7
# File 'lib/clever_elements/client.rb', line 5

def api_key
  @api_key
end

#modeObject (readonly)

Returns the value of attribute mode.



5
6
7
# File 'lib/clever_elements/client.rb', line 5

def mode
  @mode
end

#savonObject (readonly)

Returns the value of attribute savon.



5
6
7
# File 'lib/clever_elements/client.rb', line 5

def savon
  @savon
end

#user_idObject (readonly)

Returns the value of attribute user_id.



5
6
7
# File 'lib/clever_elements/client.rb', line 5

def user_id
  @user_id
end

Instance Method Details

#authentication_headerObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/clever_elements/client.rb', line 19

def authentication_header
  {
    :validate => {
      :userid => user_id,
      :apikey => api_key,
      :version => API_VERSION,
      :mode => mode
    }
  }
end

#proxyObject



30
31
32
# File 'lib/clever_elements/client.rb', line 30

def proxy
  @proxy ||= Proxy.new self
end

#request(method, arguments = {}) ⇒ Object



12
13
14
15
16
17
# File 'lib/clever_elements/client.rb', line 12

def request method, arguments = {}
  savon.request method do
    soap.body = arguments
    soap.header = authentication_header
  end
end