Class: ForgeAuth::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/forge_auth/token.rb

Constant Summary collapse

EXPIRATION_BUFFER =

5% buffer

0.05

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token:, token_type:, expires_in:) ⇒ Token

Returns a new instance of Token.



7
8
9
10
11
# File 'lib/forge_auth/token.rb', line 7

def initialize(access_token:, token_type:,  expires_in:)
  @access_token = access_token
  @token_type = token_type
  @expires_in = expires_in
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



5
6
7
# File 'lib/forge_auth/token.rb', line 5

def access_token
  @access_token
end

#expires_inObject (readonly)

Returns the value of attribute expires_in.



5
6
7
# File 'lib/forge_auth/token.rb', line 5

def expires_in
  @expires_in
end

#token_typeObject (readonly)

Returns the value of attribute token_type.



5
6
7
# File 'lib/forge_auth/token.rb', line 5

def token_type
  @token_type
end

Instance Method Details

#full_tokenObject



13
14
15
# File 'lib/forge_auth/token.rb', line 13

def full_token
  "#{token_type} #{access_token}"
end

#short_expirationObject



17
18
19
# File 'lib/forge_auth/token.rb', line 17

def short_expiration
  @short_expiration ||= expires_in * (1 - EXPIRATION_BUFFER)
end