class Savon::SOAP::Response
Savon::SOAP::Response¶ ↑
Represents the SOAP response and contains the HTTP response.
Attributes
http[RW]
Public Class Methods
new(response)
click to toggle source
Expects an HTTPI::Response
and handles errors.
# File lib/savon/soap/response.rb, line 14 def initialize(response) self.http = response raise_errors if Savon.raise_errors? end
Public Instance Methods
[](key)
click to toggle source
Shortcut accessor for the SOAP response body Hash.
# File lib/savon/soap/response.rb, line 47 def [](key) body[key] end
body()
click to toggle source
Returns the SOAP response body as a Hash.
# File lib/savon/soap/response.rb, line 57 def body hash[:envelope][:body] end
Also aliased as: to_hash
hash()
click to toggle source
header()
click to toggle source
Returns the SOAP response header as a Hash.
# File lib/savon/soap/response.rb, line 52 def header hash[:envelope][:header] end
http_error()
click to toggle source
Returns the Savon::HTTP::Error
.
# File lib/savon/soap/response.rb, line 42 def http_error @http_error ||= HTTP::Error.new http end
http_error?()
click to toggle source
Returns whether there was an HTTP error.
# File lib/savon/soap/response.rb, line 37 def http_error? http_error.present? end
soap_fault()
click to toggle source
Returns the Savon::SOAP::Fault
.
# File lib/savon/soap/response.rb, line 32 def soap_fault @soap_fault ||= Fault.new http end
soap_fault?()
click to toggle source
Returns whether there was a SOAP fault.
# File lib/savon/soap/response.rb, line 27 def soap_fault? soap_fault.present? end
success?()
click to toggle source
Returns whether the request was successful.
# File lib/savon/soap/response.rb, line 22 def success? !soap_fault? && !http_error? end
to_array(*path)
click to toggle source
Traverses the SOAP response body Hash for a
given path
of Hash keys and returns the value as an Array.
Defaults to return an empty Array in case the path does not exist or
returns nil.
# File lib/savon/soap/response.rb, line 66 def to_array(*path) result = path.inject body do |memo, key| return [] unless memo[key] memo[key] end result.kind_of?(Array) ? result.compact : [result].compact end
Private Instance Methods
raise_errors()
click to toggle source
# File lib/savon/soap/response.rb, line 87 def raise_errors raise soap_fault if soap_fault? raise http_error if http_error? end