Class: Economic::SoapAPI

Inherits:
Object
  • Object
show all
Defined in:
lib/economic/soap_api.rb

Constant Summary collapse

URL =
"https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?WSDL".freeze

Class Method Summary collapse

Class Method Details

.auth_cookiesObject



12
13
14
# File 'lib/economic/soap_api.rb', line 12

def auth_cookies
  @auth_cookies ||= client.call(:connect_with_token, message: {token: Economic::Session.agreement_grant_token, appToken: Economic::Session.app_secret_token}).http.cookies
end

.call(method, message: {}) ⇒ Object



6
7
8
9
10
# File 'lib/economic/soap_api.rb', line 6

def call(method, message: {})
  response = client.call(method, message: message, cookies: auth_cookies)

  response.body["#{method}_response".to_sym]["#{method}_result".to_sym]
end

.clientObject



16
17
18
19
20
21
# File 'lib/economic/soap_api.rb', line 16

def client
  @client ||= Savon.client {
    wsdl(URL)
    convert_request_keys_to :none # or one of [:lower_camelcase, :upcase, :none]
  }
end