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,509 @@
|
|
1
|
+
# spotify_web_api
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module SpotifyWebApi
|
7
|
+
# PlayerController
|
8
|
+
class PlayerController < BaseController
|
9
|
+
# Get information about the user’s current playback state, including track
|
10
|
+
# or episode, progress, and active device.
|
11
|
+
# @param [String] market Optional parameter: Example:
|
12
|
+
# @param [String] additional_types Optional parameter: Example:
|
13
|
+
# @return [CurrentlyPlayingContextObject] response from the API call
|
14
|
+
def get_information_about_the_users_current_playback(market: nil,
|
15
|
+
additional_types: nil)
|
16
|
+
new_api_call_builder
|
17
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
18
|
+
'/me/player',
|
19
|
+
Server::DEFAULT)
|
20
|
+
.query_param(new_parameter(market, key: 'market'))
|
21
|
+
.query_param(new_parameter(additional_types, key: 'additional_types'))
|
22
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
23
|
+
.auth(Single.new('oauth_2_0')))
|
24
|
+
.response(new_response_handler
|
25
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
26
|
+
.deserialize_into(CurrentlyPlayingContextObject.method(:from_hash))
|
27
|
+
.is_api_response(true)
|
28
|
+
.local_error('401',
|
29
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
30
|
+
' token or\nthe access token has expired. You should'\
|
31
|
+
' re-authenticate the user.\n",
|
32
|
+
UnauthorizedException)
|
33
|
+
.local_error('403',
|
34
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
35
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
36
|
+
' won't help here.\n",
|
37
|
+
ForbiddenException)
|
38
|
+
.local_error('429',
|
39
|
+
"The app has exceeded its rate limits.\n",
|
40
|
+
TooManyRequestsException))
|
41
|
+
.execute
|
42
|
+
end
|
43
|
+
|
44
|
+
# Transfer playback to a new device and optionally begin playback. This API
|
45
|
+
# only works for users who have Spotify Premium. The order of execution is
|
46
|
+
# not guaranteed when you use this API with other Player API endpoints.
|
47
|
+
# @param [MePlayerRequest] body Optional parameter: Example:
|
48
|
+
# @return [void] response from the API call
|
49
|
+
def transfer_a_users_playback(body: nil)
|
50
|
+
new_api_call_builder
|
51
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
52
|
+
'/me/player',
|
53
|
+
Server::DEFAULT)
|
54
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
55
|
+
.body_param(new_parameter(body))
|
56
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
57
|
+
.auth(Single.new('oauth_2_0')))
|
58
|
+
.response(new_response_handler
|
59
|
+
.is_response_void(true)
|
60
|
+
.is_api_response(true)
|
61
|
+
.local_error('401',
|
62
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
63
|
+
' token or\nthe access token has expired. You should'\
|
64
|
+
' re-authenticate the user.\n",
|
65
|
+
UnauthorizedException)
|
66
|
+
.local_error('403',
|
67
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
68
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
69
|
+
' won't help here.\n",
|
70
|
+
ForbiddenException)
|
71
|
+
.local_error('429',
|
72
|
+
"The app has exceeded its rate limits.\n",
|
73
|
+
TooManyRequestsException))
|
74
|
+
.execute
|
75
|
+
end
|
76
|
+
|
77
|
+
# Get information about a user’s available Spotify Connect devices. Some
|
78
|
+
# device models are not supported and will not be listed in the API
|
79
|
+
# response.
|
80
|
+
# @return [ManyDevices] response from the API call
|
81
|
+
def get_a_users_available_devices
|
82
|
+
new_api_call_builder
|
83
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
84
|
+
'/me/player/devices',
|
85
|
+
Server::DEFAULT)
|
86
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
87
|
+
.auth(Single.new('oauth_2_0')))
|
88
|
+
.response(new_response_handler
|
89
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
90
|
+
.deserialize_into(ManyDevices.method(:from_hash))
|
91
|
+
.is_api_response(true)
|
92
|
+
.local_error('401',
|
93
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
94
|
+
' token or\nthe access token has expired. You should'\
|
95
|
+
' re-authenticate the user.\n",
|
96
|
+
UnauthorizedException)
|
97
|
+
.local_error('403',
|
98
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
99
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
100
|
+
' won't help here.\n",
|
101
|
+
ForbiddenException)
|
102
|
+
.local_error('429',
|
103
|
+
"The app has exceeded its rate limits.\n",
|
104
|
+
TooManyRequestsException))
|
105
|
+
.execute
|
106
|
+
end
|
107
|
+
|
108
|
+
# Get the object currently being played on the user's Spotify account.
|
109
|
+
# @param [String] market Optional parameter: Example:
|
110
|
+
# @param [String] additional_types Optional parameter: Example:
|
111
|
+
# @return [CurrentlyPlayingObject] response from the API call
|
112
|
+
def get_the_users_currently_playing_track(market: nil,
|
113
|
+
additional_types: nil)
|
114
|
+
new_api_call_builder
|
115
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
116
|
+
'/me/player/currently-playing',
|
117
|
+
Server::DEFAULT)
|
118
|
+
.query_param(new_parameter(market, key: 'market'))
|
119
|
+
.query_param(new_parameter(additional_types, key: 'additional_types'))
|
120
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
121
|
+
.auth(Single.new('oauth_2_0')))
|
122
|
+
.response(new_response_handler
|
123
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
124
|
+
.deserialize_into(CurrentlyPlayingObject.method(:from_hash))
|
125
|
+
.is_api_response(true)
|
126
|
+
.local_error('401',
|
127
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
128
|
+
' token or\nthe access token has expired. You should'\
|
129
|
+
' re-authenticate the user.\n",
|
130
|
+
UnauthorizedException)
|
131
|
+
.local_error('403',
|
132
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
133
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
134
|
+
' won't help here.\n",
|
135
|
+
ForbiddenException)
|
136
|
+
.local_error('429',
|
137
|
+
"The app has exceeded its rate limits.\n",
|
138
|
+
TooManyRequestsException))
|
139
|
+
.execute
|
140
|
+
end
|
141
|
+
|
142
|
+
# Start a new context or resume current playback on the user's active
|
143
|
+
# device. This API only works for users who have Spotify Premium. The order
|
144
|
+
# of execution is not guaranteed when you use this API with other Player API
|
145
|
+
# endpoints.
|
146
|
+
# @param [String] device_id Optional parameter: Example:
|
147
|
+
# @param [MePlayerPlayRequest] body Optional parameter: Example:
|
148
|
+
# @return [void] response from the API call
|
149
|
+
def start_a_users_playback(device_id: nil,
|
150
|
+
body: nil)
|
151
|
+
new_api_call_builder
|
152
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
153
|
+
'/me/player/play',
|
154
|
+
Server::DEFAULT)
|
155
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
156
|
+
.query_param(new_parameter(device_id, key: 'device_id'))
|
157
|
+
.body_param(new_parameter(body))
|
158
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
159
|
+
.auth(Single.new('oauth_2_0')))
|
160
|
+
.response(new_response_handler
|
161
|
+
.is_response_void(true)
|
162
|
+
.is_api_response(true)
|
163
|
+
.local_error('401',
|
164
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
165
|
+
' token or\nthe access token has expired. You should'\
|
166
|
+
' re-authenticate the user.\n",
|
167
|
+
UnauthorizedException)
|
168
|
+
.local_error('403',
|
169
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
170
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
171
|
+
' won't help here.\n",
|
172
|
+
ForbiddenException)
|
173
|
+
.local_error('429',
|
174
|
+
"The app has exceeded its rate limits.\n",
|
175
|
+
TooManyRequestsException))
|
176
|
+
.execute
|
177
|
+
end
|
178
|
+
|
179
|
+
# Pause playback on the user's account. This API only works for users who
|
180
|
+
# have Spotify Premium. The order of execution is not guaranteed when you
|
181
|
+
# use this API with other Player API endpoints.
|
182
|
+
# @param [String] device_id Optional parameter: Example:
|
183
|
+
# @return [void] response from the API call
|
184
|
+
def pause_a_users_playback(device_id: nil)
|
185
|
+
new_api_call_builder
|
186
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
187
|
+
'/me/player/pause',
|
188
|
+
Server::DEFAULT)
|
189
|
+
.query_param(new_parameter(device_id, key: 'device_id'))
|
190
|
+
.auth(Single.new('oauth_2_0')))
|
191
|
+
.response(new_response_handler
|
192
|
+
.is_response_void(true)
|
193
|
+
.is_api_response(true)
|
194
|
+
.local_error('401',
|
195
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
196
|
+
' token or\nthe access token has expired. You should'\
|
197
|
+
' re-authenticate the user.\n",
|
198
|
+
UnauthorizedException)
|
199
|
+
.local_error('403',
|
200
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
201
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
202
|
+
' won't help here.\n",
|
203
|
+
ForbiddenException)
|
204
|
+
.local_error('429',
|
205
|
+
"The app has exceeded its rate limits.\n",
|
206
|
+
TooManyRequestsException))
|
207
|
+
.execute
|
208
|
+
end
|
209
|
+
|
210
|
+
# Skips to next track in the user’s queue. This API only works for users who
|
211
|
+
# have Spotify Premium. The order of execution is not guaranteed when you
|
212
|
+
# use this API with other Player API endpoints.
|
213
|
+
# @param [String] device_id Optional parameter: Example:
|
214
|
+
# @return [void] response from the API call
|
215
|
+
def skip_users_playback_to_next_track(device_id: nil)
|
216
|
+
new_api_call_builder
|
217
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
218
|
+
'/me/player/next',
|
219
|
+
Server::DEFAULT)
|
220
|
+
.query_param(new_parameter(device_id, key: 'device_id'))
|
221
|
+
.auth(Single.new('oauth_2_0')))
|
222
|
+
.response(new_response_handler
|
223
|
+
.is_response_void(true)
|
224
|
+
.is_api_response(true)
|
225
|
+
.local_error('401',
|
226
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
227
|
+
' token or\nthe access token has expired. You should'\
|
228
|
+
' re-authenticate the user.\n",
|
229
|
+
UnauthorizedException)
|
230
|
+
.local_error('403',
|
231
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
232
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
233
|
+
' won't help here.\n",
|
234
|
+
ForbiddenException)
|
235
|
+
.local_error('429',
|
236
|
+
"The app has exceeded its rate limits.\n",
|
237
|
+
TooManyRequestsException))
|
238
|
+
.execute
|
239
|
+
end
|
240
|
+
|
241
|
+
# Skips to previous track in the user’s queue. This API only works for users
|
242
|
+
# who have Spotify Premium. The order of execution is not guaranteed when
|
243
|
+
# you use this API with other Player API endpoints.
|
244
|
+
# @param [String] device_id Optional parameter: Example:
|
245
|
+
# @return [void] response from the API call
|
246
|
+
def skip_users_playback_to_previous_track(device_id: nil)
|
247
|
+
new_api_call_builder
|
248
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
249
|
+
'/me/player/previous',
|
250
|
+
Server::DEFAULT)
|
251
|
+
.query_param(new_parameter(device_id, key: 'device_id'))
|
252
|
+
.auth(Single.new('oauth_2_0')))
|
253
|
+
.response(new_response_handler
|
254
|
+
.is_response_void(true)
|
255
|
+
.is_api_response(true)
|
256
|
+
.local_error('401',
|
257
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
258
|
+
' token or\nthe access token has expired. You should'\
|
259
|
+
' re-authenticate the user.\n",
|
260
|
+
UnauthorizedException)
|
261
|
+
.local_error('403',
|
262
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
263
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
264
|
+
' won't help here.\n",
|
265
|
+
ForbiddenException)
|
266
|
+
.local_error('429',
|
267
|
+
"The app has exceeded its rate limits.\n",
|
268
|
+
TooManyRequestsException))
|
269
|
+
.execute
|
270
|
+
end
|
271
|
+
|
272
|
+
# Seeks to the given position in the user’s currently playing track. This
|
273
|
+
# API only works for users who have Spotify Premium. The order of execution
|
274
|
+
# is not guaranteed when you use this API with other Player API endpoints.
|
275
|
+
# @param [Integer] position_ms Required parameter: Example:
|
276
|
+
# @param [String] device_id Optional parameter: Example:
|
277
|
+
# @return [void] response from the API call
|
278
|
+
def seek_to_position_in_currently_playing_track(position_ms,
|
279
|
+
device_id: nil)
|
280
|
+
new_api_call_builder
|
281
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
282
|
+
'/me/player/seek',
|
283
|
+
Server::DEFAULT)
|
284
|
+
.query_param(new_parameter(position_ms, key: 'position_ms'))
|
285
|
+
.query_param(new_parameter(device_id, key: 'device_id'))
|
286
|
+
.auth(Single.new('oauth_2_0')))
|
287
|
+
.response(new_response_handler
|
288
|
+
.is_response_void(true)
|
289
|
+
.is_api_response(true)
|
290
|
+
.local_error('401',
|
291
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
292
|
+
' token or\nthe access token has expired. You should'\
|
293
|
+
' re-authenticate the user.\n",
|
294
|
+
UnauthorizedException)
|
295
|
+
.local_error('403',
|
296
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
297
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
298
|
+
' won't help here.\n",
|
299
|
+
ForbiddenException)
|
300
|
+
.local_error('429',
|
301
|
+
"The app has exceeded its rate limits.\n",
|
302
|
+
TooManyRequestsException))
|
303
|
+
.execute
|
304
|
+
end
|
305
|
+
|
306
|
+
# Set the repeat mode for the user's playback. This API only works for users
|
307
|
+
# who have Spotify Premium. The order of execution is not guaranteed when
|
308
|
+
# you use this API with other Player API endpoints.
|
309
|
+
# @param [String] state Required parameter: Example:
|
310
|
+
# @param [String] device_id Optional parameter: Example:
|
311
|
+
# @return [void] response from the API call
|
312
|
+
def set_repeat_mode_on_users_playback(state,
|
313
|
+
device_id: nil)
|
314
|
+
new_api_call_builder
|
315
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
316
|
+
'/me/player/repeat',
|
317
|
+
Server::DEFAULT)
|
318
|
+
.query_param(new_parameter(state, key: 'state'))
|
319
|
+
.query_param(new_parameter(device_id, key: 'device_id'))
|
320
|
+
.auth(Single.new('oauth_2_0')))
|
321
|
+
.response(new_response_handler
|
322
|
+
.is_response_void(true)
|
323
|
+
.is_api_response(true)
|
324
|
+
.local_error('401',
|
325
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
326
|
+
' token or\nthe access token has expired. You should'\
|
327
|
+
' re-authenticate the user.\n",
|
328
|
+
UnauthorizedException)
|
329
|
+
.local_error('403',
|
330
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
331
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
332
|
+
' won't help here.\n",
|
333
|
+
ForbiddenException)
|
334
|
+
.local_error('429',
|
335
|
+
"The app has exceeded its rate limits.\n",
|
336
|
+
TooManyRequestsException))
|
337
|
+
.execute
|
338
|
+
end
|
339
|
+
|
340
|
+
# Set the volume for the user’s current playback device. This API only works
|
341
|
+
# for users who have Spotify Premium. The order of execution is not
|
342
|
+
# guaranteed when you use this API with other Player API endpoints.
|
343
|
+
# @param [Integer] volume_percent Required parameter: Example:
|
344
|
+
# @param [String] device_id Optional parameter: Example:
|
345
|
+
# @return [void] response from the API call
|
346
|
+
def set_volume_for_users_playback(volume_percent,
|
347
|
+
device_id: nil)
|
348
|
+
new_api_call_builder
|
349
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
350
|
+
'/me/player/volume',
|
351
|
+
Server::DEFAULT)
|
352
|
+
.query_param(new_parameter(volume_percent, key: 'volume_percent'))
|
353
|
+
.query_param(new_parameter(device_id, key: 'device_id'))
|
354
|
+
.auth(Single.new('oauth_2_0')))
|
355
|
+
.response(new_response_handler
|
356
|
+
.is_response_void(true)
|
357
|
+
.is_api_response(true)
|
358
|
+
.local_error('401',
|
359
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
360
|
+
' token or\nthe access token has expired. You should'\
|
361
|
+
' re-authenticate the user.\n",
|
362
|
+
UnauthorizedException)
|
363
|
+
.local_error('403',
|
364
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
365
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
366
|
+
' won't help here.\n",
|
367
|
+
ForbiddenException)
|
368
|
+
.local_error('429',
|
369
|
+
"The app has exceeded its rate limits.\n",
|
370
|
+
TooManyRequestsException))
|
371
|
+
.execute
|
372
|
+
end
|
373
|
+
|
374
|
+
# Toggle shuffle on or off for user’s playback. This API only works for
|
375
|
+
# users who have Spotify Premium. The order of execution is not guaranteed
|
376
|
+
# when you use this API with other Player API endpoints.
|
377
|
+
# @param [TrueClass | FalseClass] state Required parameter: Example:
|
378
|
+
# @param [String] device_id Optional parameter: Example:
|
379
|
+
# @return [void] response from the API call
|
380
|
+
def toggle_shuffle_for_users_playback(state,
|
381
|
+
device_id: nil)
|
382
|
+
new_api_call_builder
|
383
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
384
|
+
'/me/player/shuffle',
|
385
|
+
Server::DEFAULT)
|
386
|
+
.query_param(new_parameter(state, key: 'state'))
|
387
|
+
.query_param(new_parameter(device_id, key: 'device_id'))
|
388
|
+
.auth(Single.new('oauth_2_0')))
|
389
|
+
.response(new_response_handler
|
390
|
+
.is_response_void(true)
|
391
|
+
.is_api_response(true)
|
392
|
+
.local_error('401',
|
393
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
394
|
+
' token or\nthe access token has expired. You should'\
|
395
|
+
' re-authenticate the user.\n",
|
396
|
+
UnauthorizedException)
|
397
|
+
.local_error('403',
|
398
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
399
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
400
|
+
' won't help here.\n",
|
401
|
+
ForbiddenException)
|
402
|
+
.local_error('429',
|
403
|
+
"The app has exceeded its rate limits.\n",
|
404
|
+
TooManyRequestsException))
|
405
|
+
.execute
|
406
|
+
end
|
407
|
+
|
408
|
+
# Get tracks from the current user's recently played tracks.
|
409
|
+
# _**Note**: Currently doesn't support podcast episodes._
|
410
|
+
# @param [Integer] limit Optional parameter: Example:20
|
411
|
+
# @param [Integer] after Optional parameter: Example:
|
412
|
+
# @param [Integer] before Optional parameter: Example:
|
413
|
+
# @return [CursorPagingPlayHistoryObject] response from the API call
|
414
|
+
def get_recently_played(limit: 20,
|
415
|
+
after: nil,
|
416
|
+
before: nil)
|
417
|
+
new_api_call_builder
|
418
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
419
|
+
'/me/player/recently-played',
|
420
|
+
Server::DEFAULT)
|
421
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
422
|
+
.query_param(new_parameter(after, key: 'after'))
|
423
|
+
.query_param(new_parameter(before, key: 'before'))
|
424
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
425
|
+
.auth(Single.new('oauth_2_0')))
|
426
|
+
.response(new_response_handler
|
427
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
428
|
+
.deserialize_into(CursorPagingPlayHistoryObject.method(:from_hash))
|
429
|
+
.is_api_response(true)
|
430
|
+
.local_error('401',
|
431
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
432
|
+
' token or\nthe access token has expired. You should'\
|
433
|
+
' re-authenticate the user.\n",
|
434
|
+
UnauthorizedException)
|
435
|
+
.local_error('403',
|
436
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
437
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
438
|
+
' won't help here.\n",
|
439
|
+
ForbiddenException)
|
440
|
+
.local_error('429',
|
441
|
+
"The app has exceeded its rate limits.\n",
|
442
|
+
TooManyRequestsException))
|
443
|
+
.execute
|
444
|
+
end
|
445
|
+
|
446
|
+
# Get the list of objects that make up the user's queue.
|
447
|
+
# @return [QueueObject] response from the API call
|
448
|
+
def get_queue
|
449
|
+
new_api_call_builder
|
450
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
451
|
+
'/me/player/queue',
|
452
|
+
Server::DEFAULT)
|
453
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
454
|
+
.auth(Single.new('oauth_2_0')))
|
455
|
+
.response(new_response_handler
|
456
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
457
|
+
.deserialize_into(QueueObject.method(:from_hash))
|
458
|
+
.is_api_response(true)
|
459
|
+
.local_error('401',
|
460
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
461
|
+
' token or\nthe access token has expired. You should'\
|
462
|
+
' re-authenticate the user.\n",
|
463
|
+
UnauthorizedException)
|
464
|
+
.local_error('403',
|
465
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
466
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
467
|
+
' won't help here.\n",
|
468
|
+
ForbiddenException)
|
469
|
+
.local_error('429',
|
470
|
+
"The app has exceeded its rate limits.\n",
|
471
|
+
TooManyRequestsException))
|
472
|
+
.execute
|
473
|
+
end
|
474
|
+
|
475
|
+
# Add an item to the end of the user's current playback queue. This API only
|
476
|
+
# works for users who have Spotify Premium. The order of execution is not
|
477
|
+
# guaranteed when you use this API with other Player API endpoints.
|
478
|
+
# @param [String] uri Required parameter: Example:
|
479
|
+
# @param [String] device_id Optional parameter: Example:
|
480
|
+
# @return [void] response from the API call
|
481
|
+
def add_to_queue(uri,
|
482
|
+
device_id: nil)
|
483
|
+
new_api_call_builder
|
484
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
485
|
+
'/me/player/queue',
|
486
|
+
Server::DEFAULT)
|
487
|
+
.query_param(new_parameter(uri, key: 'uri'))
|
488
|
+
.query_param(new_parameter(device_id, key: 'device_id'))
|
489
|
+
.auth(Single.new('oauth_2_0')))
|
490
|
+
.response(new_response_handler
|
491
|
+
.is_response_void(true)
|
492
|
+
.is_api_response(true)
|
493
|
+
.local_error('401',
|
494
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
495
|
+
' token or\nthe access token has expired. You should'\
|
496
|
+
' re-authenticate the user.\n",
|
497
|
+
UnauthorizedException)
|
498
|
+
.local_error('403',
|
499
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
500
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
501
|
+
' won't help here.\n",
|
502
|
+
ForbiddenException)
|
503
|
+
.local_error('429',
|
504
|
+
"The app has exceeded its rate limits.\n",
|
505
|
+
TooManyRequestsException))
|
506
|
+
.execute
|
507
|
+
end
|
508
|
+
end
|
509
|
+
end
|