spotify-apimatic-sdk 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. spotify_apimatic_sdk-1.0.0.dist-info/METADATA +150 -0
  2. spotify_apimatic_sdk-1.0.0.dist-info/RECORD +186 -0
  3. spotify_apimatic_sdk-1.0.0.dist-info/WHEEL +5 -0
  4. spotify_apimatic_sdk-1.0.0.dist-info/licenses/LICENSE +30 -0
  5. spotify_apimatic_sdk-1.0.0.dist-info/top_level.txt +1 -0
  6. spotifywebapi/__init__.py +12 -0
  7. spotifywebapi/api_helper.py +19 -0
  8. spotifywebapi/configuration.py +318 -0
  9. spotifywebapi/controllers/__init__.py +20 -0
  10. spotifywebapi/controllers/albums_controller.py +498 -0
  11. spotifywebapi/controllers/artists_controller.py +327 -0
  12. spotifywebapi/controllers/audiobooks_controller.py +441 -0
  13. spotifywebapi/controllers/base_controller.py +67 -0
  14. spotifywebapi/controllers/categories_controller.py +161 -0
  15. spotifywebapi/controllers/chapters_controller.py +157 -0
  16. spotifywebapi/controllers/episodes_controller.py +390 -0
  17. spotifywebapi/controllers/genres_controller.py +84 -0
  18. spotifywebapi/controllers/markets_controller.py +82 -0
  19. spotifywebapi/controllers/o_auth_authorization_controller.py +156 -0
  20. spotifywebapi/controllers/player_controller.py +807 -0
  21. spotifywebapi/controllers/playlists_controller.py +851 -0
  22. spotifywebapi/controllers/search_controller.py +123 -0
  23. spotifywebapi/controllers/shows_controller.py +439 -0
  24. spotifywebapi/controllers/tracks_controller.py +821 -0
  25. spotifywebapi/controllers/users_controller.py +649 -0
  26. spotifywebapi/exceptions/__init__.py +11 -0
  27. spotifywebapi/exceptions/api_exception.py +36 -0
  28. spotifywebapi/exceptions/bad_request_exception.py +56 -0
  29. spotifywebapi/exceptions/forbidden_exception.py +56 -0
  30. spotifywebapi/exceptions/not_found_exception.py +56 -0
  31. spotifywebapi/exceptions/o_auth_provider_exception.py +73 -0
  32. spotifywebapi/exceptions/too_many_requests_exception.py +56 -0
  33. spotifywebapi/exceptions/unauthorized_exception.py +56 -0
  34. spotifywebapi/http/__init__.py +11 -0
  35. spotifywebapi/http/api_response.py +67 -0
  36. spotifywebapi/http/auth/__init__.py +5 -0
  37. spotifywebapi/http/auth/o_auth_2.py +336 -0
  38. spotifywebapi/http/http_call_back.py +20 -0
  39. spotifywebapi/http/http_client_provider.py +23 -0
  40. spotifywebapi/http/http_method_enum.py +25 -0
  41. spotifywebapi/http/http_request.py +55 -0
  42. spotifywebapi/http/http_response.py +45 -0
  43. spotifywebapi/http/proxy_settings.py +50 -0
  44. spotifywebapi/models/__init__.py +142 -0
  45. spotifywebapi/models/album_base.py +264 -0
  46. spotifywebapi/models/album_group_enum.py +51 -0
  47. spotifywebapi/models/album_object.py +375 -0
  48. spotifywebapi/models/album_restriction_object.py +109 -0
  49. spotifywebapi/models/album_type_enum.py +62 -0
  50. spotifywebapi/models/artist_discography_album_object.py +298 -0
  51. spotifywebapi/models/artist_object.py +335 -0
  52. spotifywebapi/models/audio_analysis_object.py +266 -0
  53. spotifywebapi/models/audio_features_object.py +518 -0
  54. spotifywebapi/models/audiobook_base.py +353 -0
  55. spotifywebapi/models/audiobook_object.py +369 -0
  56. spotifywebapi/models/author_object.py +85 -0
  57. spotifywebapi/models/categories.py +162 -0
  58. spotifywebapi/models/category_object.py +117 -0
  59. spotifywebapi/models/chapter_base.py +392 -0
  60. spotifywebapi/models/chapter_object.py +408 -0
  61. spotifywebapi/models/chapter_restriction_object.py +113 -0
  62. spotifywebapi/models/context_object.py +181 -0
  63. spotifywebapi/models/copyright_object.py +130 -0
  64. spotifywebapi/models/currently_playing_context_object.py +314 -0
  65. spotifywebapi/models/currently_playing_object.py +241 -0
  66. spotifywebapi/models/cursor_object.py +108 -0
  67. spotifywebapi/models/cursor_paged_artists.py +75 -0
  68. spotifywebapi/models/cursor_paging_object.py +183 -0
  69. spotifywebapi/models/cursor_paging_play_history_object.py +214 -0
  70. spotifywebapi/models/cursor_paging_simplified_artist_object.py +213 -0
  71. spotifywebapi/models/device_object.py +278 -0
  72. spotifywebapi/models/disallows_object.py +314 -0
  73. spotifywebapi/models/episode_base.py +394 -0
  74. spotifywebapi/models/episode_object.py +665 -0
  75. spotifywebapi/models/episode_restriction_object.py +112 -0
  76. spotifywebapi/models/error_object.py +85 -0
  77. spotifywebapi/models/explicit_content_settings_object.py +110 -0
  78. spotifywebapi/models/external_id_object.py +156 -0
  79. spotifywebapi/models/external_url_object.py +107 -0
  80. spotifywebapi/models/followers_object.py +134 -0
  81. spotifywebapi/models/image_object.py +168 -0
  82. spotifywebapi/models/include_external_enum.py +45 -0
  83. spotifywebapi/models/item_type_1_enum.py +56 -0
  84. spotifywebapi/models/item_type_2_enum.py +45 -0
  85. spotifywebapi/models/item_type_3_enum.py +45 -0
  86. spotifywebapi/models/item_type_enum.py +58 -0
  87. spotifywebapi/models/linked_track_object.py +205 -0
  88. spotifywebapi/models/many_albums.py +76 -0
  89. spotifywebapi/models/many_artists.py +76 -0
  90. spotifywebapi/models/many_audio_features.py +77 -0
  91. spotifywebapi/models/many_audiobooks.py +77 -0
  92. spotifywebapi/models/many_chapters.py +77 -0
  93. spotifywebapi/models/many_devices.py +76 -0
  94. spotifywebapi/models/many_episodes.py +77 -0
  95. spotifywebapi/models/many_genres.py +69 -0
  96. spotifywebapi/models/many_simplified_shows.py +74 -0
  97. spotifywebapi/models/many_tracks.py +76 -0
  98. spotifywebapi/models/markets.py +85 -0
  99. spotifywebapi/models/me_albums_request.py +90 -0
  100. spotifywebapi/models/me_episodes_request.py +73 -0
  101. spotifywebapi/models/me_episodes_request_1.py +89 -0
  102. spotifywebapi/models/me_following_request.py +74 -0
  103. spotifywebapi/models/me_following_request_1.py +90 -0
  104. spotifywebapi/models/me_player_play_request.py +165 -0
  105. spotifywebapi/models/me_player_request.py +103 -0
  106. spotifywebapi/models/me_shows_request.py +89 -0
  107. spotifywebapi/models/me_tracks_request.py +74 -0
  108. spotifywebapi/models/me_tracks_request_1.py +90 -0
  109. spotifywebapi/models/meta.py +227 -0
  110. spotifywebapi/models/mode_enum.py +52 -0
  111. spotifywebapi/models/narrator_object.py +85 -0
  112. spotifywebapi/models/o_auth_provider_error_enum.py +67 -0
  113. spotifywebapi/models/o_auth_scope_enum.py +98 -0
  114. spotifywebapi/models/o_auth_token.py +113 -0
  115. spotifywebapi/models/paged_albums.py +75 -0
  116. spotifywebapi/models/paged_categories.py +74 -0
  117. spotifywebapi/models/paging_artist_discography_album_object.py +163 -0
  118. spotifywebapi/models/paging_artist_object.py +162 -0
  119. spotifywebapi/models/paging_featured_playlist_object.py +113 -0
  120. spotifywebapi/models/paging_object.py +142 -0
  121. spotifywebapi/models/paging_playlist_object.py +163 -0
  122. spotifywebapi/models/paging_playlist_track_object.py +163 -0
  123. spotifywebapi/models/paging_saved_album_object.py +163 -0
  124. spotifywebapi/models/paging_saved_audiobook_object.py +163 -0
  125. spotifywebapi/models/paging_saved_episode_object.py +163 -0
  126. spotifywebapi/models/paging_saved_show_object.py +163 -0
  127. spotifywebapi/models/paging_saved_track_object.py +163 -0
  128. spotifywebapi/models/paging_simplified_album_object.py +163 -0
  129. spotifywebapi/models/paging_simplified_audiobook_object.py +162 -0
  130. spotifywebapi/models/paging_simplified_chapter_object.py +162 -0
  131. spotifywebapi/models/paging_simplified_episode_object.py +162 -0
  132. spotifywebapi/models/paging_simplified_show_object.py +160 -0
  133. spotifywebapi/models/paging_simplified_track_object.py +163 -0
  134. spotifywebapi/models/paging_track_object.py +162 -0
  135. spotifywebapi/models/play_history_object.py +141 -0
  136. spotifywebapi/models/playlist_object.py +425 -0
  137. spotifywebapi/models/playlist_owner_object.py +238 -0
  138. spotifywebapi/models/playlist_snapshot_id.py +85 -0
  139. spotifywebapi/models/playlist_track_object.py +171 -0
  140. spotifywebapi/models/playlist_tracks_ref_object.py +109 -0
  141. spotifywebapi/models/playlist_user_object.py +231 -0
  142. spotifywebapi/models/playlists_followers_request.py +86 -0
  143. spotifywebapi/models/playlists_request.py +160 -0
  144. spotifywebapi/models/playlists_tracks_request.py +121 -0
  145. spotifywebapi/models/playlists_tracks_request_1.py +188 -0
  146. spotifywebapi/models/playlists_tracks_request_2.py +109 -0
  147. spotifywebapi/models/private_user_object.py +379 -0
  148. spotifywebapi/models/public_user_object.py +268 -0
  149. spotifywebapi/models/queue_object.py +118 -0
  150. spotifywebapi/models/reason_enum.py +65 -0
  151. spotifywebapi/models/recommendation_seed_object.py +208 -0
  152. spotifywebapi/models/recommendations_object.py +96 -0
  153. spotifywebapi/models/release_date_precision_enum.py +62 -0
  154. spotifywebapi/models/resume_point_object.py +131 -0
  155. spotifywebapi/models/saved_album_object.py +118 -0
  156. spotifywebapi/models/saved_audiobook_object.py +118 -0
  157. spotifywebapi/models/saved_episode_object.py +116 -0
  158. spotifywebapi/models/saved_show_object.py +116 -0
  159. spotifywebapi/models/saved_track_object.py +118 -0
  160. spotifywebapi/models/search_items.py +256 -0
  161. spotifywebapi/models/section_object.py +362 -0
  162. spotifywebapi/models/segment_object.py +307 -0
  163. spotifywebapi/models/show_base.py +550 -0
  164. spotifywebapi/models/show_object.py +319 -0
  165. spotifywebapi/models/simplified_album_object.py +468 -0
  166. spotifywebapi/models/simplified_artist_object.py +228 -0
  167. spotifywebapi/models/simplified_playlist_object.py +398 -0
  168. spotifywebapi/models/simplified_track_object.py +494 -0
  169. spotifywebapi/models/time_interval_object.py +132 -0
  170. spotifywebapi/models/track.py +697 -0
  171. spotifywebapi/models/track_1.py +85 -0
  172. spotifywebapi/models/track_object.py +605 -0
  173. spotifywebapi/models/track_restriction_object.py +112 -0
  174. spotifywebapi/models/type_2_enum.py +56 -0
  175. spotifywebapi/models/type_3_enum.py +56 -0
  176. spotifywebapi/models/type_4_enum.py +56 -0
  177. spotifywebapi/models/type_5_enum.py +56 -0
  178. spotifywebapi/models/type_6_enum.py +56 -0
  179. spotifywebapi/models/type_8_enum.py +42 -0
  180. spotifywebapi/models/type_9_enum.py +42 -0
  181. spotifywebapi/models/type_enum.py +56 -0
  182. spotifywebapi/models/users_playlists_request.py +154 -0
  183. spotifywebapi/spotifywebapi_client.py +198 -0
  184. spotifywebapi/utilities/__init__.py +6 -0
  185. spotifywebapi/utilities/file_wrapper.py +45 -0
  186. spotifywebapi/utilities/union_type_lookup.py +113 -0
