Class: Savon::SOAP::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/vindicia/savon.rb

Instance Method Summary collapse

Instance Method Details

#to_class(opts = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/vindicia/savon.rb', line 7

def to_class(opts = {})
  return if !success?
  klass = to_hash
  # drill down to envelope
  klass = klass[klass.keys[0]]

  status_code = klass[:return][:return_code].to_i
  if status_code != 200
    if opts[:raise_on_error]
      raise ResponseError.new("Soap Error: #{klass[:return][:return_string]}")
    end
    return
  end
  
  # drill down to payload, [0] is return, [1] is payload, [2] is xmlns
  klass[klass.keys[1]]
end