lib/friendly_shipping/services/usps/parse_time_in_transit_response.rb
# Parse a response from USPS' time in transit API
#
# @param [FriendlyShipping::Request] request The request that was used to obtain this Response
# @param [FriendlyShipping::Response] response The response that USPS returned
# @return [Result<ApiResult<Array<FriendlyShipping::Timing>>>] When successfully parsing, an array of timings in a Success Monad.
Parse a response from USPS' time in transit API
Parse a response from USPS ' time in transit API
def call(request:, response:)
            parsing_result = ParseXMLResponse.call(
              request: request,
              response: response,
              expected_root_tag: 'SDCGetLocationsResponse'
            )
            parsing_result.fmap do |xml|
              expedited_commitments = xml.xpath('//Expedited')
              expedited_timings = parse_expedited_commitment_nodes(expedited_commitments)
              non_expedited_commitments = xml.xpath('//NonExpedited')
              non_expedited_timings = parse_non_expedited_commitment_nodes(non_expedited_commitments)
              ApiResult.new(
                expedited_timings + non_expedited_timings,
                original_request: request,
                original_response: response
              )
            end
          end
def call ( request : , response : ) parsing_result = ParseXMLResponse . call ( request : request , response : response , expected_root_tag : 'SDCGetLocationsResponse' ) parsing_result . fmap do | xml | expedited_commitments = xml . xpath ( '//Expedited' ) expedited_timings = parse_expedited_commitment_nodes ( expedited_commitments ) non_expedited_commitments = xml . xpath ( '//NonExpedited' ) non_expedited_timings = parse_non_expedited_commitment_nodes ( non_expedited_commitments ) ApiResult . new ( expedited_timings + non_expedited_timings , original_request : request , original_response : response ) end end
Parse a response from USPS' time in transit API
Parse a response from USPS ' time in transit API
# Filter out error responses and directly return a failure
When successfully parsing, an array of timings in a Success Monad.
When successfully parsing an array of timings in a Success Monad .
Result<ApiResult<Array<FriendlyShipping::Timing>>>
request
<not_specific>
response
<not_specific>
<not_specific>
response The response that USPS returned
response The response that USPS returned