Sha256: cc04c7302b1f23b7cf37d00df18d662db5b4b5c9dd3f117b095c939666218314

Contents?: true

Size: 907 Bytes

Versions: 1

Compression:

Stored size: 907 Bytes

Contents

# frozen_string_literal: true

module FriendlyShipping
  module Services
    class UpsJson
      class ParseAddressClassificationResponse
        extend Dry::Monads::Result::Mixin

        class << self
          def call(request:, response:)
            parsed_response = ParseJsonResponse.call(
              request: request,
              response: response,
              expected_root_key: 'XAVResponse'
            )
            parsed_response.bind do |classification_response|
              address_type = classification_response.dig('XAVResponse', 'AddressClassification', 'Description')&.downcase
              Success(
                FriendlyShipping::ApiResult.new(
                  address_type,
                  original_request: request,
                  original_response: response
                )
              )
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
friendly_shipping-0.9.0 lib/friendly_shipping/services/ups_json/parse_address_classification_response.rb