Class: WalmartOpen::AuthToken
- Inherits:
-
Object
- Object
- WalmartOpen::AuthToken
- Defined in:
- lib/walmart_open/auth_token.rb
Constant Summary collapse
- BUFFER_TIME =
seconds
30
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#expiration_time ⇒ Object
readonly
Returns the value of attribute expiration_time.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#token_type ⇒ Object
readonly
Returns the value of attribute token_type.
Instance Method Summary collapse
- #authorization_header ⇒ Object
- #expired? ⇒ Boolean
-
#initialize(attrs, grant_time = Time.now) ⇒ AuthToken
constructor
A new instance of AuthToken.
Constructor Details
#initialize(attrs, grant_time = Time.now) ⇒ AuthToken
Returns a new instance of AuthToken.
10 11 12 13 14 15 |
# File 'lib/walmart_open/auth_token.rb', line 10 def initialize(attrs, grant_time = Time.now) @expiration_time = grant_time + attrs["expires_in"] @token_type = attrs["token_type"] @access_token = attrs["access_token"] @time = grant_time end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
5 6 7 |
# File 'lib/walmart_open/auth_token.rb', line 5 def access_token @access_token end |
#expiration_time ⇒ Object (readonly)
Returns the value of attribute expiration_time.
5 6 7 |
# File 'lib/walmart_open/auth_token.rb', line 5 def expiration_time @expiration_time end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
5 6 7 |
# File 'lib/walmart_open/auth_token.rb', line 5 def time @time end |
#token_type ⇒ Object (readonly)
Returns the value of attribute token_type.
5 6 7 |
# File 'lib/walmart_open/auth_token.rb', line 5 def token_type @token_type end |
Instance Method Details
#authorization_header ⇒ Object
21 22 23 |
# File 'lib/walmart_open/auth_token.rb', line 21 def "#{token_type.capitalize} #{access_token}" end |
#expired? ⇒ Boolean
17 18 19 |
# File 'lib/walmart_open/auth_token.rb', line 17 def expired? Time.now + BUFFER_TIME >= expiration_time end |