Class: SpotifyWebApi::Client
- Inherits:
-
Object
- Object
- SpotifyWebApi::Client
- Includes:
- CoreLibrary
- Defined in:
- lib/spotify_web_api/client.rb
Overview
spotify_web_api client class.
Instance Attribute Summary collapse
-
#auth_managers ⇒ Object
readonly
Returns the value of attribute auth_managers.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#albums ⇒ AlbumsController
Access to albums controller.
-
#artists ⇒ ArtistsController
Access to artists controller.
-
#audiobooks ⇒ AudiobooksController
Access to audiobooks controller.
-
#categories ⇒ CategoriesController
Access to categories controller.
-
#chapters ⇒ ChaptersController
Access to chapters controller.
-
#episodes ⇒ EpisodesController
Access to episodes controller.
-
#genres ⇒ GenresController
Access to genres controller.
-
#initialize(connection: nil, adapter: :net_http_persistent, timeout: 60, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put],, http_callback: nil, environment: Environment::PRODUCTION, o_auth_client_id: nil, o_auth_client_secret: nil, o_auth_redirect_uri: nil, o_auth_token: nil, o_auth_scopes: nil, authorization_code_auth_credentials: nil, config: nil) ⇒ Client
constructor
A new instance of Client.
-
#initialize_auth_managers(global_config) ⇒ Object
Initializes the auth managers hash used for authenticating API calls.
-
#markets ⇒ MarketsController
Access to markets controller.
-
#o_auth_authorization ⇒ OAuthAuthorizationController
Access to o_auth_authorization controller.
-
#oauth_2_0 ⇒ Object
Returns the configured authentication oauth_2_0 instance.
-
#player ⇒ PlayerController
Access to player controller.
-
#playlists ⇒ PlaylistsController
Access to playlists controller.
-
#search ⇒ SearchController
Access to search controller.
-
#shows ⇒ ShowsController
Access to shows controller.
-
#tracks ⇒ TracksController
Access to tracks controller.
-
#users ⇒ UsersController
Access to users controller.
Constructor Details
#initialize(connection: nil, adapter: :net_http_persistent, timeout: 60, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put],, http_callback: nil, environment: Environment::PRODUCTION, o_auth_client_id: nil, o_auth_client_secret: nil, o_auth_redirect_uri: nil, o_auth_token: nil, o_auth_scopes: nil, authorization_code_auth_credentials: nil, config: nil) ⇒ Client
Returns a new instance of Client.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/spotify_web_api/client.rb', line 107 def initialize( connection: nil, adapter: :net_http_persistent, timeout: 60, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put], http_callback: nil, environment: Environment::PRODUCTION, o_auth_client_id: nil, o_auth_client_secret: nil, o_auth_redirect_uri: nil, o_auth_token: nil, o_auth_scopes: nil, authorization_code_auth_credentials: nil, config: nil ) @config = if config.nil? Configuration.new( connection: connection, adapter: adapter, timeout: timeout, max_retries: max_retries, retry_interval: retry_interval, backoff_factor: backoff_factor, retry_statuses: retry_statuses, retry_methods: retry_methods, http_callback: http_callback, environment: environment, o_auth_client_id: o_auth_client_id, o_auth_client_secret: o_auth_client_secret, o_auth_redirect_uri: o_auth_redirect_uri, o_auth_token: o_auth_token, o_auth_scopes: o_auth_scopes, authorization_code_auth_credentials: ) else config end @global_configuration = GlobalConfiguration.new(client_configuration: @config) .base_uri_executor(@config.method(:get_base_uri)) .global_errors(BaseController::GLOBAL_ERRORS) .user_agent(BaseController.user_agent) initialize_auth_managers(@global_configuration) @global_configuration = @global_configuration.auth_managers(@auth_managers) end |
Instance Attribute Details
#auth_managers ⇒ Object (readonly)
Returns the value of attribute auth_managers.
10 11 12 |
# File 'lib/spotify_web_api/client.rb', line 10 def auth_managers @auth_managers end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
10 11 12 |
# File 'lib/spotify_web_api/client.rb', line 10 def config @config end |
Instance Method Details
#albums ⇒ AlbumsController
Access to albums controller.
19 20 21 |
# File 'lib/spotify_web_api/client.rb', line 19 def albums @albums ||= AlbumsController.new @global_configuration end |
#artists ⇒ ArtistsController
Access to artists controller.
25 26 27 |
# File 'lib/spotify_web_api/client.rb', line 25 def artists @artists ||= ArtistsController.new @global_configuration end |
#audiobooks ⇒ AudiobooksController
Access to audiobooks controller.
31 32 33 |
# File 'lib/spotify_web_api/client.rb', line 31 def audiobooks @audiobooks ||= AudiobooksController.new @global_configuration end |
#categories ⇒ CategoriesController
Access to categories controller.
37 38 39 |
# File 'lib/spotify_web_api/client.rb', line 37 def categories @categories ||= CategoriesController.new @global_configuration end |
#chapters ⇒ ChaptersController
Access to chapters controller.
43 44 45 |
# File 'lib/spotify_web_api/client.rb', line 43 def chapters @chapters ||= ChaptersController.new @global_configuration end |
#episodes ⇒ EpisodesController
Access to episodes controller.
49 50 51 |
# File 'lib/spotify_web_api/client.rb', line 49 def episodes @episodes ||= EpisodesController.new @global_configuration end |
#genres ⇒ GenresController
Access to genres controller.
55 56 57 |
# File 'lib/spotify_web_api/client.rb', line 55 def genres @genres ||= GenresController.new @global_configuration end |
#initialize_auth_managers(global_config) ⇒ Object
Initializes the auth managers hash used for authenticating API calls.
145 146 147 148 149 150 151 152 |
# File 'lib/spotify_web_api/client.rb', line 145 def initialize_auth_managers(global_config) @auth_managers = {} http_client_config = global_config.client_configuration %w[oauth_2_0].each { |auth| @auth_managers[auth] = nil } @auth_managers['oauth_2_0'] = OAuth2.new( http_client_config., global_config ) end |
#markets ⇒ MarketsController
Access to markets controller.
61 62 63 |
# File 'lib/spotify_web_api/client.rb', line 61 def markets @markets ||= MarketsController.new @global_configuration end |
#o_auth_authorization ⇒ OAuthAuthorizationController
Access to o_auth_authorization controller.
103 104 105 |
# File 'lib/spotify_web_api/client.rb', line 103 def @o_auth_authorization ||= OAuthAuthorizationController.new @global_configuration end |
#oauth_2_0 ⇒ Object
Returns the configured authentication oauth_2_0 instance.
13 14 15 |
# File 'lib/spotify_web_api/client.rb', line 13 def oauth_2_0 @auth_managers['oauth_2_0'] end |
#player ⇒ PlayerController
Access to player controller.
67 68 69 |
# File 'lib/spotify_web_api/client.rb', line 67 def player @player ||= PlayerController.new @global_configuration end |
#playlists ⇒ PlaylistsController
Access to playlists controller.
73 74 75 |
# File 'lib/spotify_web_api/client.rb', line 73 def playlists @playlists ||= PlaylistsController.new @global_configuration end |
#search ⇒ SearchController
Access to search controller.
79 80 81 |
# File 'lib/spotify_web_api/client.rb', line 79 def search @search ||= SearchController.new @global_configuration end |
#shows ⇒ ShowsController
Access to shows controller.
85 86 87 |
# File 'lib/spotify_web_api/client.rb', line 85 def shows @shows ||= ShowsController.new @global_configuration end |
#tracks ⇒ TracksController
Access to tracks controller.
91 92 93 |
# File 'lib/spotify_web_api/client.rb', line 91 def tracks @tracks ||= TracksController.new @global_configuration end |
#users ⇒ UsersController
Access to users controller.
97 98 99 |
# File 'lib/spotify_web_api/client.rb', line 97 def users @users ||= UsersController.new @global_configuration end |