Class: SpotifyWebApi::ArtistsController
- Inherits:
-
BaseController
- Object
- BaseController
- SpotifyWebApi::ArtistsController
- Defined in:
- lib/spotify_web_api/controllers/artists_controller.rb
Overview
ArtistsController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#get_an_artist(id) ⇒ ArtistObject
Get Spotify catalog information for a single artist identified by their unique Spotify ID.
-
#get_an_artists_albums(id, include_groups: nil, market: nil, limit: 20, offset: 0) ⇒ PagingArtistDiscographyAlbumObject
Get Spotify catalog information about an artist’s albums.
-
#get_an_artists_related_artists(id) ⇒ ManyArtists
Get Spotify catalog information about artists similar to a given artist.
-
#get_an_artists_top_tracks(id, market: nil) ⇒ ManyTracks
Get Spotify catalog information about an artist’s top tracks by country.
-
#get_multiple_artists(ids) ⇒ ManyArtists
Get Spotify catalog information for several artists based on their Spotify IDs.
Methods inherited from BaseController
#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent
Constructor Details
This class inherits a constructor from SpotifyWebApi::BaseController
Instance Method Details
#get_an_artist(id) ⇒ ArtistObject
Get Spotify catalog information for a single artist identified by their unique Spotify ID.
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 39 40 |
# File 'lib/spotify_web_api/controllers/artists_controller.rb', line 13 def get_an_artist(id) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/artists/{id}', Server::DEFAULT) .template_param(new_parameter(id, key: 'id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('oauth_2_0'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ArtistObject.method(:from_hash)) .is_api_response(true) .local_error('401', "Bad or expired token. This can happen if the user revoked a'\ ' token or\nthe access token has expired. You should'\ ' re-authenticate the user.\n", UnauthorizedException) .local_error('403', "Bad OAuth request (wrong consumer key, bad nonce, expired'\ '\ntimestamp...). Unfortunately, re-authenticating the user'\ ' won't help here.\n", ForbiddenException) .local_error('429', "The app has exceeded its rate limits.\n", TooManyRequestsException)) .execute end |
#get_an_artists_albums(id, include_groups: nil, market: nil, limit: 20, offset: 0) ⇒ PagingArtistDiscographyAlbumObject
Get Spotify catalog information about an artist’s albums.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/spotify_web_api/controllers/artists_controller.rb', line 81 def get_an_artists_albums(id, include_groups: nil, market: nil, limit: 20, offset: 0) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/artists/{id}/albums', Server::DEFAULT) .template_param(new_parameter(id, key: 'id') .should_encode(true)) .query_param(new_parameter(include_groups, key: 'include_groups')) .query_param(new_parameter(market, key: 'market')) .query_param(new_parameter(limit, key: 'limit')) .query_param(new_parameter(offset, key: 'offset')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('oauth_2_0'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(PagingArtistDiscographyAlbumObject.method(:from_hash)) .is_api_response(true) .local_error('401', "Bad or expired token. This can happen if the user revoked a'\ ' token or\nthe access token has expired. You should'\ ' re-authenticate the user.\n", UnauthorizedException) .local_error('403', "Bad OAuth request (wrong consumer key, bad nonce, expired'\ '\ntimestamp...). Unfortunately, re-authenticating the user'\ ' won't help here.\n", ForbiddenException) .local_error('429', "The app has exceeded its rate limits.\n", TooManyRequestsException)) .execute end |
#get_an_artists_related_artists(id) ⇒ ManyArtists
Get Spotify catalog information about artists similar to a given artist. Similarity is based on analysis of the Spotify community’s listening history.
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/spotify_web_api/controllers/artists_controller.rb', line 158 def (id) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/artists/{id}/related-artists', Server::DEFAULT) .template_param(new_parameter(id, key: 'id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('oauth_2_0'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ManyArtists.method(:from_hash)) .is_api_response(true) .local_error('401', "Bad or expired token. This can happen if the user revoked a'\ ' token or\nthe access token has expired. You should'\ ' re-authenticate the user.\n", UnauthorizedException) .local_error('403', "Bad OAuth request (wrong consumer key, bad nonce, expired'\ '\ntimestamp...). Unfortunately, re-authenticating the user'\ ' won't help here.\n", ForbiddenException) .local_error('429', "The app has exceeded its rate limits.\n", TooManyRequestsException)) .execute end |
#get_an_artists_top_tracks(id, market: nil) ⇒ ManyTracks
Get Spotify catalog information about an artist’s top tracks by country.
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/spotify_web_api/controllers/artists_controller.rb', line 122 def get_an_artists_top_tracks(id, market: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/artists/{id}/top-tracks', Server::DEFAULT) .template_param(new_parameter(id, key: 'id') .should_encode(true)) .query_param(new_parameter(market, key: 'market')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('oauth_2_0'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ManyTracks.method(:from_hash)) .is_api_response(true) .local_error('401', "Bad or expired token. This can happen if the user revoked a'\ ' token or\nthe access token has expired. You should'\ ' re-authenticate the user.\n", UnauthorizedException) .local_error('403', "Bad OAuth request (wrong consumer key, bad nonce, expired'\ '\ntimestamp...). Unfortunately, re-authenticating the user'\ ' won't help here.\n", ForbiddenException) .local_error('429', "The app has exceeded its rate limits.\n", TooManyRequestsException)) .execute end |
#get_multiple_artists(ids) ⇒ ManyArtists
Get Spotify catalog information for several artists based on their Spotify IDs.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/spotify_web_api/controllers/artists_controller.rb', line 46 def get_multiple_artists(ids) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/artists', Server::DEFAULT) .query_param(new_parameter(ids, key: 'ids')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('oauth_2_0'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ManyArtists.method(:from_hash)) .is_api_response(true) .local_error('401', "Bad or expired token. This can happen if the user revoked a'\ ' token or\nthe access token has expired. You should'\ ' re-authenticate the user.\n", UnauthorizedException) .local_error('403', "Bad OAuth request (wrong consumer key, bad nonce, expired'\ '\ntimestamp...). Unfortunately, re-authenticating the user'\ ' won't help here.\n", ForbiddenException) .local_error('429', "The app has exceeded its rate limits.\n", TooManyRequestsException)) .execute end |