Class: Berbix::UserTokens

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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_tokenObject (readonly)

Returns the value of attribute access_token.



40
41
42
# File 'lib/berbix.rb', line 40

def access_token
  @access_token
end

#expiryObject (readonly)

Returns the value of attribute expiry.



40
41
42
# File 'lib/berbix.rb', line 40

def expiry
  @expiry
end

#refresh_tokenObject (readonly)

Returns the value of attribute refresh_token.



40
41
42
# File 'lib/berbix.rb', line 40

def refresh_token
  @refresh_token
end

#user_idObject (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

Returns:

  • (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