Sha256: 0b740e3deb3255bbb48e0654c3b5f8915526d335050ae8c6e2ea73bb602d9bb6

Contents?: true

Size: 985 Bytes

Versions: 2

Compression:

Stored size: 985 Bytes

Contents

module ActiveMerchant #:nodoc:
  module Shipping #:nodoc:
    class Error < ActiveMerchant::ActiveMerchantError
    end

    class ResponseError < Error
      attr_reader :response

      def initialize(response = nil)
        if response.is_a? Response
          super(response.message)
          @response = response
        else
          super(response)
        end
      end
    end

    class Response
      attr_reader :params
      attr_reader :message
      attr_reader :test
      attr_reader :xml
      attr_reader :request

      def initialize(success, message, params = {}, options = {})
        @success, @message, @params = success, message, params.stringify_keys
        @test = options[:test] || false
        @xml = options[:xml]
        @request = options[:request]
        raise ResponseError.new(self) unless success
      end

      def success?
        @success ? true : false
      end

      def test?
        @test ? true : false
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_shipping-0.12.6 lib/active_shipping/shipping/response.rb
active_shipping-0.12.5 lib/active_shipping/shipping/response.rb