Class: Malcolm::SOAPParser
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- Malcolm::SOAPParser
- Defined in:
- lib/malcolm/response/soap_parser.rb
Overview
Response middleware that unwraps a SOAP envelope for you
Instance Method Summary collapse
-
#initialize(env, *args) ⇒ SOAPParser
constructor
A new instance of SOAPParser.
-
#on_complete(env) ⇒ Object
Expects response XML to already be parsed.
Constructor Details
#initialize(env, *args) ⇒ SOAPParser
Returns a new instance of SOAPParser.
4 5 6 7 |
# File 'lib/malcolm/response/soap_parser.rb', line 4 def initialize(env, *args) key = args[0] super(env) end |
Instance Method Details
#on_complete(env) ⇒ Object
Expects response XML to already be parsed
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/malcolm/response/soap_parser.rb', line 10 def on_complete(env) env[:body] = Nori.new( strip_namespaces: true, convert_tags_to: ->(tag) { tag.snakecase.to_sym } ).parse(env[:body]) raise SOAPError, "Invalid SOAP response" if env[:body].empty? env[:body] = env[:body][:envelope][:body] env[:body] = find_key_in_hash(env[:body], @key) end |