Class: ResoTransport::Authentication::Access

Inherits:
Object
  • Object
show all
Defined in:
lib/reso_transport/authentication/access.rb

Overview

Session class for TokenAuth. This stores the access token, the token type (usually ‘Bearer`), and the expiration date of the token.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Access

Returns a new instance of Access.



8
9
10
11
12
# File 'lib/reso_transport/authentication/access.rb', line 8

def initialize(options = {})
  @access_token = options[:access_token]
  @expires      = Time.now + options[:expires_in]
  @token_type   = options[:token_type]
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



6
7
8
# File 'lib/reso_transport/authentication/access.rb', line 6

def access_token
  @access_token
end

#expiresObject

Returns the value of attribute expires.



6
7
8
# File 'lib/reso_transport/authentication/access.rb', line 6

def expires
  @expires
end

#token_typeObject

Returns the value of attribute token_type.



6
7
8
# File 'lib/reso_transport/authentication/access.rb', line 6

def token_type
  @token_type
end

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/reso_transport/authentication/access.rb', line 14

def expired?
  Time.now > expires
end

#valid?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/reso_transport/authentication/access.rb', line 18

def valid?
  !!access_token && !expired?
end