Class: SpotifyWebApi::GenresController

Inherits:
BaseController show all
Defined in:
lib/spotify_web_api/controllers/genres_controller.rb

Overview

GenresController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

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_recommendation_genresManyGenres

Retrieve a list of available genres seed parameter values for [recommendations](/documentation/web-api/reference/get-recommendations).

Returns:



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
# File 'lib/spotify_web_api/controllers/genres_controller.rb', line 12

def get_recommendation_genres
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/recommendations/available-genre-seeds',
                                 Server::DEFAULT)
               .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(ManyGenres.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