Sha256: a3ae52086d3cb41a079ed3765a6afb2caf59d2128d7c63c21d38fad22c90de94

Contents?: true

Size: 769 Bytes

Versions: 3

Compression:

Stored size: 769 Bytes

Contents

require_relative 'hal_resource'
module Finix

  class Errors < ::StandardError
    include Finix::HalResource
    attr_reader :code
    attr_reader :total

    def initialize(response=nil)
      @code = response[:status].to_i
      @total = response[:body]['total'].to_i

      load_page_from_response! response
      @attributes['errors'] = @attributes.delete 'items'
      @attributes.delete 'page'
    end

    def to_s
      "#{@errors}"
    end

  end

  class BadRequest < Errors
  end

  class Unauthorized < Errors
  end

  class PaymentRequired < Errors
  end

  class Forbidden < Errors
  end

  class NotFound < Errors
  end

  class MethodNotAllowed < Errors
  end

  class UnprocessableEntity < Errors
  end

  class InternalServerError < Errors
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
finix-1.0.1 lib/finix/errors.rb
finix-1.0.0 lib/finix/errors.rb
finix-0.16 lib/finix/errors.rb