Class: DpdApi::Client::Response

Inherits:
Object
  • Object
show all
Includes:
Observable
Defined in:
lib/dpd_api/client/response.rb

Defined Under Namespace

Classes: ResourceBuilder

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Response

Returns a new instance of Response.



9
10
11
12
# File 'lib/dpd_api/client/response.rb', line 9

def initialize(url)
  @url    = url
  @client = Savon.client(wsdl: @url)
end

Instance Method Details

#response(method, params = {}, options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/dpd_api/client/response.rb', line 14

def response(method, params = {}, options = {})
  changed
  builder = ResourceBuilder.new(@client, method, params, options)
  result = begin
    builder.resources
  rescue Savon::SOAPFault => error
    { errors: error.to_s }
  end
  notify_observers(@url, builder.request_params, builder.response_body, result)
  result
end