Class: OAS::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Client

Returns a new instance of Client.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/oas/client.rb', line 8

def initialize(opts={})
  options = OAS.options.merge(opts)
  Configuration::VALID_OPTIONS_KEYS.each do |key|
    send("#{key}=", options[key])
  end

  @savon = Savon::Client.new do |client|
    client.endpoint endpoint.to_s
    client.namespace "http://api.oas.tfsm.com/"
    client.namespace_identifier :n1
    client.convert_request_keys_to :camelcase
    client.open_timeout timeout.to_i
    client.read_timeout timeout.to_i
    client.ssl_verify_mode :none
    client.logger logger
    client.log !!logger
  end
end

Instance Method Details

#execute(request) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/oas/client.rb', line 27

def execute(request)
  response = @savon.call :oas_xml_request, message: Hash["String_1", .to_s, "String_2", username.to_s, "String_3", password.to_s, "String_4", request.to_xml.to_s]
  OAS::AdXML.parse response.body[:oas_xml_request_response][:result]
rescue Savon::HTTPError => e
  _raise_http_error!(e)
rescue Savon::InvalidResponseError => e
  raise OAS::Error.new(e.message)
end