Sha256: 43cfe55365f42458c3c3ed45fdc0c76d755bc0161c0d446a5eb2440cd93c53ea

Contents?: true

Size: 560 Bytes

Versions: 3

Compression:

Stored size: 560 Bytes

Contents

# frozen_string_literal: true

require 'friendly_shipping/bad_request'

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

        attr_reader :response

        def initialize(response:)
          @response = response
        end

        def call
          parsed_json = JSON.parse(response.body)
          approved, message = parsed_json["approved"], parsed_json["message"]
          approved ? Success(message) : Failure(message)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
friendly_shipping-0.2.6 lib/friendly_shipping/services/ship_engine/parse_void_response.rb
friendly_shipping-0.2.5 lib/friendly_shipping/services/ship_engine/parse_void_response.rb
friendly_shipping-0.2.4 lib/friendly_shipping/services/ship_engine/parse_void_response.rb