Class: Fullscriptapi::AccessToken
- Inherits:
-
Object
- Object
- Fullscriptapi::AccessToken
- Defined in:
- lib/fullscriptapi/access_token.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#expires_in ⇒ Object
readonly
Returns the value of attribute expires_in.
-
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
Instance Method Summary collapse
- #expired? ⇒ Boolean
-
#initialize(opts = {}) ⇒ AccessToken
constructor
A new instance of AccessToken.
Constructor Details
#initialize(opts = {}) ⇒ AccessToken
Returns a new instance of AccessToken.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/fullscriptapi/access_token.rb', line 8 def initialize(opts = {}) opts = opts.dup %i[access_token refresh_token expires_in expires_at expires_latency].each do |arg| instance_variable_set("@#{arg}", opts.delete(arg) || opts.delete(arg.to_s)) end @expires_in ||= opts.delete('expires') @expires_in &&= @expires_in.to_i @expires_at &&= convert_expires_at(@expires_at) @expires_at ||= Time.now.to_i + @expires_in if @expires_in end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
5 6 7 |
# File 'lib/fullscriptapi/access_token.rb', line 5 def access_token @access_token end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/fullscriptapi/access_token.rb', line 5 def client @client end |
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at.
5 6 7 |
# File 'lib/fullscriptapi/access_token.rb', line 5 def expires_at @expires_at end |
#expires_in ⇒ Object (readonly)
Returns the value of attribute expires_in.
5 6 7 |
# File 'lib/fullscriptapi/access_token.rb', line 5 def expires_in @expires_in end |
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
6 7 8 |
# File 'lib/fullscriptapi/access_token.rb', line 6 def refresh_token @refresh_token end |
Instance Method Details
#expired? ⇒ Boolean
21 22 23 |
# File 'lib/fullscriptapi/access_token.rb', line 21 def expired? expires_at <= Time.now.to_i end |