Sha256: 1e6c7066dbe77b4c53afd2979a1d29e9b3fd1f7b9782add86f817419fdcdc81d

Contents?: true

Size: 795 Bytes

Versions: 2

Compression:

Stored size: 795 Bytes

Contents

module SimpleShipping
  # Represents a response returned by the remote service for a request initiated
  # by {SimpleShipping::Abstract::Client client}.
  #
  # An abstract class which provides a common interface.
  # In the real world, you will deal with its subclasses:
  # * {SimpleShipping::Fedex::Response}
  # * {SimpleShipping::Ups::Response}
  #
  # == Example:
  #   response = client.request(shipper, recipient, package)
  #   response.response # => #<Savon::SOAP::Response ...>
  class Abstract::Response
    attr_reader :response

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

    # Fetch the value of an XML attribute at the path specified as an array.
    # of node names
    def value_of(*path)
      @response.to_array(*path).first
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simple_shipping-0.4.7 lib/simple_shipping/abstract/response.rb
simple_shipping-0.4.6 lib/simple_shipping/abstract/response.rb