Sha256: f958f3c62a46f754bbe8a53a54303b0bb976d1fe2b29d516ce0ee8636fda3f87

Contents?: true

Size: 686 Bytes

Versions: 33

Compression:

Stored size: 686 Bytes

Contents

# frozen_string_literal: true

module FriendlyShipping
  module Services
    class ShipEngine
      class ParseVoidResponse
        extend Dry::Monads::Result::Mixin

        def self.call(request:, response:)
          parsed_json = JSON.parse(response.body)
          approved, message = parsed_json["approved"], parsed_json["message"]
          if approved
            Success(
              ApiResult.new(message, original_request: request, original_response: response)
            )
          else
            Failure(
              ApiFailure.new(message, original_request: request, original_response: response)
            )
          end
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
friendly_shipping-0.8.1 lib/friendly_shipping/services/ship_engine/parse_void_response.rb
friendly_shipping-0.8.0 lib/friendly_shipping/services/ship_engine/parse_void_response.rb
friendly_shipping-0.7.3 lib/friendly_shipping/services/ship_engine/parse_void_response.rb
friendly_shipping-0.7.2 lib/friendly_shipping/services/ship_engine/parse_void_response.rb
friendly_shipping-0.7.1 lib/friendly_shipping/services/ship_engine/parse_void_response.rb
friendly_shipping-0.7.0 lib/friendly_shipping/services/ship_engine/parse_void_response.rb
friendly_shipping-0.6.5 lib/friendly_shipping/services/ship_engine/parse_void_response.rb
friendly_shipping-0.6.4 lib/friendly_shipping/services/ship_engine/parse_void_response.rb
friendly_shipping-0.6.3 lib/friendly_shipping/services/ship_engine/parse_void_response.rb
friendly_shipping-0.6.2 lib/friendly_shipping/services/ship_engine/parse_void_response.rb
friendly_shipping-0.6.1 lib/friendly_shipping/services/ship_engine/parse_void_response.rb
friendly_shipping-0.6.0 lib/friendly_shipping/services/ship_engine/parse_void_response.rb
friendly_shipping-0.5.3 lib/friendly_shipping/services/ship_engine/parse_void_response.rb
friendly_shipping-0.5.2 lib/friendly_shipping/services/ship_engine/parse_void_response.rb
friendly_shipping-0.5.1 lib/friendly_shipping/services/ship_engine/parse_void_response.rb
friendly_shipping-0.5 lib/friendly_shipping/services/ship_engine/parse_void_response.rb
friendly_shipping-0.4.14 lib/friendly_shipping/services/ship_engine/parse_void_response.rb
friendly_shipping-0.4.13 lib/friendly_shipping/services/ship_engine/parse_void_response.rb
friendly_shipping-0.4.12 lib/friendly_shipping/services/ship_engine/parse_void_response.rb
friendly_shipping-0.4.11 lib/friendly_shipping/services/ship_engine/parse_void_response.rb