Sha256: 1c1722c277b88ee8c4cb61982fe0c552195c05b3dcee670218864fd992a470d2

Contents?: true

Size: 855 Bytes

Versions: 1

Compression:

Stored size: 855 Bytes

Contents

module Ifns
  module Responses
    class Base
      attr_reader :response, :cached, :id

      delegate :body, :status, to: :response

      def initialize(response)
        @response = response
      end

      def valid?
        good?
      end

      def invalid?
        incorrect_fpd? || incorrect_params? || not_found?
      end

      def retry?
        gone? || accepted?
      end

      def good?
        status == 200
      end

      def gone?
        status == 410
      end

      def internal_error?
        status >= 500
      end

      def not_found?
        status == 404
      end

      def accepted?
        status == 202
      end

      def incorrect_params?
        status == 400
      end

      def rate_limit_exceeded?
        status == 429
      end

      def incorrect_fpd?
        status == 406
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ifns-0.2.0 lib/ifns/responses/base.rb