Class: FidorApi::Token

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
lib/fidor_api/token.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



6
7
8
# File 'lib/fidor_api/token.rb', line 6

def access_token
  @access_token
end

#expires_atObject

Returns the value of attribute expires_at.



6
7
8
# File 'lib/fidor_api/token.rb', line 6

def expires_at
  @expires_at
end

#refresh_tokenObject

Returns the value of attribute refresh_token.



6
7
8
# File 'lib/fidor_api/token.rb', line 6

def refresh_token
  @refresh_token
end

#stateObject

Returns the value of attribute state.



6
7
8
# File 'lib/fidor_api/token.rb', line 6

def state
  @state
end

#token_typeObject

Returns the value of attribute token_type.



6
7
8
# File 'lib/fidor_api/token.rb', line 6

def token_type
  @token_type
end

Instance Method Details

#expires_in=(value) ⇒ Object



12
13
14
# File 'lib/fidor_api/token.rb', line 12

def expires_in=(value)
  self.expires_at = Time.now + value.seconds
end

#to_hashObject



16
17
18
19
20
21
22
23
24
# File 'lib/fidor_api/token.rb', line 16

def to_hash
  {
    access_token:  access_token,
    expires_at:    expires_at,
    token_type:    token_type,
    refresh_token: refresh_token,
    state:         state
  }
end

#valid?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/fidor_api/token.rb', line 8

def valid?
  expires_at >= Time.now
end