@@ -0,0 +1,807 @@
1
+ """spotifywebapi.
2
+
3
+ This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
4
+ """
5
+
6
+ # ruff: noqa: D410, E501, E101, D206
7
+ from apimatic_core.authentication.multiple.single_auth import (
8
+ Single,
9
+ )
10
+ from apimatic_core.request_builder import RequestBuilder
11
+ from apimatic_core.response_handler import ResponseHandler
12
+ from apimatic_core.types.parameter import Parameter
13
+
14
+ from spotifywebapi.api_helper import APIHelper
15
+ from spotifywebapi.configuration import Server
16
+ from spotifywebapi.controllers.base_controller import (
17
+ BaseController,
18
+ )
19
+ from spotifywebapi.exceptions.forbidden_exception import (
20
+ ForbiddenException,
21
+ )
22
+ from spotifywebapi.exceptions.too_many_requests_exception import (
23
+ TooManyRequestsException,
24
+ )
25
+ from spotifywebapi.exceptions.unauthorized_exception import (
26
+ UnauthorizedException,
27
+ )
28
+ from spotifywebapi.http.http_method_enum import (
29
+ HttpMethodEnum,
30
+ )
31
+ from spotifywebapi.models.currently_playing_context_object import (
32
+ CurrentlyPlayingContextObject,
33
+ )
34
+ from spotifywebapi.models.currently_playing_object import (
35
+ CurrentlyPlayingObject,
36
+ )
37
+ from spotifywebapi.models.cursor_paging_play_history_object import (
38
+ CursorPagingPlayHistoryObject,
39
+ )
40
+ from spotifywebapi.models.many_devices import (
41
+ ManyDevices,
42
+ )
43
+ from spotifywebapi.models.queue_object import (
44
+ QueueObject,
45
+ )
46
+
47
+
48
+ class PlayerController(BaseController):
49
+ """A Controller to access Endpoints in the spotifywebapi API."""
50
+
51
+ def __init__(self, config):
52
+ """Initialize PlayerController object."""
53
+ super(PlayerController, self).__init__(config)
54
+
55
+ def get_information_about_the_users_current_playback(self,
56
+ market=None,
57
+ additional_types=None):
58
+ """Perform a GET request to /me/player.
59
+
60
+ Get information about the user’s current playback state, including track or
61
+ episode, progress, and active device.
62
+
63
+ Args:
64
+ market (str, optional): The request query parameter.
65
+ additional_types (str, optional): The request query parameter.
66
+
67
+ Returns:
68
+ ApiResponse: An object with the response value as well as other useful
69
+ information such as status codes and headers. Information about
70
+ playback
71
+
72
+ Raises:
73
+ APIException: When an error occurs while fetching the data from the
74
+ remote API. This exception includes the HTTP Response code, an error
75
+ message, and the HTTP body that was received in the request.
76
+
77
+ """
78
+ return super().new_api_call_builder.request(
79
+ RequestBuilder().server(Server.DEFAULT)
80
+ .path("/me/player")
81
+ .http_method(HttpMethodEnum.GET)
82
+ .query_param(Parameter()
83
+ .key("market")
84
+ .value(market))
85
+ .query_param(Parameter()
86
+ .key("additional_types")
87
+ .value(additional_types))
88
+ .header_param(Parameter()
89
+ .key("accept")
90
+ .value("application/json"))
91
+ .auth(Single("oauth_2_0")),
92
+ ).response(
93
+ ResponseHandler()
94
+ .deserializer(APIHelper.json_deserialize)
95
+ .deserialize_into(CurrentlyPlayingContextObject.from_dictionary)
96
+ .is_api_response(True)
97
+ .local_error("401",
98
+ "Bad or expired token. This can happen if the user revoked a token or"
99
+ "\nthe access token has expired. You should re-authenticate the user."
100
+ "\n",
101
+ UnauthorizedException)
102
+ .local_error("403",
103
+ "Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
104
+ "...). Unfortunately, re-authenticating the user won't help here.\n",
105
+ ForbiddenException)
106
+ .local_error("429",
107
+ "The app has exceeded its rate limits.\n",
108
+ TooManyRequestsException),
109
+ ).execute()
110
+
111
+ def transfer_a_users_playback(self,
112
+ body=None):
113
+ """Perform a PUT request to /me/player.
114
+
115
+ Transfer playback to a new device and optionally begin playback. This API
116
+ only works for users who have Spotify Premium. The order of execution is not
117
+ guaranteed when you use this API with other Player API endpoints.
118
+
119
+ Args:
120
+ body (MePlayerRequest, optional): The request body parameter.
121
+
122
+ Returns:
123
+ ApiResponse: An object with the response value as well as other useful
124
+ information such as status codes and headers. Playback transferred
125
+
126
+ Raises:
127
+ APIException: When an error occurs while fetching the data from the
128
+ remote API. This exception includes the HTTP Response code, an error
129
+ message, and the HTTP body that was received in the request.
130
+
131
+ """
132
+ return super().new_api_call_builder.request(
133
+ RequestBuilder().server(Server.DEFAULT)
134
+ .path("/me/player")
135
+ .http_method(HttpMethodEnum.PUT)
136
+ .header_param(Parameter()
137
+ .key("Content-Type")
138
+ .value("application/json"))
139
+ .body_param(Parameter()
140
+ .value(body))
141
+ .body_serializer(APIHelper.json_serialize)
142
+ .auth(Single("oauth_2_0")),
143
+ ).response(
144
+ ResponseHandler()
145
+ .is_api_response(True)
146
+ .local_error("401",
147
+ "Bad or expired token. This can happen if the user revoked a token or"
148
+ "\nthe access token has expired. You should re-authenticate the user."
149
+ "\n",
150
+ UnauthorizedException)
151
+ .local_error("403",
152
+ "Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
153
+ "...). Unfortunately, re-authenticating the user won't help here.\n",
154
+ ForbiddenException)
155
+ .local_error("429",
156
+ "The app has exceeded its rate limits.\n",
157
+ TooManyRequestsException),
158
+ ).execute()
159
+
160
+ def get_a_users_available_devices(self):
161
+ """Perform a GET request to /me/player/devices.
162
+
163
+ Get information about a user’s available Spotify Connect devices. Some device
164
+ models are not supported and will not be listed in the API response.
165
+
166
+ Returns:
167
+ ApiResponse: An object with the response value as well as other useful
168
+ information such as status codes and headers. A set of devices
169
+
170
+ Raises:
171
+ APIException: When an error occurs while fetching the data from the
172
+ remote API. This exception includes the HTTP Response code, an error
173
+ message, and the HTTP body that was received in the request.
174
+
175
+ """
176
+ return super().new_api_call_builder.request(
177
+ RequestBuilder().server(Server.DEFAULT)
178
+ .path("/me/player/devices")
179
+ .http_method(HttpMethodEnum.GET)
180
+ .header_param(Parameter()
181
+ .key("accept")
182
+ .value("application/json"))
183
+ .auth(Single("oauth_2_0")),
184
+ ).response(
185
+ ResponseHandler()
186
+ .deserializer(APIHelper.json_deserialize)
187
+ .deserialize_into(ManyDevices.from_dictionary)
188
+ .is_api_response(True)
189
+ .local_error("401",
190
+ "Bad or expired token. This can happen if the user revoked a token or"
191
+ "\nthe access token has expired. You should re-authenticate the user."
192
+ "\n",
193
+ UnauthorizedException)
194
+ .local_error("403",
195
+ "Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
196
+ "...). Unfortunately, re-authenticating the user won't help here.\n",
197
+ ForbiddenException)
198
+ .local_error("429",
199
+ "The app has exceeded its rate limits.\n",
200
+ TooManyRequestsException),
201
+ ).execute()
202
+
203
+ def get_the_users_currently_playing_track(self,
204
+ market=None,
205
+ additional_types=None):
206
+ """Perform a GET request to /me/player/currently-playing.
207
+
208
+ Get the object currently being played on the user's Spotify account.
209
+
210
+ Args:
211
+ market (str, optional): The request query parameter.
212
+ additional_types (str, optional): The request query parameter.
213
+
214
+ Returns:
215
+ ApiResponse: An object with the response value as well as other useful
216
+ information such as status codes and headers. Information about the
217
+ currently playing track
218
+
219
+ Raises:
220
+ APIException: When an error occurs while fetching the data from the
221
+ remote API. This exception includes the HTTP Response code, an error
222
+ message, and the HTTP body that was received in the request.
223
+
224
+ """
225
+ return super().new_api_call_builder.request(
226
+ RequestBuilder().server(Server.DEFAULT)
227
+ .path("/me/player/currently-playing")
228
+ .http_method(HttpMethodEnum.GET)
229
+ .query_param(Parameter()
230
+ .key("market")
231
+ .value(market))
232
+ .query_param(Parameter()
233
+ .key("additional_types")
234
+ .value(additional_types))
235
+ .header_param(Parameter()
236
+ .key("accept")
237
+ .value("application/json"))
238
+ .auth(Single("oauth_2_0")),
239
+ ).response(
240
+ ResponseHandler()
241
+ .deserializer(APIHelper.json_deserialize)
242
+ .deserialize_into(CurrentlyPlayingObject.from_dictionary)
243
+ .is_api_response(True)
244
+ .local_error("401",
245
+ "Bad or expired token. This can happen if the user revoked a token or"
246
+ "\nthe access token has expired. You should re-authenticate the user."
247
+ "\n",
248
+ UnauthorizedException)
249
+ .local_error("403",
250
+ "Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
251
+ "...). Unfortunately, re-authenticating the user won't help here.\n",
252
+ ForbiddenException)
253
+ .local_error("429",
254
+ "The app has exceeded its rate limits.\n",
255
+ TooManyRequestsException),
256
+ ).execute()
257
+
258
+ def start_a_users_playback(self,
259
+ device_id=None,
260
+ body=None):
261
+ """Perform a PUT request to /me/player/play.
262
+
263
+ Start a new context or resume current playback on the user's active device.
264
+ This API only works for users who have Spotify Premium. The order of
265
+ execution is not guaranteed when you use this API with other Player API
266
+ endpoints.
267
+
268
+ Args:
269
+ device_id (str, optional): The request query parameter.
270
+ body (MePlayerPlayRequest, optional): The request body parameter.
271
+
272
+ Returns:
273
+ ApiResponse: An object with the response value as well as other useful
274
+ information such as status codes and headers. Playback started
275
+
276
+ Raises:
277
+ APIException: When an error occurs while fetching the data from the
278
+ remote API. This exception includes the HTTP Response code, an error
279
+ message, and the HTTP body that was received in the request.
280
+
281
+ """
282
+ return super().new_api_call_builder.request(
283
+ RequestBuilder().server(Server.DEFAULT)
284
+ .path("/me/player/play")
285
+ .http_method(HttpMethodEnum.PUT)
286
+ .header_param(Parameter()
287
+ .key("Content-Type")
288
+ .value("application/json"))
289
+ .query_param(Parameter()
290
+ .key("device_id")
291
+ .value(device_id))
292
+ .body_param(Parameter()
293
+ .value(body))
294
+ .body_serializer(APIHelper.json_serialize)
295
+ .auth(Single("oauth_2_0")),
296
+ ).response(
297
+ ResponseHandler()
298
+ .is_api_response(True)
299
+ .local_error("401",
300
+ "Bad or expired token. This can happen if the user revoked a token or"
301
+ "\nthe access token has expired. You should re-authenticate the user."
302
+ "\n",
303
+ UnauthorizedException)
304
+ .local_error("403",
305
+ "Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
306
+ "...). Unfortunately, re-authenticating the user won't help here.\n",
307
+ ForbiddenException)
308
+ .local_error("429",
309
+ "The app has exceeded its rate limits.\n",
310
+ TooManyRequestsException),
311
+ ).execute()
312
+
313
+ def pause_a_users_playback(self,
314
+ device_id=None):
315
+ """Perform a PUT request to /me/player/pause.
316
+
317
+ Pause playback on the user's account. This API only works for users who have
318
+ Spotify Premium. The order of execution is not guaranteed when you use this
319
+ API with other Player API endpoints.
320
+
321
+ Args:
322
+ device_id (str, optional): The request query parameter.
323
+
324
+ Returns:
325
+ ApiResponse: An object with the response value as well as other useful
326
+ information such as status codes and headers. Playback paused
327
+
328
+ Raises:
329
+ APIException: When an error occurs while fetching the data from the
330
+ remote API. This exception includes the HTTP Response code, an error
331
+ message, and the HTTP body that was received in the request.
332
+
333
+ """
334
+ return super().new_api_call_builder.request(
335
+ RequestBuilder().server(Server.DEFAULT)
336
+ .path("/me/player/pause")
337
+ .http_method(HttpMethodEnum.PUT)
338
+ .query_param(Parameter()
339
+ .key("device_id")
340
+ .value(device_id))
341
+ .auth(Single("oauth_2_0")),
342
+ ).response(
343
+ ResponseHandler()
344
+ .is_api_response(True)
345
+ .local_error("401",
346
+ "Bad or expired token. This can happen if the user revoked a token or"
347
+ "\nthe access token has expired. You should re-authenticate the user."
348
+ "\n",
349
+ UnauthorizedException)
350
+ .local_error("403",
351
+ "Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
352
+ "...). Unfortunately, re-authenticating the user won't help here.\n",
353
+ ForbiddenException)
354
+ .local_error("429",
355
+ "The app has exceeded its rate limits.\n",
356
+ TooManyRequestsException),
357
+ ).execute()
358
+
359
+ def skip_users_playback_to_next_track(self,
360
+ device_id=None):
361
+ """Perform a POST request to /me/player/next.
362
+
363
+ Skips to next track in the user’s queue. This API only works for users who
364
+ have Spotify Premium. The order of execution is not guaranteed when you use
365
+ this API with other Player API endpoints.
366
+
367
+ Args:
368
+ device_id (str, optional): The request query parameter.
369
+
370
+ Returns:
371
+ ApiResponse: An object with the response value as well as other useful
372
+ information such as status codes and headers. Command sent
373
+
374
+ Raises:
375
+ APIException: When an error occurs while fetching the data from the
376
+ remote API. This exception includes the HTTP Response code, an error
377
+ message, and the HTTP body that was received in the request.
378
+
379
+ """
380
+ return super().new_api_call_builder.request(
381
+ RequestBuilder().server(Server.DEFAULT)
382
+ .path("/me/player/next")
383
+ .http_method(HttpMethodEnum.POST)
384
+ .query_param(Parameter()
385
+ .key("device_id")
386
+ .value(device_id))
387
+ .auth(Single("oauth_2_0")),
388
+ ).response(
389
+ ResponseHandler()
390
+ .is_api_response(True)
391
+ .local_error("401",
392
+ "Bad or expired token. This can happen if the user revoked a token or"
393
+ "\nthe access token has expired. You should re-authenticate the user."
394
+ "\n",
395
+ UnauthorizedException)
396
+ .local_error("403",
397
+ "Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
398
+ "...). Unfortunately, re-authenticating the user won't help here.\n",
399
+ ForbiddenException)
400
+ .local_error("429",
401
+ "The app has exceeded its rate limits.\n",
402
+ TooManyRequestsException),
403
+ ).execute()
404
+
405
+ def skip_users_playback_to_previous_track(self,
406
+ device_id=None):
407
+ """Perform a POST request to /me/player/previous.
408
+
409
+ Skips to previous track in the user’s queue. This API only works for users
410
+ who have Spotify Premium. The order of execution is not guaranteed when you
411
+ use this API with other Player API endpoints.
412
+
413
+ Args:
414
+ device_id (str, optional): The request query parameter.
415
+
416
+ Returns:
417
+ ApiResponse: An object with the response value as well as other useful
418
+ information such as status codes and headers. Command sent
419
+
420
+ Raises:
421
+ APIException: When an error occurs while fetching the data from the
422
+ remote API. This exception includes the HTTP Response code, an error
423
+ message, and the HTTP body that was received in the request.
424
+
425
+ """
426
+ return super().new_api_call_builder.request(
427
+ RequestBuilder().server(Server.DEFAULT)
428
+ .path("/me/player/previous")
429
+ .http_method(HttpMethodEnum.POST)
430
+ .query_param(Parameter()
431
+ .key("device_id")
432
+ .value(device_id))
433
+ .auth(Single("oauth_2_0")),
434
+ ).response(
435
+ ResponseHandler()
436
+ .is_api_response(True)
437
+ .local_error("401",
438
+ "Bad or expired token. This can happen if the user revoked a token or"
439
+ "\nthe access token has expired. You should re-authenticate the user."
440
+ "\n",
441
+ UnauthorizedException)
442
+ .local_error("403",
443
+ "Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
444
+ "...). Unfortunately, re-authenticating the user won't help here.\n",
445
+ ForbiddenException)
446
+ .local_error("429",
447
+ "The app has exceeded its rate limits.\n",
448
+ TooManyRequestsException),
449
+ ).execute()
450
+
451
+ def seek_to_position_in_currently_playing_track(self,
452
+ position_ms,
453
+ device_id=None):
454
+ """Perform a PUT request to /me/player/seek.
455
+
456
+ Seeks to the given position in the user’s currently playing track. This API
457
+ only works for users who have Spotify Premium. The order of execution is not
458
+ guaranteed when you use this API with other Player API endpoints.
459
+
460
+ Args:
461
+ position_ms (int): The request query parameter.
462
+ device_id (str, optional): The request query parameter.
463
+
464
+ Returns:
465
+ ApiResponse: An object with the response value as well as other useful
466
+ information such as status codes and headers. Command sent
467
+
468
+ Raises:
469
+ APIException: When an error occurs while fetching the data from the
470
+ remote API. This exception includes the HTTP Response code, an error
471
+ message, and the HTTP body that was received in the request.
472
+
473
+ """
474
+ return super().new_api_call_builder.request(
475
+ RequestBuilder().server(Server.DEFAULT)
476
+ .path("/me/player/seek")
477
+ .http_method(HttpMethodEnum.PUT)
478
+ .query_param(Parameter()
479
+ .key("position_ms")
480
+ .value(position_ms))
481
+ .query_param(Parameter()
482
+ .key("device_id")
483
+ .value(device_id))
484
+ .auth(Single("oauth_2_0")),
485
+ ).response(
486
+ ResponseHandler()
487
+ .is_api_response(True)
488
+ .local_error("401",
489
+ "Bad or expired token. This can happen if the user revoked a token or"
490
+ "\nthe access token has expired. You should re-authenticate the user."
491
+ "\n",
492
+ UnauthorizedException)
493
+ .local_error("403",
494
+ "Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
495
+ "...). Unfortunately, re-authenticating the user won't help here.\n",
496
+ ForbiddenException)
497
+ .local_error("429",
498
+ "The app has exceeded its rate limits.\n",
499
+ TooManyRequestsException),
500
+ ).execute()
501
+
502
+ def set_repeat_mode_on_users_playback(self,
503
+ state,
504
+ device_id=None):
505
+ """Perform a PUT request to /me/player/repeat.
506
+
507
+ Set the repeat mode for the user's playback. This API only works for users
508
+ who have Spotify Premium. The order of execution is not guaranteed when you
509
+ use this API with other Player API endpoints.
510
+
511
+ Args:
512
+ state (str): The request query parameter.
513
+ device_id (str, optional): The request query parameter.
514
+
515
+ Returns:
516
+ ApiResponse: An object with the response value as well as other useful
517
+ information such as status codes and headers. Command sent
518
+
519
+ Raises:
520
+ APIException: When an error occurs while fetching the data from the
521
+ remote API. This exception includes the HTTP Response code, an error
522
+ message, and the HTTP body that was received in the request.
523
+
524
+ """
525
+ return super().new_api_call_builder.request(
526
+ RequestBuilder().server(Server.DEFAULT)
527
+ .path("/me/player/repeat")
528
+ .http_method(HttpMethodEnum.PUT)
529
+ .query_param(Parameter()
530
+ .key("state")
531
+ .value(state))
532
+ .query_param(Parameter()
533
+ .key("device_id")
534
+ .value(device_id))
535
+ .auth(Single("oauth_2_0")),
536
+ ).response(
537
+ ResponseHandler()
538
+ .is_api_response(True)
539
+ .local_error("401",
540
+ "Bad or expired token. This can happen if the user revoked a token or"
541
+ "\nthe access token has expired. You should re-authenticate the user."
542
+ "\n",
543
+ UnauthorizedException)
544
+ .local_error("403",
545
+ "Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
546
+ "...). Unfortunately, re-authenticating the user won't help here.\n",
547
+ ForbiddenException)
548
+ .local_error("429",
549
+ "The app has exceeded its rate limits.\n",
550
+ TooManyRequestsException),
551
+ ).execute()
552
+
553
+ def set_volume_for_users_playback(self,
554
+ volume_percent,
555
+ device_id=None):
556
+ """Perform a PUT request to /me/player/volume.
557
+
558
+ Set the volume for the user’s current playback device. This API only works
559
+ for users who have Spotify Premium. The order of execution is not guaranteed
560
+ when you use this API with other Player API endpoints.
561
+
562
+ Args:
563
+ volume_percent (int): The request query parameter.
564
+ device_id (str, optional): The request query parameter.
565
+
566
+ Returns:
567
+ ApiResponse: An object with the response value as well as other useful
568
+ information such as status codes and headers. Command sent
569
+
570
+ Raises:
571
+ APIException: When an error occurs while fetching the data from the
572
+ remote API. This exception includes the HTTP Response code, an error
573
+ message, and the HTTP body that was received in the request.
574
+
575
+ """
576
+ return super().new_api_call_builder.request(
577
+ RequestBuilder().server(Server.DEFAULT)
578
+ .path("/me/player/volume")
579
+ .http_method(HttpMethodEnum.PUT)
580
+ .query_param(Parameter()
581
+ .key("volume_percent")
582
+ .value(volume_percent))
583
+ .query_param(Parameter()
584
+ .key("device_id")
585
+ .value(device_id))
586
+ .auth(Single("oauth_2_0")),
587
+ ).response(
588
+ ResponseHandler()
589
+ .is_api_response(True)
590
+ .local_error("401",
591
+ "Bad or expired token. This can happen if the user revoked a token or"
592
+ "\nthe access token has expired. You should re-authenticate the user."
593
+ "\n",
594
+ UnauthorizedException)
595
+ .local_error("403",
596
+ "Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
597
+ "...). Unfortunately, re-authenticating the user won't help here.\n",
598
+ ForbiddenException)
599
+ .local_error("429",
600
+ "The app has exceeded its rate limits.\n",
601
+ TooManyRequestsException),
602
+ ).execute()
603
+
604
+ def toggle_shuffle_for_users_playback(self,
605
+ state,
606
+ device_id=None):
607
+ """Perform a PUT request to /me/player/shuffle.
608
+
609
+ Toggle shuffle on or off for user’s playback. This API only works for users
610
+ who have Spotify Premium. The order of execution is not guaranteed when you
611
+ use this API with other Player API endpoints.
612
+
613
+ Args:
614
+ state (bool): The request query parameter.
615
+ device_id (str, optional): The request query parameter.
616
+
617
+ Returns:
618
+ ApiResponse: An object with the response value as well as other useful
619
+ information such as status codes and headers. Command sent
620
+
621
+ Raises:
622
+ APIException: When an error occurs while fetching the data from the
623
+ remote API. This exception includes the HTTP Response code, an error
624
+ message, and the HTTP body that was received in the request.
625
+
626
+ """
627
+ return super().new_api_call_builder.request(
628
+ RequestBuilder().server(Server.DEFAULT)
629
+ .path("/me/player/shuffle")
630
+ .http_method(HttpMethodEnum.PUT)
631
+ .query_param(Parameter()
632
+ .key("state")
633
+ .value(state))
634
+ .query_param(Parameter()
635
+ .key("device_id")
636
+ .value(device_id))
637
+ .auth(Single("oauth_2_0")),
638
+ ).response(
639
+ ResponseHandler()
640
+ .is_api_response(True)
641
+ .local_error("401",
642
+ "Bad or expired token. This can happen if the user revoked a token or"
643
+ "\nthe access token has expired. You should re-authenticate the user."
644
+ "\n",
645
+ UnauthorizedException)
646
+ .local_error("403",
647
+ "Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
648
+ "...). Unfortunately, re-authenticating the user won't help here.\n",
649
+ ForbiddenException)
650
+ .local_error("429",
651
+ "The app has exceeded its rate limits.\n",
652
+ TooManyRequestsException),
653
+ ).execute()
654
+
655
+ def get_recently_played(self,
656
+ limit=20,
657
+ after=None,
658
+ before=None):
659
+ """Perform a GET request to /me/player/recently-played.
660
+
661
+ Get tracks from the current user's recently played tracks.
662
+ _**Note**: Currently doesn't support podcast episodes._
663
+
664
+ Args:
665
+ limit (int, optional): The request query parameter. Example: 20
666
+ after (int, optional): The request query parameter.
667
+ before (int, optional): The request query parameter.
668
+
669
+ Returns:
670
+ ApiResponse: An object with the response value as well as other useful
671
+ information such as status codes and headers. A paged set of tracks
672
+
673
+ Raises:
674
+ APIException: When an error occurs while fetching the data from the
675
+ remote API. This exception includes the HTTP Response code, an error
676
+ message, and the HTTP body that was received in the request.
677
+
678
+ """
679
+ return super().new_api_call_builder.request(
680
+ RequestBuilder().server(Server.DEFAULT)
681
+ .path("/me/player/recently-played")
682
+ .http_method(HttpMethodEnum.GET)
683
+ .query_param(Parameter()
684
+ .key("limit")
685
+ .value(limit))
686
+ .query_param(Parameter()
687
+ .key("after")
688
+ .value(after))
689
+ .query_param(Parameter()
690
+ .key("before")
691
+ .value(before))
692
+ .header_param(Parameter()
693
+ .key("accept")
694
+ .value("application/json"))
695
+ .auth(Single("oauth_2_0")),
696
+ ).response(
697
+ ResponseHandler()
698
+ .deserializer(APIHelper.json_deserialize)
699
+ .deserialize_into(CursorPagingPlayHistoryObject.from_dictionary)
700
+ .is_api_response(True)
701
+ .local_error("401",
702
+ "Bad or expired token. This can happen if the user revoked a token or"
703
+ "\nthe access token has expired. You should re-authenticate the user."
704
+ "\n",
705
+ UnauthorizedException)
706
+ .local_error("403",
707
+ "Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
708
+ "...). Unfortunately, re-authenticating the user won't help here.\n",
709
+ ForbiddenException)
710
+ .local_error("429",
711
+ "The app has exceeded its rate limits.\n",
712
+ TooManyRequestsException),
713
+ ).execute()
714
+
715
+ def get_queue(self):
716
+ """Perform a GET request to /me/player/queue.
717
+
718
+ Get the list of objects that make up the user's queue.
719
+
720
+ Returns:
721
+ ApiResponse: An object with the response value as well as other useful
722
+ information such as status codes and headers. Information about the
723
+ queue
724
+
725
+ Raises:
726
+ APIException: When an error occurs while fetching the data from the
727
+ remote API. This exception includes the HTTP Response code, an error
728
+ message, and the HTTP body that was received in the request.
729
+
730
+ """
731
+ return super().new_api_call_builder.request(
732
+ RequestBuilder().server(Server.DEFAULT)
733
+ .path("/me/player/queue")
734
+ .http_method(HttpMethodEnum.GET)
735
+ .header_param(Parameter()
736
+ .key("accept")
737
+ .value("application/json"))
738
+ .auth(Single("oauth_2_0")),
739
+ ).response(
740
+ ResponseHandler()
741
+ .deserializer(APIHelper.json_deserialize)
742
+ .deserialize_into(QueueObject.from_dictionary)
743
+ .is_api_response(True)
744
+ .local_error("401",
745
+ "Bad or expired token. This can happen if the user revoked a token or"
746
+ "\nthe access token has expired. You should re-authenticate the user."
747
+ "\n",
748
+ UnauthorizedException)
749
+ .local_error("403",
750
+ "Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
751
+ "...). Unfortunately, re-authenticating the user won't help here.\n",
752
+ ForbiddenException)
753
+ .local_error("429",
754
+ "The app has exceeded its rate limits.\n",
755
+ TooManyRequestsException),
756
+ ).execute()
757
+
758
+ def add_to_queue(self,
759
+ uri,
760
+ device_id=None):
761
+ """Perform a POST request to /me/player/queue.
762
+
763
+ Add an item to the end of the user's current playback queue. This API only
764
+ works for users who have Spotify Premium. The order of execution is not
765
+ guaranteed when you use this API with other Player API endpoints.
766
+
767
+ Args:
768
+ uri (str): The request query parameter.
769
+ device_id (str, optional): The request query parameter.
770
+
771
+ Returns:
772
+ ApiResponse: An object with the response value as well as other useful
773
+ information such as status codes and headers. Command received
774
+
775
+ Raises:
776
+ APIException: When an error occurs while fetching the data from the
777
+ remote API. This exception includes the HTTP Response code, an error
778
+ message, and the HTTP body that was received in the request.
779
+
780
+ """
781
+ return super().new_api_call_builder.request(
782
+ RequestBuilder().server(Server.DEFAULT)
783
+ .path("/me/player/queue")
784
+ .http_method(HttpMethodEnum.POST)
785
+ .query_param(Parameter()
786
+ .key("uri")
787
+ .value(uri))
788
+ .query_param(Parameter()
789
+ .key("device_id")
790
+ .value(device_id))
791
+ .auth(Single("oauth_2_0")),
792
+ ).response(
793
+ ResponseHandler()
794
+ .is_api_response(True)
795
+ .local_error("401",
796
+ "Bad or expired token. This can happen if the user revoked a token or"
797
+ "\nthe access token has expired. You should re-authenticate the user."
798
+ "\n",
799
+ UnauthorizedException)
800
+ .local_error("403",
801
+ "Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
802
+ "...). Unfortunately, re-authenticating the user won't help here.\n",
803
+ ForbiddenException)
804
+ .local_error("429",
805
+ "The app has exceeded its rate limits.\n",
806
+ TooManyRequestsException),
807
+ ).execute()