Class: SpotifyWebApi::OAuthToken
- Defined in:
- lib/spotify_web_api/models/o_auth_token.rb
Overview
OAuth 2 Authorization endpoint response
Instance Attribute Summary collapse
-
#access_token ⇒ String
Access token.
-
#expires_in ⇒ Integer
Time in seconds before the access token expires.
-
#expiry ⇒ Integer
Time of token expiry as unix timestamp (UTC).
-
#refresh_token ⇒ String
Refresh token Used to get a new access token when it expires.
-
#scope ⇒ String
List of scopes granted This is a space-delimited list of strings.
-
#token_type ⇒ String
Type of access token.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(access_token = nil, token_type = nil, expires_in = SKIP, scope = SKIP, expiry = SKIP, refresh_token = SKIP) ⇒ OAuthToken
constructor
A new instance of OAuthToken.
Methods inherited from BaseModel
Constructor Details
#initialize(access_token = nil, token_type = nil, expires_in = SKIP, scope = SKIP, expiry = SKIP, refresh_token = SKIP) ⇒ OAuthToken
Returns a new instance of OAuthToken.
65 66 67 68 69 70 71 72 73 |
# File 'lib/spotify_web_api/models/o_auth_token.rb', line 65 def initialize(access_token = nil, token_type = nil, expires_in = SKIP, scope = SKIP, expiry = SKIP, refresh_token = SKIP) @access_token = access_token @token_type = token_type @expires_in = expires_in unless expires_in == SKIP @scope = scope unless scope == SKIP @expiry = expiry unless expiry == SKIP @refresh_token = refresh_token unless refresh_token == SKIP end |
Instance Attribute Details
#access_token ⇒ String
Access token
14 15 16 |
# File 'lib/spotify_web_api/models/o_auth_token.rb', line 14 def access_token @access_token end |
#expires_in ⇒ Integer
Time in seconds before the access token expires
22 23 24 |
# File 'lib/spotify_web_api/models/o_auth_token.rb', line 22 def expires_in @expires_in end |
#expiry ⇒ Integer
Time of token expiry as unix timestamp (UTC)
31 32 33 |
# File 'lib/spotify_web_api/models/o_auth_token.rb', line 31 def expiry @expiry end |
#refresh_token ⇒ String
Refresh token Used to get a new access token when it expires.
36 37 38 |
# File 'lib/spotify_web_api/models/o_auth_token.rb', line 36 def refresh_token @refresh_token end |
#scope ⇒ String
List of scopes granted This is a space-delimited list of strings.
27 28 29 |
# File 'lib/spotify_web_api/models/o_auth_token.rb', line 27 def scope @scope end |
#token_type ⇒ String
Type of access token
18 19 20 |
# File 'lib/spotify_web_api/models/o_auth_token.rb', line 18 def token_type @token_type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/spotify_web_api/models/o_auth_token.rb', line 76 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. access_token = hash.key?('access_token') ? hash['access_token'] : nil token_type = hash.key?('token_type') ? hash['token_type'] : nil expires_in = hash.key?('expires_in') ? hash['expires_in'] : SKIP scope = hash.key?('scope') ? hash['scope'] : SKIP expiry = hash.key?('expiry') ? hash['expiry'] : SKIP refresh_token = hash.key?('refresh_token') ? hash['refresh_token'] : SKIP # Create object from extracted values. OAuthToken.new(access_token, token_type, expires_in, scope, expiry, refresh_token) end |
.names ⇒ Object
A mapping from model property names to API property names.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/spotify_web_api/models/o_auth_token.rb', line 39 def self.names @_hash = {} if @_hash.nil? @_hash['access_token'] = 'access_token' @_hash['token_type'] = 'token_type' @_hash['expires_in'] = 'expires_in' @_hash['scope'] = 'scope' @_hash['expiry'] = 'expiry' @_hash['refresh_token'] = 'refresh_token' @_hash end |
.nullables ⇒ Object
An array for nullable fields
61 62 63 |
# File 'lib/spotify_web_api/models/o_auth_token.rb', line 61 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
51 52 53 54 55 56 57 58 |
# File 'lib/spotify_web_api/models/o_auth_token.rb', line 51 def self.optionals %w[ expires_in scope expiry refresh_token ] end |