Class: ChalkRuby::Token

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exchange_credentials_response) ⇒ Token



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

def initialize(exchange_credentials_response)
  @token       = exchange_credentials_response[:access_token]
  @expires_at  = DateTime.parse(exchange_credentials_response[:expires_at])
  @environment = exchange_credentials_response[:primary_environment]
  @engines     = exchange_credentials_response[:engines]
end

Instance Attribute Details

#enginesObject

Returns the value of attribute engines.



3
4
5
# File 'lib/chalk_ruby/token.rb', line 3

def engines
  @engines
end

#environmentObject

Returns the value of attribute environment.



3
4
5
# File 'lib/chalk_ruby/token.rb', line 3

def environment
  @environment
end

#expires_atObject

Returns the value of attribute expires_at.



3
4
5
# File 'lib/chalk_ruby/token.rb', line 3

def expires_at
  @expires_at
end

#tokenObject

Returns the value of attribute token.



3
4
5
# File 'lib/chalk_ruby/token.rb', line 3

def token
  @token
end

Instance Method Details

#expired?Boolean



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

def expired?
  DateTime.now.advance({ seconds: 60 }) > @expires_at
end