Class: SpotifyWebApi::SearchController
- Inherits:
-
BaseController
- Object
- BaseController
- SpotifyWebApi::SearchController
- Defined in:
- lib/spotify_web_api/controllers/search_controller.rb
Overview
SearchController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#search(q, type, market: nil, limit: 20, offset: 0, include_external: nil) ⇒ SearchItems
Get Spotify catalog information about albums, artists, playlists, tracks, shows, episodes or audiobooks that match a keyword string.
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
#search(q, type, market: nil, limit: 20, offset: 0, include_external: nil) ⇒ SearchItems
Get Spotify catalog information about albums, artists, playlists, tracks, shows, episodes or audiobooks that match a keyword string. Audiobooks are only available within the US, UK, Canada, Ireland, New Zealand and Australia markets. Example:
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 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/spotify_web_api/controllers/search_controller.rb', line 21 def search(q, type, market: nil, limit: 20, offset: 0, include_external: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/search', Server::DEFAULT) .query_param(new_parameter(q, key: 'q')) .query_param(new_parameter(type, key: 'type')) .query_param(new_parameter(market, key: 'market')) .query_param(new_parameter(limit, key: 'limit')) .query_param(new_parameter(offset, key: 'offset')) .query_param(new_parameter(include_external, key: 'include_external')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('oauth_2_0')) .array_serialization_format(ArraySerializationFormat::CSV)) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(SearchItems.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 |