spotify-api-sdk 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +30 -0
- data/README.md +107 -0
- data/lib/spotify_web_api/api_helper.rb +10 -0
- data/lib/spotify_web_api/client.rb +154 -0
- data/lib/spotify_web_api/configuration.rb +180 -0
- data/lib/spotify_web_api/controllers/albums_controller.rb +295 -0
- data/lib/spotify_web_api/controllers/artists_controller.rb +187 -0
- data/lib/spotify_web_api/controllers/audiobooks_controller.rb +258 -0
- data/lib/spotify_web_api/controllers/base_controller.rb +66 -0
- data/lib/spotify_web_api/controllers/categories_controller.rb +83 -0
- data/lib/spotify_web_api/controllers/chapters_controller.rb +82 -0
- data/lib/spotify_web_api/controllers/episodes_controller.rb +239 -0
- data/lib/spotify_web_api/controllers/genres_controller.rb +39 -0
- data/lib/spotify_web_api/controllers/markets_controller.rb +38 -0
- data/lib/spotify_web_api/controllers/o_auth_authorization_controller.rb +82 -0
- data/lib/spotify_web_api/controllers/player_controller.rb +509 -0
- data/lib/spotify_web_api/controllers/playlists_controller.rb +521 -0
- data/lib/spotify_web_api/controllers/search_controller.rb +60 -0
- data/lib/spotify_web_api/controllers/shows_controller.rb +261 -0
- data/lib/spotify_web_api/controllers/tracks_controller.rb +491 -0
- data/lib/spotify_web_api/controllers/users_controller.rb +396 -0
- data/lib/spotify_web_api/exceptions/api_exception.rb +10 -0
- data/lib/spotify_web_api/exceptions/bad_request_exception.rb +32 -0
- data/lib/spotify_web_api/exceptions/forbidden_exception.rb +32 -0
- data/lib/spotify_web_api/exceptions/not_found_exception.rb +32 -0
- data/lib/spotify_web_api/exceptions/o_auth_provider_exception.rb +48 -0
- data/lib/spotify_web_api/exceptions/too_many_requests_exception.rb +32 -0
- data/lib/spotify_web_api/exceptions/unauthorized_exception.rb +32 -0
- data/lib/spotify_web_api/http/api_response.rb +21 -0
- data/lib/spotify_web_api/http/auth/o_auth2.rb +146 -0
- data/lib/spotify_web_api/http/http_call_back.rb +10 -0
- data/lib/spotify_web_api/http/http_method_enum.rb +10 -0
- data/lib/spotify_web_api/http/http_request.rb +10 -0
- data/lib/spotify_web_api/http/http_response.rb +10 -0
- data/lib/spotify_web_api/models/album_base.rb +168 -0
- data/lib/spotify_web_api/models/album_group_enum.rb +29 -0
- data/lib/spotify_web_api/models/album_object.rb +247 -0
- data/lib/spotify_web_api/models/album_restriction_object.rb +53 -0
- data/lib/spotify_web_api/models/album_type_enum.rb +26 -0
- data/lib/spotify_web_api/models/artist_discography_album_object.rb +194 -0
- data/lib/spotify_web_api/models/artist_object.rb +147 -0
- data/lib/spotify_web_api/models/audio_analysis_object.rb +156 -0
- data/lib/spotify_web_api/models/audio_features_object.rb +249 -0
- data/lib/spotify_web_api/models/audiobook_base.rb +245 -0
- data/lib/spotify_web_api/models/audiobook_object.rb +253 -0
- data/lib/spotify_web_api/models/author_object.rb +50 -0
- data/lib/spotify_web_api/models/base_model.rb +62 -0
- data/lib/spotify_web_api/models/categories.rb +110 -0
- data/lib/spotify_web_api/models/category_object.rb +82 -0
- data/lib/spotify_web_api/models/chapter_base.rb +237 -0
- data/lib/spotify_web_api/models/chapter_object.rb +245 -0
- data/lib/spotify_web_api/models/chapter_restriction_object.rb +59 -0
- data/lib/spotify_web_api/models/context_object.rb +78 -0
- data/lib/spotify_web_api/models/copyright_object.rb +60 -0
- data/lib/spotify_web_api/models/currently_playing_context_object.rb +137 -0
- data/lib/spotify_web_api/models/currently_playing_object.rb +109 -0
- data/lib/spotify_web_api/models/cursor_object.rb +59 -0
- data/lib/spotify_web_api/models/cursor_paged_artists.rb +48 -0
- data/lib/spotify_web_api/models/cursor_paging_object.rb +88 -0
- data/lib/spotify_web_api/models/cursor_paging_play_history_object.rb +106 -0
- data/lib/spotify_web_api/models/cursor_paging_simplified_artist_object.rb +106 -0
- data/lib/spotify_web_api/models/device_object.rb +126 -0
- data/lib/spotify_web_api/models/disallows_object.rb +140 -0
- data/lib/spotify_web_api/models/episode_base.rb +237 -0
- data/lib/spotify_web_api/models/episode_object.rb +246 -0
- data/lib/spotify_web_api/models/episode_restriction_object.rb +58 -0
- data/lib/spotify_web_api/models/error_object.rb +59 -0
- data/lib/spotify_web_api/models/explicit_content_settings_object.rb +61 -0
- data/lib/spotify_web_api/models/external_id_object.rb +72 -0
- data/lib/spotify_web_api/models/external_url_object.rb +51 -0
- data/lib/spotify_web_api/models/followers_object.rb +62 -0
- data/lib/spotify_web_api/models/image_object.rb +67 -0
- data/lib/spotify_web_api/models/include_external_enum.rb +23 -0
- data/lib/spotify_web_api/models/item_type1_enum.rb +20 -0
- data/lib/spotify_web_api/models/item_type2_enum.rb +23 -0
- data/lib/spotify_web_api/models/item_type3_enum.rb +23 -0
- data/lib/spotify_web_api/models/item_type_enum.rb +38 -0
- data/lib/spotify_web_api/models/linked_track_object.rb +89 -0
- data/lib/spotify_web_api/models/many_albums.rb +57 -0
- data/lib/spotify_web_api/models/many_artists.rb +57 -0
- data/lib/spotify_web_api/models/many_audio_features.rb +57 -0
- data/lib/spotify_web_api/models/many_audiobooks.rb +57 -0
- data/lib/spotify_web_api/models/many_chapters.rb +57 -0
- data/lib/spotify_web_api/models/many_devices.rb +57 -0
- data/lib/spotify_web_api/models/many_episodes.rb +57 -0
- data/lib/spotify_web_api/models/many_genres.rb +48 -0
- data/lib/spotify_web_api/models/many_simplified_shows.rb +57 -0
- data/lib/spotify_web_api/models/many_tracks.rb +57 -0
- data/lib/spotify_web_api/models/markets.rb +50 -0
- data/lib/spotify_web_api/models/me_albums_request.rb +55 -0
- data/lib/spotify_web_api/models/me_episodes_request.rb +52 -0
- data/lib/spotify_web_api/models/me_episodes_request1.rb +54 -0
- data/lib/spotify_web_api/models/me_following_request.rb +53 -0
- data/lib/spotify_web_api/models/me_following_request1.rb +55 -0
- data/lib/spotify_web_api/models/me_player_play_request.rb +89 -0
- data/lib/spotify_web_api/models/me_player_request.rb +63 -0
- data/lib/spotify_web_api/models/me_shows_request.rb +55 -0
- data/lib/spotify_web_api/models/me_tracks_request.rb +53 -0
- data/lib/spotify_web_api/models/me_tracks_request1.rb +55 -0
- data/lib/spotify_web_api/models/meta.rb +110 -0
- data/lib/spotify_web_api/models/mode_enum.rb +30 -0
- data/lib/spotify_web_api/models/narrator_object.rb +50 -0
- data/lib/spotify_web_api/models/o_auth_provider_error_enum.rb +45 -0
- data/lib/spotify_web_api/models/o_auth_scope_enum.rb +94 -0
- data/lib/spotify_web_api/models/o_auth_token.rb +96 -0
- data/lib/spotify_web_api/models/paged_albums.rb +48 -0
- data/lib/spotify_web_api/models/paged_categories.rb +48 -0
- data/lib/spotify_web_api/models/paging_artist_discography_album_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_artist_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_featured_playlist_object.rb +59 -0
- data/lib/spotify_web_api/models/paging_object.rb +93 -0
- data/lib/spotify_web_api/models/paging_playlist_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_playlist_track_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_saved_album_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_saved_audiobook_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_saved_episode_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_saved_show_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_saved_track_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_simplified_album_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_simplified_audiobook_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_simplified_chapter_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_simplified_episode_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_simplified_show_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_simplified_track_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_track_object.rb +110 -0
- data/lib/spotify_web_api/models/play_history_object.rb +77 -0
- data/lib/spotify_web_api/models/playlist_object.rb +193 -0
- data/lib/spotify_web_api/models/playlist_owner_object.rb +109 -0
- data/lib/spotify_web_api/models/playlist_snapshot_id.rb +50 -0
- data/lib/spotify_web_api/models/playlist_track_object.rb +90 -0
- data/lib/spotify_web_api/models/playlist_tracks_ref_object.rb +60 -0
- data/lib/spotify_web_api/models/playlist_user_object.rb +98 -0
- data/lib/spotify_web_api/models/playlists_followers_request.rb +51 -0
- data/lib/spotify_web_api/models/playlists_request.rb +82 -0
- data/lib/spotify_web_api/models/playlists_tracks_request.rb +72 -0
- data/lib/spotify_web_api/models/playlists_tracks_request1.rb +97 -0
- data/lib/spotify_web_api/models/playlists_tracks_request2.rb +75 -0
- data/lib/spotify_web_api/models/private_user_object.rb +181 -0
- data/lib/spotify_web_api/models/public_user_object.rb +128 -0
- data/lib/spotify_web_api/models/queue_object.rb +60 -0
- data/lib/spotify_web_api/models/reason_enum.rb +29 -0
- data/lib/spotify_web_api/models/recommendation_seed_object.rb +104 -0
- data/lib/spotify_web_api/models/recommendations_object.rb +74 -0
- data/lib/spotify_web_api/models/release_date_precision_enum.rb +26 -0
- data/lib/spotify_web_api/models/resume_point_object.rb +60 -0
- data/lib/spotify_web_api/models/saved_album_object.rb +73 -0
- data/lib/spotify_web_api/models/saved_audiobook_object.rb +73 -0
- data/lib/spotify_web_api/models/saved_episode_object.rb +70 -0
- data/lib/spotify_web_api/models/saved_show_object.rb +73 -0
- data/lib/spotify_web_api/models/saved_track_object.rb +73 -0
- data/lib/spotify_web_api/models/search_items.rb +107 -0
- data/lib/spotify_web_api/models/section_object.rb +180 -0
- data/lib/spotify_web_api/models/segment_object.rb +166 -0
- data/lib/spotify_web_api/models/show_base.rb +211 -0
- data/lib/spotify_web_api/models/show_object.rb +219 -0
- data/lib/spotify_web_api/models/simplified_album_object.rb +186 -0
- data/lib/spotify_web_api/models/simplified_artist_object.rb +98 -0
- data/lib/spotify_web_api/models/simplified_playlist_object.rb +184 -0
- data/lib/spotify_web_api/models/simplified_track_object.rb +227 -0
- data/lib/spotify_web_api/models/time_interval_object.rb +68 -0
- data/lib/spotify_web_api/models/track.rb +331 -0
- data/lib/spotify_web_api/models/track1.rb +50 -0
- data/lib/spotify_web_api/models/track_object.rb +265 -0
- data/lib/spotify_web_api/models/track_restriction_object.rb +58 -0
- data/lib/spotify_web_api/models/type2_enum.rb +20 -0
- data/lib/spotify_web_api/models/type3_enum.rb +20 -0
- data/lib/spotify_web_api/models/type4_enum.rb +20 -0
- data/lib/spotify_web_api/models/type6_enum.rb +20 -0
- data/lib/spotify_web_api/models/type7_enum.rb +20 -0
- data/lib/spotify_web_api/models/type8_enum.rb +20 -0
- data/lib/spotify_web_api/models/type9_enum.rb +20 -0
- data/lib/spotify_web_api/models/type_enum.rb +20 -0
- data/lib/spotify_web_api/models/users_playlists_request.rb +87 -0
- data/lib/spotify_web_api/utilities/date_time_helper.rb +11 -0
- data/lib/spotify_web_api/utilities/file_wrapper.rb +16 -0
- data/lib/spotify_web_api.rb +198 -0
- metadata +264 -0
@@ -0,0 +1,521 @@
|
|
1
|
+
# spotify_web_api
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module SpotifyWebApi
|
7
|
+
# PlaylistsController
|
8
|
+
class PlaylistsController < BaseController
|
9
|
+
# Get a playlist owned by a Spotify user.
|
10
|
+
# @param [String] playlist_id Required parameter: Example:
|
11
|
+
# @param [String] market Optional parameter: Example:
|
12
|
+
# @param [String] fields Optional parameter: Example:
|
13
|
+
# @param [String] additional_types Optional parameter: Example:
|
14
|
+
# @return [PlaylistObject] response from the API call
|
15
|
+
def get_playlist(playlist_id,
|
16
|
+
market: nil,
|
17
|
+
fields: nil,
|
18
|
+
additional_types: nil)
|
19
|
+
new_api_call_builder
|
20
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
21
|
+
'/playlists/{playlist_id}',
|
22
|
+
Server::DEFAULT)
|
23
|
+
.template_param(new_parameter(playlist_id, key: 'playlist_id')
|
24
|
+
.should_encode(true))
|
25
|
+
.query_param(new_parameter(market, key: 'market'))
|
26
|
+
.query_param(new_parameter(fields, key: 'fields'))
|
27
|
+
.query_param(new_parameter(additional_types, key: 'additional_types'))
|
28
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
29
|
+
.auth(Single.new('oauth_2_0')))
|
30
|
+
.response(new_response_handler
|
31
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
32
|
+
.deserialize_into(PlaylistObject.method(:from_hash))
|
33
|
+
.is_api_response(true)
|
34
|
+
.local_error('401',
|
35
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
36
|
+
' token or\nthe access token has expired. You should'\
|
37
|
+
' re-authenticate the user.\n",
|
38
|
+
UnauthorizedException)
|
39
|
+
.local_error('403',
|
40
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
41
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
42
|
+
' won't help here.\n",
|
43
|
+
ForbiddenException)
|
44
|
+
.local_error('429',
|
45
|
+
"The app has exceeded its rate limits.\n",
|
46
|
+
TooManyRequestsException))
|
47
|
+
.execute
|
48
|
+
end
|
49
|
+
|
50
|
+
# Change a playlist's name and public/private state. (The user must, of
|
51
|
+
# course, own the playlist.)
|
52
|
+
# @param [String] playlist_id Required parameter: Example:
|
53
|
+
# @param [PlaylistsRequest] body Optional parameter: Example:
|
54
|
+
# @return [void] response from the API call
|
55
|
+
def change_playlist_details(playlist_id,
|
56
|
+
body: nil)
|
57
|
+
new_api_call_builder
|
58
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
59
|
+
'/playlists/{playlist_id}',
|
60
|
+
Server::DEFAULT)
|
61
|
+
.template_param(new_parameter(playlist_id, key: 'playlist_id')
|
62
|
+
.should_encode(true))
|
63
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
64
|
+
.body_param(new_parameter(body))
|
65
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
66
|
+
.auth(Single.new('oauth_2_0')))
|
67
|
+
.response(new_response_handler
|
68
|
+
.is_response_void(true)
|
69
|
+
.is_api_response(true)
|
70
|
+
.local_error('401',
|
71
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
72
|
+
' token or\nthe access token has expired. You should'\
|
73
|
+
' re-authenticate the user.\n",
|
74
|
+
UnauthorizedException)
|
75
|
+
.local_error('403',
|
76
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
77
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
78
|
+
' won't help here.\n",
|
79
|
+
ForbiddenException)
|
80
|
+
.local_error('429',
|
81
|
+
"The app has exceeded its rate limits.\n",
|
82
|
+
TooManyRequestsException))
|
83
|
+
.execute
|
84
|
+
end
|
85
|
+
|
86
|
+
# Get full details of the items of a playlist owned by a Spotify user.
|
87
|
+
# @param [String] playlist_id Required parameter: Example:
|
88
|
+
# @param [String] market Optional parameter: Example:
|
89
|
+
# @param [String] fields Optional parameter: Example:
|
90
|
+
# @param [Integer] limit Optional parameter: Example:20
|
91
|
+
# @param [Integer] offset Optional parameter: Example:0
|
92
|
+
# @param [String] additional_types Optional parameter: Example:
|
93
|
+
# @return [PagingPlaylistTrackObject] response from the API call
|
94
|
+
def get_playlists_tracks(playlist_id,
|
95
|
+
market: nil,
|
96
|
+
fields: nil,
|
97
|
+
limit: 20,
|
98
|
+
offset: 0,
|
99
|
+
additional_types: nil)
|
100
|
+
new_api_call_builder
|
101
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
102
|
+
'/playlists/{playlist_id}/tracks',
|
103
|
+
Server::DEFAULT)
|
104
|
+
.template_param(new_parameter(playlist_id, key: 'playlist_id')
|
105
|
+
.should_encode(true))
|
106
|
+
.query_param(new_parameter(market, key: 'market'))
|
107
|
+
.query_param(new_parameter(fields, key: 'fields'))
|
108
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
109
|
+
.query_param(new_parameter(offset, key: 'offset'))
|
110
|
+
.query_param(new_parameter(additional_types, key: 'additional_types'))
|
111
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
112
|
+
.auth(Single.new('oauth_2_0')))
|
113
|
+
.response(new_response_handler
|
114
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
115
|
+
.deserialize_into(PagingPlaylistTrackObject.method(:from_hash))
|
116
|
+
.is_api_response(true)
|
117
|
+
.local_error('401',
|
118
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
119
|
+
' token or\nthe access token has expired. You should'\
|
120
|
+
' re-authenticate the user.\n",
|
121
|
+
UnauthorizedException)
|
122
|
+
.local_error('403',
|
123
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
124
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
125
|
+
' won't help here.\n",
|
126
|
+
ForbiddenException)
|
127
|
+
.local_error('429',
|
128
|
+
"The app has exceeded its rate limits.\n",
|
129
|
+
TooManyRequestsException))
|
130
|
+
.execute
|
131
|
+
end
|
132
|
+
|
133
|
+
# Add one or more items to a user's playlist.
|
134
|
+
# @param [String] playlist_id Required parameter: Example:
|
135
|
+
# @param [Integer] position Optional parameter: Example:
|
136
|
+
# @param [String] uris Optional parameter: Example:
|
137
|
+
# @param [PlaylistsTracksRequest] body Optional parameter: Example:
|
138
|
+
# @return [PlaylistSnapshotId] response from the API call
|
139
|
+
def add_tracks_to_playlist(playlist_id,
|
140
|
+
position: nil,
|
141
|
+
uris: nil,
|
142
|
+
body: nil)
|
143
|
+
new_api_call_builder
|
144
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
145
|
+
'/playlists/{playlist_id}/tracks',
|
146
|
+
Server::DEFAULT)
|
147
|
+
.template_param(new_parameter(playlist_id, key: 'playlist_id')
|
148
|
+
.should_encode(true))
|
149
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
150
|
+
.query_param(new_parameter(position, key: 'position'))
|
151
|
+
.query_param(new_parameter(uris, key: 'uris'))
|
152
|
+
.body_param(new_parameter(body))
|
153
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
154
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
155
|
+
.auth(Single.new('oauth_2_0')))
|
156
|
+
.response(new_response_handler
|
157
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
158
|
+
.deserialize_into(PlaylistSnapshotId.method(:from_hash))
|
159
|
+
.is_api_response(true)
|
160
|
+
.local_error('401',
|
161
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
162
|
+
' token or\nthe access token has expired. You should'\
|
163
|
+
' re-authenticate the user.\n",
|
164
|
+
UnauthorizedException)
|
165
|
+
.local_error('403',
|
166
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
167
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
168
|
+
' won't help here.\n",
|
169
|
+
ForbiddenException)
|
170
|
+
.local_error('429',
|
171
|
+
"The app has exceeded its rate limits.\n",
|
172
|
+
TooManyRequestsException))
|
173
|
+
.execute
|
174
|
+
end
|
175
|
+
|
176
|
+
# Either reorder or replace items in a playlist depending on the request's
|
177
|
+
# parameters.
|
178
|
+
# To reorder items, include `range_start`, `insert_before`, `range_length`
|
179
|
+
# and `snapshot_id` in the request's body.
|
180
|
+
# To replace items, include `uris` as either a query parameter or in the
|
181
|
+
# request's body.
|
182
|
+
# Replacing items in a playlist will overwrite its existing items. This
|
183
|
+
# operation can be used for replacing or clearing items in a playlist.
|
184
|
+
# <br/>
|
185
|
+
# **Note**: Replace and reorder are mutually exclusive operations which
|
186
|
+
# share the same endpoint, but have different parameters.
|
187
|
+
# These operations can't be applied together in a single request.
|
188
|
+
# @param [String] playlist_id Required parameter: Example:
|
189
|
+
# @param [String] uris Optional parameter: Example:
|
190
|
+
# @param [PlaylistsTracksRequest1] body Optional parameter: Example:
|
191
|
+
# @return [PlaylistSnapshotId] response from the API call
|
192
|
+
def reorder_or_replace_playlists_tracks(playlist_id,
|
193
|
+
uris: nil,
|
194
|
+
body: nil)
|
195
|
+
new_api_call_builder
|
196
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
197
|
+
'/playlists/{playlist_id}/tracks',
|
198
|
+
Server::DEFAULT)
|
199
|
+
.template_param(new_parameter(playlist_id, key: 'playlist_id')
|
200
|
+
.should_encode(true))
|
201
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
202
|
+
.query_param(new_parameter(uris, key: 'uris'))
|
203
|
+
.body_param(new_parameter(body))
|
204
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
205
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
206
|
+
.auth(Single.new('oauth_2_0')))
|
207
|
+
.response(new_response_handler
|
208
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
209
|
+
.deserialize_into(PlaylistSnapshotId.method(:from_hash))
|
210
|
+
.is_api_response(true)
|
211
|
+
.local_error('401',
|
212
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
213
|
+
' token or\nthe access token has expired. You should'\
|
214
|
+
' re-authenticate the user.\n",
|
215
|
+
UnauthorizedException)
|
216
|
+
.local_error('403',
|
217
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
218
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
219
|
+
' won't help here.\n",
|
220
|
+
ForbiddenException)
|
221
|
+
.local_error('429',
|
222
|
+
"The app has exceeded its rate limits.\n",
|
223
|
+
TooManyRequestsException))
|
224
|
+
.execute
|
225
|
+
end
|
226
|
+
|
227
|
+
# Remove one or more items from a user's playlist.
|
228
|
+
# @param [String] playlist_id Required parameter: Example:
|
229
|
+
# @param [PlaylistsTracksRequest2] body Optional parameter: Example:
|
230
|
+
# @return [PlaylistSnapshotId] response from the API call
|
231
|
+
def remove_tracks_playlist(playlist_id,
|
232
|
+
body: nil)
|
233
|
+
new_api_call_builder
|
234
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
235
|
+
'/playlists/{playlist_id}/tracks',
|
236
|
+
Server::DEFAULT)
|
237
|
+
.template_param(new_parameter(playlist_id, key: 'playlist_id')
|
238
|
+
.should_encode(true))
|
239
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
240
|
+
.body_param(new_parameter(body))
|
241
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
242
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
243
|
+
.auth(Single.new('oauth_2_0')))
|
244
|
+
.response(new_response_handler
|
245
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
246
|
+
.deserialize_into(PlaylistSnapshotId.method(:from_hash))
|
247
|
+
.is_api_response(true)
|
248
|
+
.local_error('401',
|
249
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
250
|
+
' token or\nthe access token has expired. You should'\
|
251
|
+
' re-authenticate the user.\n",
|
252
|
+
UnauthorizedException)
|
253
|
+
.local_error('403',
|
254
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
255
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
256
|
+
' won't help here.\n",
|
257
|
+
ForbiddenException)
|
258
|
+
.local_error('429',
|
259
|
+
"The app has exceeded its rate limits.\n",
|
260
|
+
TooManyRequestsException))
|
261
|
+
.execute
|
262
|
+
end
|
263
|
+
|
264
|
+
# Get a list of the playlists owned or followed by the current Spotify
|
265
|
+
# user.
|
266
|
+
# @param [Integer] limit Optional parameter: Example:20
|
267
|
+
# @param [Integer] offset Optional parameter: Example:0
|
268
|
+
# @return [PagingPlaylistObject] response from the API call
|
269
|
+
def get_a_list_of_current_users_playlists(limit: 20,
|
270
|
+
offset: 0)
|
271
|
+
new_api_call_builder
|
272
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
273
|
+
'/me/playlists',
|
274
|
+
Server::DEFAULT)
|
275
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
276
|
+
.query_param(new_parameter(offset, key: 'offset'))
|
277
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
278
|
+
.auth(Single.new('oauth_2_0')))
|
279
|
+
.response(new_response_handler
|
280
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
281
|
+
.deserialize_into(PagingPlaylistObject.method(:from_hash))
|
282
|
+
.is_api_response(true)
|
283
|
+
.local_error('401',
|
284
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
285
|
+
' token or\nthe access token has expired. You should'\
|
286
|
+
' re-authenticate the user.\n",
|
287
|
+
UnauthorizedException)
|
288
|
+
.local_error('403',
|
289
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
290
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
291
|
+
' won't help here.\n",
|
292
|
+
ForbiddenException)
|
293
|
+
.local_error('429',
|
294
|
+
"The app has exceeded its rate limits.\n",
|
295
|
+
TooManyRequestsException))
|
296
|
+
.execute
|
297
|
+
end
|
298
|
+
|
299
|
+
# Get a list of the playlists owned or followed by a Spotify user.
|
300
|
+
# @param [String] user_id Required parameter: Example:
|
301
|
+
# @param [Integer] limit Optional parameter: Example:20
|
302
|
+
# @param [Integer] offset Optional parameter: Example:0
|
303
|
+
# @return [PagingPlaylistObject] response from the API call
|
304
|
+
def get_list_users_playlists(user_id,
|
305
|
+
limit: 20,
|
306
|
+
offset: 0)
|
307
|
+
new_api_call_builder
|
308
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
309
|
+
'/users/{user_id}/playlists',
|
310
|
+
Server::DEFAULT)
|
311
|
+
.template_param(new_parameter(user_id, key: 'user_id')
|
312
|
+
.should_encode(true))
|
313
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
314
|
+
.query_param(new_parameter(offset, key: 'offset'))
|
315
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
316
|
+
.auth(Single.new('oauth_2_0')))
|
317
|
+
.response(new_response_handler
|
318
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
319
|
+
.deserialize_into(PagingPlaylistObject.method(:from_hash))
|
320
|
+
.is_api_response(true)
|
321
|
+
.local_error('401',
|
322
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
323
|
+
' token or\nthe access token has expired. You should'\
|
324
|
+
' re-authenticate the user.\n",
|
325
|
+
UnauthorizedException)
|
326
|
+
.local_error('403',
|
327
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
328
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
329
|
+
' won't help here.\n",
|
330
|
+
ForbiddenException)
|
331
|
+
.local_error('429',
|
332
|
+
"The app has exceeded its rate limits.\n",
|
333
|
+
TooManyRequestsException))
|
334
|
+
.execute
|
335
|
+
end
|
336
|
+
|
337
|
+
# Create a playlist for a Spotify user. (The playlist will be empty until
|
338
|
+
# you [add
|
339
|
+
# tracks](/documentation/web-api/reference/add-tracks-to-playlist).)
|
340
|
+
# Each user is generally limited to a maximum of 11000 playlists.
|
341
|
+
# @param [String] user_id Required parameter: Example:
|
342
|
+
# @param [UsersPlaylistsRequest] body Optional parameter: Example:
|
343
|
+
# @return [PlaylistObject] response from the API call
|
344
|
+
def create_playlist(user_id,
|
345
|
+
body: nil)
|
346
|
+
new_api_call_builder
|
347
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
348
|
+
'/users/{user_id}/playlists',
|
349
|
+
Server::DEFAULT)
|
350
|
+
.template_param(new_parameter(user_id, key: 'user_id')
|
351
|
+
.should_encode(true))
|
352
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
353
|
+
.body_param(new_parameter(body))
|
354
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
355
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
356
|
+
.auth(Single.new('oauth_2_0')))
|
357
|
+
.response(new_response_handler
|
358
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
359
|
+
.deserialize_into(PlaylistObject.method(:from_hash))
|
360
|
+
.is_api_response(true)
|
361
|
+
.local_error('401',
|
362
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
363
|
+
' token or\nthe access token has expired. You should'\
|
364
|
+
' re-authenticate the user.\n",
|
365
|
+
UnauthorizedException)
|
366
|
+
.local_error('403',
|
367
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
368
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
369
|
+
' won't help here.\n",
|
370
|
+
ForbiddenException)
|
371
|
+
.local_error('429',
|
372
|
+
"The app has exceeded its rate limits.\n",
|
373
|
+
TooManyRequestsException))
|
374
|
+
.execute
|
375
|
+
end
|
376
|
+
|
377
|
+
# Get a list of Spotify featured playlists (shown, for example, on a Spotify
|
378
|
+
# player's 'Browse' tab).
|
379
|
+
# @param [String] locale Optional parameter: Example:
|
380
|
+
# @param [Integer] limit Optional parameter: Example:20
|
381
|
+
# @param [Integer] offset Optional parameter: Example:0
|
382
|
+
# @return [PagingFeaturedPlaylistObject] response from the API call
|
383
|
+
def get_featured_playlists(locale: nil,
|
384
|
+
limit: 20,
|
385
|
+
offset: 0)
|
386
|
+
new_api_call_builder
|
387
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
388
|
+
'/browse/featured-playlists',
|
389
|
+
Server::DEFAULT)
|
390
|
+
.query_param(new_parameter(locale, key: 'locale'))
|
391
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
392
|
+
.query_param(new_parameter(offset, key: 'offset'))
|
393
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
394
|
+
.auth(Single.new('oauth_2_0')))
|
395
|
+
.response(new_response_handler
|
396
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
397
|
+
.deserialize_into(PagingFeaturedPlaylistObject.method(:from_hash))
|
398
|
+
.is_api_response(true)
|
399
|
+
.local_error('401',
|
400
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
401
|
+
' token or\nthe access token has expired. You should'\
|
402
|
+
' re-authenticate the user.\n",
|
403
|
+
UnauthorizedException)
|
404
|
+
.local_error('403',
|
405
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
406
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
407
|
+
' won't help here.\n",
|
408
|
+
ForbiddenException)
|
409
|
+
.local_error('429',
|
410
|
+
"The app has exceeded its rate limits.\n",
|
411
|
+
TooManyRequestsException))
|
412
|
+
.execute
|
413
|
+
end
|
414
|
+
|
415
|
+
# Get a list of Spotify playlists tagged with a particular category.
|
416
|
+
# @param [String] category_id Required parameter: Example:
|
417
|
+
# @param [Integer] limit Optional parameter: Example:20
|
418
|
+
# @param [Integer] offset Optional parameter: Example:0
|
419
|
+
# @return [PagingFeaturedPlaylistObject] response from the API call
|
420
|
+
def get_a_categories_playlists(category_id,
|
421
|
+
limit: 20,
|
422
|
+
offset: 0)
|
423
|
+
new_api_call_builder
|
424
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
425
|
+
'/browse/categories/{category_id}/playlists',
|
426
|
+
Server::DEFAULT)
|
427
|
+
.template_param(new_parameter(category_id, key: 'category_id')
|
428
|
+
.should_encode(true))
|
429
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
430
|
+
.query_param(new_parameter(offset, key: 'offset'))
|
431
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
432
|
+
.auth(Single.new('oauth_2_0')))
|
433
|
+
.response(new_response_handler
|
434
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
435
|
+
.deserialize_into(PagingFeaturedPlaylistObject.method(:from_hash))
|
436
|
+
.is_api_response(true)
|
437
|
+
.local_error('401',
|
438
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
439
|
+
' token or\nthe access token has expired. You should'\
|
440
|
+
' re-authenticate the user.\n",
|
441
|
+
UnauthorizedException)
|
442
|
+
.local_error('403',
|
443
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
444
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
445
|
+
' won't help here.\n",
|
446
|
+
ForbiddenException)
|
447
|
+
.local_error('429',
|
448
|
+
"The app has exceeded its rate limits.\n",
|
449
|
+
TooManyRequestsException))
|
450
|
+
.execute
|
451
|
+
end
|
452
|
+
|
453
|
+
# Get the current image associated with a specific playlist.
|
454
|
+
# @param [String] playlist_id Required parameter: Example:
|
455
|
+
# @return [Array[ImageObject]] response from the API call
|
456
|
+
def get_playlist_cover(playlist_id)
|
457
|
+
new_api_call_builder
|
458
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
459
|
+
'/playlists/{playlist_id}/images',
|
460
|
+
Server::DEFAULT)
|
461
|
+
.template_param(new_parameter(playlist_id, key: 'playlist_id')
|
462
|
+
.should_encode(true))
|
463
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
464
|
+
.auth(Single.new('oauth_2_0')))
|
465
|
+
.response(new_response_handler
|
466
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
467
|
+
.deserialize_into(ImageObject.method(:from_hash))
|
468
|
+
.is_api_response(true)
|
469
|
+
.is_response_array(true)
|
470
|
+
.local_error('401',
|
471
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
472
|
+
' token or\nthe access token has expired. You should'\
|
473
|
+
' re-authenticate the user.\n",
|
474
|
+
UnauthorizedException)
|
475
|
+
.local_error('403',
|
476
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
477
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
478
|
+
' won't help here.\n",
|
479
|
+
ForbiddenException)
|
480
|
+
.local_error('429',
|
481
|
+
"The app has exceeded its rate limits.\n",
|
482
|
+
TooManyRequestsException))
|
483
|
+
.execute
|
484
|
+
end
|
485
|
+
|
486
|
+
# Replace the image used to represent a specific playlist.
|
487
|
+
# @param [String] playlist_id Required parameter: Example:
|
488
|
+
# @param [Object] body Required parameter: Example:
|
489
|
+
# @return [void] response from the API call
|
490
|
+
def upload_custom_playlist_cover(playlist_id,
|
491
|
+
body)
|
492
|
+
new_api_call_builder
|
493
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
494
|
+
'/playlists/{playlist_id}/images',
|
495
|
+
Server::DEFAULT)
|
496
|
+
.template_param(new_parameter(playlist_id, key: 'playlist_id')
|
497
|
+
.should_encode(true))
|
498
|
+
.body_param(new_parameter(body))
|
499
|
+
.header_param(new_parameter('application/json; charset=utf-8', key: 'content-type'))
|
500
|
+
.body_serializer(APIHelper.method(:json_serialize))
|
501
|
+
.auth(Single.new('oauth_2_0')))
|
502
|
+
.response(new_response_handler
|
503
|
+
.is_response_void(true)
|
504
|
+
.is_api_response(true)
|
505
|
+
.local_error('401',
|
506
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
507
|
+
' token or\nthe access token has expired. You should'\
|
508
|
+
' re-authenticate the user.\n",
|
509
|
+
UnauthorizedException)
|
510
|
+
.local_error('403',
|
511
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
512
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
513
|
+
' won't help here.\n",
|
514
|
+
ForbiddenException)
|
515
|
+
.local_error('429',
|
516
|
+
"The app has exceeded its rate limits.\n",
|
517
|
+
TooManyRequestsException))
|
518
|
+
.execute
|
519
|
+
end
|
520
|
+
end
|
521
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# spotify_web_api
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module SpotifyWebApi
|
7
|
+
# SearchController
|
8
|
+
class SearchController < BaseController
|
9
|
+
# Get Spotify catalog information about albums, artists, playlists, tracks,
|
10
|
+
# shows, episodes or audiobooks
|
11
|
+
# that match a keyword string. Audiobooks are only available within the US,
|
12
|
+
# UK, Canada, Ireland, New Zealand and Australia markets.
|
13
|
+
# @param [String] q Required parameter: Example:
|
14
|
+
# @param [Array[ItemTypeEnum]] type Required parameter: Example:
|
15
|
+
# @param [String] market Optional parameter: Example:
|
16
|
+
# @param [Integer] limit Optional parameter: Example:20
|
17
|
+
# @param [Integer] offset Optional parameter: Example:0
|
18
|
+
# @param [IncludeExternalEnum] include_external Optional parameter:
|
19
|
+
# Example:
|
20
|
+
# @return [SearchItems] response from the API call
|
21
|
+
def search(q,
|
22
|
+
type,
|
23
|
+
market: nil,
|
24
|
+
limit: 20,
|
25
|
+
offset: 0,
|
26
|
+
include_external: nil)
|
27
|
+
new_api_call_builder
|
28
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
29
|
+
'/search',
|
30
|
+
Server::DEFAULT)
|
31
|
+
.query_param(new_parameter(q, key: 'q'))
|
32
|
+
.query_param(new_parameter(type, key: 'type'))
|
33
|
+
.query_param(new_parameter(market, key: 'market'))
|
34
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
35
|
+
.query_param(new_parameter(offset, key: 'offset'))
|
36
|
+
.query_param(new_parameter(include_external, key: 'include_external'))
|
37
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
38
|
+
.auth(Single.new('oauth_2_0'))
|
39
|
+
.array_serialization_format(ArraySerializationFormat::CSV))
|
40
|
+
.response(new_response_handler
|
41
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
42
|
+
.deserialize_into(SearchItems.method(:from_hash))
|
43
|
+
.is_api_response(true)
|
44
|
+
.local_error('401',
|
45
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
46
|
+
' token or\nthe access token has expired. You should'\
|
47
|
+
' re-authenticate the user.\n",
|
48
|
+
UnauthorizedException)
|
49
|
+
.local_error('403',
|
50
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
51
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
52
|
+
' won't help here.\n",
|
53
|
+
ForbiddenException)
|
54
|
+
.local_error('429',
|
55
|
+
"The app has exceeded its rate limits.\n",
|
56
|
+
TooManyRequestsException))
|
57
|
+
.execute
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|