Class: SimpleShipping::Abstract::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_shipping/abstract/response.rb

Overview

Represents a response returned by the remote service for a request initiated by client.

An abstract class which provides a common interface. In the real world, you will deal with its subclasses:

Example:

response = client.request(shipper, recipient, package)
response.response # => #<Savon::SOAP::Response ...>

Direct Known Subclasses

Fedex::Response, Ups::Response

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(savon_resp = nil) ⇒ Response

Returns a new instance of Response.



16
17
18
# File 'lib/simple_shipping/abstract/response.rb', line 16

def initialize(savon_resp = nil)
  @response = savon_resp
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



14
15
16
# File 'lib/simple_shipping/abstract/response.rb', line 14

def response
  @response
end

Instance Method Details

#value_of(*path) ⇒ Object

Fetch the value of an XML attribute at the path specified as an array. of node names



22
23
24
# File 'lib/simple_shipping/abstract/response.rb', line 22

def value_of(*path)
  @response.to_array(*path).first
end