Class: FriendlyShipping::Services::UpsJson::ParseAddressClassificationResponse

Inherits:
Object
  • Object
show all
Extended by:
Dry::Monads::Result::Mixin
Defined in:
lib/friendly_shipping/services/ups_json/parse_address_classification_response.rb

Class Method Summary collapse

Class Method Details

.call(request:, response:) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/friendly_shipping/services/ups_json/parse_address_classification_response.rb', line 10

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