Class: Reactor::Cm::MultiXmlRequest::MultiXmlResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/reactor/cm/multi_xml_request.rb

Instance Method Summary collapse

Constructor Details

#initialize(xml, mandatory, optional) ⇒ MultiXmlResponse

Returns a new instance of MultiXmlResponse.



87
88
89
90
91
92
# File 'lib/reactor/cm/multi_xml_request.rb', line 87

def initialize(xml, mandatory, optional)
  @xml = xml
  @mandatory = mandatory
  @optional = optional
  @n = Nokogiri::XML.parse(@xml)
end

Instance Method Details

#assert_successObject



94
95
96
97
98
99
# File 'lib/reactor/cm/multi_xml_request.rb', line 94

def assert_success
  first_failed = nil
  @mandatory.any? do |mandatory_id|
    @n.xpath("//cm-response[@request-id='#{mandatory_id}']//cm-code[@numeric='200']").empty? && (first_failed = mandatory_id)
  end && raise(XmlMultiRequestError, @n.xpath("//cm-response[@request-id='#{first_failed}']//cm-code//error/phrase/text()").map(&:to_s).join("\n"))
end