Class: Amsi::DocumentParser::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/amsi/document_parser/base.rb

Overview

Base class for parsing AMSI responses. Subclasses must implement #parse_body and can optionally override #validator_classes to add more validation than just the default

Direct Known Subclasses

GetMoveins, GuestCardResult, Leases, Properties

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Base

Returns a new instance of Base.



11
12
13
# File 'lib/amsi/document_parser/base.rb', line 11

def initialize(params = {})
  @params = params
end

Instance Method Details

#parse(xml) ⇒ Object

Returns the parsed object(s) from the response.

Parameters:

  • xml (String)

    the XML response from the request

Returns:

  • (Object)

    the parsed object(s) from the response

Raises:

  • (Amsi::Error::Base)

    if the response is invalid



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/amsi/document_parser/base.rb', line 18

def parse(xml)
  begin
    parsed_response = MultiXml.parse(xml)
  rescue MultiXml::ParseError => e
    raise Amsi::Error::UnparsableResponse, xml
  end

  validate_response!(parsed_response)

  parse_body(parsed_response['soap:Envelope']['soap:Body'])
end