Class: Berbix::UserTokens
- Inherits:
-
Object
- Object
- Berbix::UserTokens
- Defined in:
- lib/berbix.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#expiry ⇒ Object
readonly
Returns the value of attribute expiry.
-
#refresh_token ⇒ Object
readonly
Returns the value of attribute refresh_token.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Instance Method Summary collapse
-
#initialize(refresh_token, access_token = nil, expiry = nil, user_id = nil) ⇒ UserTokens
constructor
A new instance of UserTokens.
- #needs_refresh? ⇒ Boolean
- #refresh!(access_token, expiry, user_id) ⇒ Object
Constructor Details
#initialize(refresh_token, access_token = nil, expiry = nil, user_id = nil) ⇒ UserTokens
Returns a new instance of UserTokens.
42 43 44 45 46 47 |
# File 'lib/berbix.rb', line 42 def initialize(refresh_token, access_token=nil, expiry=nil, user_id=nil) @refresh_token = refresh_token @access_token = access_token @expiry = expiry @user_id = user_id end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
40 41 42 |
# File 'lib/berbix.rb', line 40 def access_token @access_token end |
#expiry ⇒ Object (readonly)
Returns the value of attribute expiry.
40 41 42 |
# File 'lib/berbix.rb', line 40 def expiry @expiry end |
#refresh_token ⇒ Object (readonly)
Returns the value of attribute refresh_token.
40 41 42 |
# File 'lib/berbix.rb', line 40 def refresh_token @refresh_token end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
40 41 42 |
# File 'lib/berbix.rb', line 40 def user_id @user_id end |
Instance Method Details
#needs_refresh? ⇒ Boolean
55 56 57 |
# File 'lib/berbix.rb', line 55 def needs_refresh? @access_token.nil? || @expiry.nil? || @expiry < Time.now end |
#refresh!(access_token, expiry, user_id) ⇒ Object
49 50 51 52 53 |
# File 'lib/berbix.rb', line 49 def refresh!(access_token, expiry, user_id) @access_token = access_token @expiry = expiry @user_id = user_id end |