Class: Rallio::AccessToken
Overview
Represents an access token object as it comes from Rallio.
Instance Attribute Summary collapse
-
#access_token ⇒ String
Actual access token string.
-
#expires_at ⇒ DateTime?
Expiration DateTime or nil if access token never expires.
-
#scopes ⇒ String
List of oauth scopes for the access token.
-
#user_id ⇒ Integer
Unique id for user.
Class Method Summary collapse
-
.create(user_id:) ⇒ Rallio::AccessToken
Creates new access token for user_id.
Instance Method Summary collapse
-
#destroy ⇒ true?
Destroys access_token.
Methods inherited from Base
Instance Attribute Details
#access_token ⇒ String
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rallio/access_token.rb', line 12 class AccessToken < Base attribute :access_token, String attribute :user_id, Integer attribute :expires_at, DateTime attribute :scopes, String # Creates new access token for user_id. # # NOTE: These tokens do not expire so it is suggested (recommended) that the # token be cached and reused whenever possible. # # @param user_id [Integer] # @return [Rallio::AccessToken] def self.create(user_id:) response = self.post("/users/#{user_id}/access_tokens", headers: app_credentials) new response.parsed_response end # Destroys access_token # # @return [true, nil] true if successful or nil def destroy headers = { 'Authorization' => "Bearer #{access_token}" } self.class.delete('/access_token', headers: headers) true end end |
#expires_at ⇒ DateTime?
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rallio/access_token.rb', line 12 class AccessToken < Base attribute :access_token, String attribute :user_id, Integer attribute :expires_at, DateTime attribute :scopes, String # Creates new access token for user_id. # # NOTE: These tokens do not expire so it is suggested (recommended) that the # token be cached and reused whenever possible. # # @param user_id [Integer] # @return [Rallio::AccessToken] def self.create(user_id:) response = self.post("/users/#{user_id}/access_tokens", headers: app_credentials) new response.parsed_response end # Destroys access_token # # @return [true, nil] true if successful or nil def destroy headers = { 'Authorization' => "Bearer #{access_token}" } self.class.delete('/access_token', headers: headers) true end end |
#scopes ⇒ String
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rallio/access_token.rb', line 12 class AccessToken < Base attribute :access_token, String attribute :user_id, Integer attribute :expires_at, DateTime attribute :scopes, String # Creates new access token for user_id. # # NOTE: These tokens do not expire so it is suggested (recommended) that the # token be cached and reused whenever possible. # # @param user_id [Integer] # @return [Rallio::AccessToken] def self.create(user_id:) response = self.post("/users/#{user_id}/access_tokens", headers: app_credentials) new response.parsed_response end # Destroys access_token # # @return [true, nil] true if successful or nil def destroy headers = { 'Authorization' => "Bearer #{access_token}" } self.class.delete('/access_token', headers: headers) true end end |
#user_id ⇒ Integer
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rallio/access_token.rb', line 12 class AccessToken < Base attribute :access_token, String attribute :user_id, Integer attribute :expires_at, DateTime attribute :scopes, String # Creates new access token for user_id. # # NOTE: These tokens do not expire so it is suggested (recommended) that the # token be cached and reused whenever possible. # # @param user_id [Integer] # @return [Rallio::AccessToken] def self.create(user_id:) response = self.post("/users/#{user_id}/access_tokens", headers: app_credentials) new response.parsed_response end # Destroys access_token # # @return [true, nil] true if successful or nil def destroy headers = { 'Authorization' => "Bearer #{access_token}" } self.class.delete('/access_token', headers: headers) true end end |
Class Method Details
.create(user_id:) ⇒ Rallio::AccessToken
Creates new access token for user_id.
NOTE: These tokens do not expire so it is suggested (recommended) that the token be cached and reused whenever possible.
25 26 27 28 |
# File 'lib/rallio/access_token.rb', line 25 def self.create(user_id:) response = self.post("/users/#{user_id}/access_tokens", headers: app_credentials) new response.parsed_response end |
Instance Method Details
#destroy ⇒ true?
Destroys access_token
33 34 35 36 37 |
# File 'lib/rallio/access_token.rb', line 33 def destroy headers = { 'Authorization' => "Bearer #{access_token}" } self.class.delete('/access_token', headers: headers) true end |