Class: FlatApi::Tokens
- Inherits:
-
Struct
- Object
- Struct
- FlatApi::Tokens
- Defined in:
- lib/flat_api/oauth.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#expires_at ⇒ Object
Returns the value of attribute expires_at.
-
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token
24 25 26 |
# File 'lib/flat_api/oauth.rb', line 24 def access_token @access_token end |
#expires_at ⇒ Object
Returns the value of attribute expires_at
24 25 26 |
# File 'lib/flat_api/oauth.rb', line 24 def expires_at @expires_at end |
#refresh_token ⇒ Object
Returns the value of attribute refresh_token
24 25 26 |
# File 'lib/flat_api/oauth.rb', line 24 def refresh_token @refresh_token end |
Class Method Details
.from_response(payload) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/flat_api/oauth.rb', line 25 def self.from_response(payload) expires_in = payload['expires_in'] new( access_token: payload['access_token'], refresh_token: payload['refresh_token'], expires_at: expires_in ? Time.now.to_i + expires_in.to_i : nil ) end |
Instance Method Details
#expired? ⇒ Boolean
34 35 36 |
# File 'lib/flat_api/oauth.rb', line 34 def expired? !expires_at.nil? && Time.now.to_i >= expires_at - EXPIRY_SKEW end |