Class: SpotifyWebApi::CategoriesController
- Inherits:
-
BaseController
- Object
- BaseController
- SpotifyWebApi::CategoriesController
- Defined in:
- lib/spotify_web_api/controllers/categories_controller.rb
Overview
CategoriesController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#get_a_category(category_id, locale: nil) ⇒ CategoryObject
Get a single category used to tag items in Spotify (on, for example, the Spotify player’s “Browse” tab).
-
#get_categories(locale: nil, limit: 20, offset: 0) ⇒ PagedCategories
Get a list of categories used to tag items in Spotify (on, for example, the Spotify player’s “Browse” tab).
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_a_category(category_id, locale: nil) ⇒ CategoryObject
Get a single category used to tag items in Spotify (on, for example, the Spotify player’s “Browse” tab).
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/spotify_web_api/controllers/categories_controller.rb', line 52 def get_a_category(category_id, locale: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/browse/categories/{category_id}', Server::DEFAULT) .template_param(new_parameter(category_id, key: 'category_id') .should_encode(true)) .query_param(new_parameter(locale, key: 'locale')) .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(CategoryObject.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_categories(locale: nil, limit: 20, offset: 0) ⇒ PagedCategories
Get a list of categories used to tag items in Spotify (on, for example, the Spotify player’s “Browse” tab).
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 41 42 43 44 45 |
# File 'lib/spotify_web_api/controllers/categories_controller.rb', line 15 def get_categories(locale: nil, limit: 20, offset: 0) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/browse/categories', Server::DEFAULT) .query_param(new_parameter(locale, key: 'locale')) .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(PagedCategories.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 |