Sha256: 26c21b4e6075b91be09c4f8fc8d2fd741b254751e90285589491dd7268050226

Contents?: true

Size: 644 Bytes

Versions: 5

Compression:

Stored size: 644 Bytes

Contents

# frozen_string_literal: true
module Usps
  module Api
    module Errors
      class UspsError < ::Faraday::Error
        attr_reader :response

        def initialize(error, response = nil)
          super error['Description']
          @error_number = error['Number']
          @error_description = error['Description']
          @error_source = error['Source']
          @response = response
        end

        def error
          response.body.error
        end

        def errors
          response.body.errors
        end

        def response_metadata
          response.body.response_metadata
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
usps-ruby-client-0.2.0 lib/usps/api/errors/usps_error.rb
usps-ruby-client-0.1.3 lib/usps/api/errors/usps_error.rb
usps-ruby-client-0.1.2 lib/usps/api/errors/usps_error.rb
usps-ruby-client-0.1.1 lib/usps/api/errors/usps_error.rb
usps-ruby-client-0.1.0 lib/usps/api/errors/usps_error.rb