Class: FriendlyShipping::Services::Ups::ParseXMLResponse
- Inherits:
-
Object
- Object
- FriendlyShipping::Services::Ups::ParseXMLResponse
- Extended by:
- Dry::Monads::Result::Mixin
- Defined in:
- lib/friendly_shipping/services/ups/parse_xml_response.rb
Constant Summary collapse
- SUCCESSFUL_RESPONSE_STATUS_CODE =
'1'
Class Method Summary collapse
Class Method Details
.call(request:, response:, expected_root_tag:) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/friendly_shipping/services/ups/parse_xml_response.rb', line 11 def call(request:, response:, expected_root_tag:) xml = Nokogiri.XML(response.body, &:strict) if xml.root.nil? || xml.root.name != expected_root_tag wrap_failure('Invalid document', request, response) elsif request_successful?(xml) Success(xml) else wrap_failure((xml), request, response) end rescue Nokogiri::XML::SyntaxError => e wrap_failure(e, request, response) end |