Module: Connect::WebService::Request

Included in:
Rest
Defined in:
lib/connect/web_service/request.rb

Instance Method Summary collapse

Instance Method Details

#call(client, options) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/connect/web_service/request.rb', line 6

def call(client, options)
  request_params = []
  request_params = options[:params] if options[:params]
  method = options[:method]
  method_as_s = method.to_s
  camel_case_method_name = method_as_s.to_s.gsub(/(?:_|\b)([a-z])/) { $1.upcase }
  xml_body = build_params(camel_case_method_name, request_params)
  xml = xml_template(xml_body)
  response = client.connection.call(method, xml: xml)
  body = response.body
  body_key = "#{method_as_s}_response".to_sym
  response_data = []
  if (property = body.dig(body_key, :return, :property)) && property.size > 1 && property[1][:value][:row]
    response_data = property[1][:value][:row]
  end
  response_data
end