Sha256: e2a136f95c78f5d2d798bde665635bf906a06cb9483fdb55d4b9452372a578e9

Contents?: true

Size: 538 Bytes

Versions: 5

Compression:

Stored size: 538 Bytes

Contents

# frozen_string_literal: true

require 'forwardable'

module Youlend
  class Response
    extend Forwardable

    attr_reader :http_response
    def_delegators :@http_response, :headers, :body, :status, :success?

    def initialize(http_response)
      @http_response = http_response
    end

    def unauthorized?
      status == 401
    end

    def token_expired?
      auth_header = @http_response.headers['www-authenticate']

      return false unless auth_header

      auth_header.match?(/.*token is expired.*/)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
youlend-1.1.2 lib/youlend/response.rb
youlend-1.1.1 lib/youlend/response.rb
youlend-1.0.2 lib/youlend/response.rb
youlend-1.0.1 lib/youlend/response.rb
youlend-1.0.0 lib/youlend/response.rb