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,336 @@
1
+
2
+ """
3
+ spotifywebapi
4
+
5
+ This file was automatically generated by APIMATIC v3.0 (
6
+ https://www.apimatic.io ).
7
+ """
8
+
9
+ import os
10
+
11
+ from apimatic_core.authentication.header_auth import (
12
+ HeaderAuth,
13
+ )
14
+ from apimatic_core.utilities.auth_helper import (
15
+ AuthHelper,
16
+ )
17
+
18
+ from spotifywebapi.api_helper import APIHelper
19
+ from spotifywebapi.configuration import Server
20
+ from spotifywebapi.controllers.o_auth_authorization_controller import (
21
+ OAuthAuthorizationController,
22
+ )
23
+ from spotifywebapi.models.o_auth_token import (
24
+ OAuthToken,
25
+ )
26
+
27
+
28
+ class OAuth2(HeaderAuth):
29
+ """
30
+ An authentication handler that applies `AuthorizationCodeAuth` to
31
+ outgoing requests. It constructs the required credential values and integrates
32
+ with the core authentication framework.
33
+ """
34
+
35
+ @property
36
+ def error_message(self):
37
+ """Return reason about the authentication failure."""
38
+ return "AuthorizationCodeAuth: OAuthToken is undefined or expired."
39
+
40
+ def __init__(self, auth_credentials_model, config):
41
+ """
42
+ Initialize the authentication handler with credential data.
43
+
44
+ Args:
45
+ auth_credentials_model: The credentials object used to generate
46
+ the authorization header.
47
+ config: The configuration instance.
48
+
49
+ """
50
+ self._o_auth_client_id = auth_credentials_model.o_auth_client_id \
51
+ if auth_credentials_model is not None else None
52
+ self._o_auth_client_secret = auth_credentials_model.o_auth_client_secret \
53
+ if auth_credentials_model is not None else None
54
+ self._o_auth_redirect_uri = auth_credentials_model.o_auth_redirect_uri \
55
+ if auth_credentials_model is not None else None
56
+ if auth_credentials_model is not None \
57
+ and isinstance(auth_credentials_model.o_auth_token, OAuthToken):
58
+ self._o_auth_token = OAuthToken.from_dictionary(
59
+ APIHelper.to_dictionary(auth_credentials_model.o_auth_token))
60
+ else:
61
+ self._o_auth_token = auth_credentials_model.o_auth_token \
62
+ if auth_credentials_model is not None else None
63
+ if auth_credentials_model is not None \
64
+ and isinstance(auth_credentials_model.o_auth_scopes, list):
65
+ self._o_auth_scopes = auth_credentials_model.o_auth_scopes
66
+ else:
67
+ self._o_auth_scopes = None
68
+ self._config = config
69
+ self._o_auth_api = OAuthAuthorizationController(config)
70
+ auth_params = {}
71
+ if (isinstance(self._o_auth_token, OAuthToken)
72
+ and hasattr(self._o_auth_token, "access_token")):
73
+ auth_params = {"Authorization": f"Bearer {self._o_auth_token.access_token}"}
74
+ super().__init__(auth_params=auth_params)
75
+
76
+ def is_valid(self):
77
+ """
78
+ Validate credentials for authentication.
79
+
80
+ Returns:
81
+ bool: True if the credentials are valid, False otherwise.
82
+
83
+ """
84
+ return (self._o_auth_token and isinstance(self._o_auth_token, OAuthToken)
85
+ and not self.is_token_expired(self._o_auth_token))
86
+
87
+ def get_authorization_url(self, state=None, additional_params=None):
88
+ """
89
+ Build and return an authorization URL. The user is expected to
90
+ obtain an authorization code from this URL and then call the authorize
91
+ function with that authorization code.
92
+
93
+ Args:
94
+ state (str): An opaque state string.
95
+ additional_params (dict): Any additional query parameters
96
+ to be added to the URL.
97
+
98
+ Returns:
99
+ str: The authorization URL.
100
+
101
+ """
102
+ auth_url = self._config.get_base_uri(Server.AUTH_SERVER)
103
+ auth_url += "/authorize"
104
+ query_params = {
105
+ "response_type": "code",
106
+ "client_id": self._o_auth_client_id,
107
+ "redirect_uri": self._o_auth_redirect_uri,
108
+ }
109
+ if self._o_auth_scopes:
110
+ query_params["scope"] = " ".join(self._o_auth_scopes)
111
+ if state:
112
+ query_params["state"] = state
113
+ if additional_params:
114
+ query_params.update(additional_params)
115
+ auth_url = APIHelper.append_url_with_query_parameters(auth_url, query_params)
116
+ return APIHelper.clean_url(auth_url)
117
+
118
+ def build_basic_auth_header(self):
119
+ """
120
+ Build the basic auth header for endpoints in the
121
+ OAuth Authorization Controller.
122
+
123
+ Returns:
124
+ str: The value of the Authentication header.
125
+
126
+ """
127
+ encoded = AuthHelper.get_base64_encoded_value(
128
+ self._o_auth_client_id,
129
+ self._o_auth_client_secret,
130
+ )
131
+ return f"Basic {encoded}"
132
+
133
+ def fetch_token(self, auth_code, additional_params=None):
134
+ """
135
+ Execute call to fetch the OAuth token.
136
+
137
+ Args:
138
+ auth_code (str): The authentication code.
139
+ additional_params (dict): Any additional form parameters.
140
+
141
+ Returns:
142
+ OAuthToken: The OAuth token.
143
+
144
+ """
145
+ token = self._o_auth_api.request_token(
146
+ self.build_basic_auth_header(),
147
+ auth_code,
148
+ self._o_auth_redirect_uri,
149
+ _optional_form_parameters=additional_params,
150
+ ).body
151
+ if hasattr(token, "expires_in"):
152
+ current_utc_timestamp = AuthHelper.get_current_utc_timestamp()
153
+ token.expiry = AuthHelper.get_token_expiry(
154
+ current_utc_timestamp,
155
+ token.expires_in,
156
+ )
157
+ return token
158
+
159
+ def is_token_expired(self, o_auth_token=None):
160
+ """
161
+ Check if OAuth token has expired.
162
+
163
+ Args:
164
+ o_auth_token (OAuthToken): The OAuth token whose expiry is to be checked.
165
+
166
+ Returns:
167
+ bool: True if OAuth token has expired, False otherwise.
168
+
169
+ """
170
+ if o_auth_token is None:
171
+ return (hasattr(self._o_auth_token, "expiry")
172
+ and AuthHelper.is_token_expired(
173
+ self._o_auth_token.expiry))
174
+
175
+ return (hasattr(o_auth_token, "expiry")
176
+ and AuthHelper.is_token_expired(
177
+ o_auth_token.expiry))
178
+
179
+ def refresh_token(self, additional_params=None):
180
+ """
181
+ Execute call to refresh the OAuth token.
182
+
183
+ Args:
184
+ additional_params (dict): Any additional form parameters.
185
+
186
+ Returns:
187
+ OAuthToken: The refreshed OAuth token.
188
+
189
+ """
190
+ token = self._o_auth_api.refresh_token(
191
+ self.build_basic_auth_header(),
192
+ self._o_auth_token.refresh_token,
193
+ " ".join(self._o_auth_scopes) if self._o_auth_scopes else None,
194
+ _optional_form_parameters=additional_params,
195
+ ).body
196
+ if hasattr(token, "expires_in"):
197
+ current_utc_timestamp = AuthHelper.get_current_utc_timestamp()
198
+ token.expiry = AuthHelper.get_token_expiry(
199
+ current_utc_timestamp,
200
+ token.expires_in,
201
+ )
202
+ return token
203
+
204
+
205
+ class AuthorizationCodeAuthCredentials:
206
+ """
207
+ A model for authentication credentials. Provides simple validation,
208
+ cloning support, and optional construction from environment variables.
209
+ Suitable as a pattern for other auth models.
210
+ """
211
+
212
+ @property
213
+ def o_auth_client_id(self):
214
+ """
215
+ OAuth 2 Client ID.
216
+ """
217
+ return self._o_auth_client_id
218
+
219
+ @property
220
+ def o_auth_client_secret(self):
221
+ """
222
+ OAuth 2 Client Secret.
223
+ """
224
+ return self._o_auth_client_secret
225
+
226
+ @property
227
+ def o_auth_redirect_uri(self):
228
+ """
229
+ OAuth 2 Redirection endpoint or Callback Uri.
230
+ """
231
+ return self._o_auth_redirect_uri
232
+
233
+ @property
234
+ def o_auth_token(self):
235
+ """
236
+ Object for storing information about the OAuth token.
237
+ """
238
+ return self._o_auth_token
239
+
240
+ @property
241
+ def o_auth_scopes(self):
242
+ """
243
+ List of scopes that apply to the OAuth token.
244
+ """
245
+ return self._o_auth_scopes
246
+
247
+ def __init__(self, o_auth_client_id, o_auth_client_secret,
248
+ o_auth_redirect_uri, o_auth_token=None, o_auth_scopes=None):
249
+ """
250
+ Initialize the credentials.
251
+
252
+ Args:
253
+ o_auth_client_id: The o_auth_client_id property value to set.
254
+ o_auth_client_secret: The o_auth_client_secret property value to set.
255
+ o_auth_redirect_uri: The o_auth_redirect_uri property value to set.
256
+ o_auth_token: The o_auth_token property value to set.
257
+ o_auth_scopes: The o_auth_scopes property value to set.
258
+
259
+ Raises:
260
+ ValueError: If any required value is missing.
261
+
262
+ """
263
+ if o_auth_client_id is None:
264
+ raise ValueError("o_auth_client_id cannot be None")
265
+ if o_auth_client_secret is None:
266
+ raise ValueError("o_auth_client_secret cannot be None")
267
+ if o_auth_redirect_uri is None:
268
+ raise ValueError("o_auth_redirect_uri cannot be None")
269
+ self._o_auth_client_id = o_auth_client_id
270
+ self._o_auth_client_secret = o_auth_client_secret
271
+ self._o_auth_redirect_uri = o_auth_redirect_uri
272
+ self._o_auth_token = o_auth_token
273
+ self._o_auth_scopes = o_auth_scopes
274
+
275
+ def clone_with(self, o_auth_client_id=None, o_auth_client_secret=None,
276
+ o_auth_redirect_uri=None, o_auth_token=None,
277
+ o_auth_scopes=None):
278
+ """
279
+ Return a new instance with optional value overrides.
280
+
281
+ Args:
282
+ o_auth_client_id: The o_auth_client_id property value to set.
283
+ o_auth_client_secret: The o_auth_client_secret property value to set.
284
+ o_auth_redirect_uri: The o_auth_redirect_uri property value to set.
285
+ o_auth_token: The o_auth_token property value to set.
286
+ o_auth_scopes: The o_auth_scopes property value to set.
287
+
288
+ """
289
+ return AuthorizationCodeAuthCredentials(
290
+ o_auth_client_id or self.o_auth_client_id,
291
+ o_auth_client_secret or self.o_auth_client_secret,
292
+ o_auth_redirect_uri or self.o_auth_redirect_uri,
293
+ o_auth_token or self.o_auth_token,
294
+ o_auth_scopes or self.o_auth_scopes)
295
+
296
+ @classmethod
297
+ def from_environment(cls):
298
+ """
299
+ Create credentials from environment variables, if available.
300
+
301
+ Returns:
302
+ A credentials instance or ``None`` if values are missing.
303
+
304
+ """
305
+ o_auth_client_id = os.getenv(
306
+ "O_AUTH_CLIENT_ID",
307
+ None,
308
+ )
309
+ o_auth_client_secret = os.getenv(
310
+ "O_AUTH_CLIENT_SECRET",
311
+ None,
312
+ )
313
+ o_auth_redirect_uri = os.getenv(
314
+ "O_AUTH_REDIRECT_URI",
315
+ None,
316
+ )
317
+ o_auth_scopes = os.getenv(
318
+ "O_AUTH_SCOPES",
319
+ None,
320
+ )
321
+
322
+ if (o_auth_client_id is None
323
+ or o_auth_client_secret is None
324
+ or o_auth_redirect_uri is None):
325
+ return None
326
+
327
+ o_auth_scopes = [
328
+ v.strip() for v in o_auth_scopes.split(",") if v.strip()
329
+ ] if o_auth_scopes else None
330
+
331
+ return cls(
332
+ o_auth_client_id=o_auth_client_id,
333
+ o_auth_client_secret=o_auth_client_secret,
334
+ o_auth_redirect_uri=o_auth_redirect_uri,
335
+ o_auth_scopes=o_auth_scopes,
336
+ )
@@ -0,0 +1,20 @@
1
+
2
+ """
3
+ spotifywebapi
4
+
5
+ This file was automatically generated by APIMATIC v3.0 (
6
+ https://www.apimatic.io ).
7
+ """
8
+
9
+ from apimatic_core.http.http_callback import HttpCallBack as CoreHttpCallback
10
+
11
+
12
+ class HttpCallBack(CoreHttpCallback):
13
+ """
14
+ An interface for the callback to be called before and after the
15
+ HTTP call for an endpoint is made.
16
+
17
+ This class should not be instantiated but should be used as a base class
18
+ for HttpCallBack classes.
19
+
20
+ """
@@ -0,0 +1,23 @@
1
+ """
2
+ spotifywebapi
3
+
4
+ This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
5
+ """
6
+ from abc import ABC
7
+
8
+ from apimatic_core_interfaces.client.http_client_provider import (
9
+ HttpClientProvider as CoreHttpClientProvider,
10
+ )
11
+
12
+
13
+ class HttpClientProvider(CoreHttpClientProvider, ABC):
14
+ """
15
+ Defines a contract for providing HTTP client configuration.
16
+
17
+ Classes implementing this interface are expected to supply a configured
18
+ HTTP session and timeout value that will be used by the SDK's internal
19
+ HTTP layer when making network requests.
20
+
21
+ This allows developers to inject their own custom HTTP clients while
22
+ maintaining compatibility with the SDK's request/response handling.
23
+ """
@@ -0,0 +1,25 @@
1
+
2
+ """
3
+ spotifywebapi
4
+
5
+ This file was automatically generated by APIMATIC v3.0 (
6
+ https://www.apimatic.io ).
7
+ """
8
+
9
+ from apimatic_core_interfaces.types.http_method_enum import (
10
+ HttpMethodEnum as CoreHttpMethodEnum,
11
+ )
12
+
13
+
14
+ class HttpMethodEnum(CoreHttpMethodEnum):
15
+ """
16
+ Enumeration of an HTTP Method
17
+
18
+ Attributes:
19
+ GET: A GET Request
20
+ POST: A POST Request
21
+ PUT: A PUT Request
22
+ PATCH: A PATCH Request
23
+ DELETE: A DELETE Request
24
+
25
+ """
@@ -0,0 +1,55 @@
1
+
2
+ """
3
+ spotifywebapi
4
+
5
+ This file was automatically generated by APIMATIC v3.0 (
6
+ https://www.apimatic.io ).
7
+ """
8
+
9
+ from apimatic_core.http.request.http_request import HttpRequest as CoreHttpRequest
10
+
11
+
12
+ class HttpRequest(CoreHttpRequest):
13
+ """
14
+ Represent an HTTP request to be sent to the server.
15
+
16
+ Encapsulates request details such as the HTTP method, target URL, headers,
17
+ query parameters, body parameters, and any files included with the request.
18
+
19
+ Attributes:
20
+ http_method: The HTTP method to use for the request.
21
+ query_url (str): The URL to which the request will be sent.
22
+ headers (dict[str, str] | None): Headers to include with the request.
23
+ query_parameters (dict[str, str] | None): Query parameters appended
24
+ to the request URL.
25
+ parameters (dict[str, str] | None): Form or body parameters sent
26
+ with the request.
27
+ files (dict | None): Files to be sent with the request.
28
+
29
+ """
30
+
31
+ def __init__(self,
32
+ http_method,
33
+ query_url,
34
+ headers=None,
35
+ query_parameters=None,
36
+ parameters=None,
37
+ files=None):
38
+ """
39
+ Initialize an HttpRequest instance.
40
+
41
+ Args:
42
+ http_method: The HTTP method to use for the request.
43
+ query_url: The URL to which the request will be sent.
44
+ headers: Headers to include with the request.
45
+ query_parameters: Query parameters appended to the request URL.
46
+ parameters: Form or body parameters sent with the request.
47
+ files: Files to be sent with the request.
48
+
49
+ """
50
+ super().__init__(http_method,
51
+ query_url,
52
+ headers,
53
+ query_parameters,
54
+ parameters,
55
+ files)
@@ -0,0 +1,45 @@
1
+
2
+ """
3
+ spotifywebapi
4
+
5
+ This file was automatically generated by APIMATIC v3.0 (
6
+ https://www.apimatic.io ).
7
+ """
8
+
9
+ from apimatic_core.http.response.http_response import HttpResponse as CoreHttpResponse
10
+
11
+
12
+ class HttpResponse(CoreHttpResponse):
13
+ """
14
+ Represent an HTTP response returned by the server.
15
+
16
+ Stores response metadata such as status code, reason phrase, headers, and
17
+ the raw response body, along with the originating request.
18
+
19
+ Attributes:
20
+ status_code (int): The HTTP status code returned by the server.
21
+ reason_phrase (str): The reason phrase associated with the status code.
22
+ headers (dict[str, str]): Response headers as key-value pairs.
23
+ text (str): The raw response body as a string.
24
+ request: The request object that resulted in this response.
25
+
26
+ """
27
+
28
+ def __init__(self,
29
+ status_code,
30
+ reason_phrase,
31
+ headers,
32
+ text,
33
+ request):
34
+ """
35
+ Initialize an HttpResponse instance.
36
+
37
+ Args:
38
+ status_code: The HTTP status code returned by the server.
39
+ reason_phrase: The reason phrase associated with the status code.
40
+ headers: Response headers as key-value pairs.
41
+ text: The raw response body as a string.
42
+ request: The request object that resulted in this response.
43
+
44
+ """
45
+ super().__init__(status_code, reason_phrase, headers, text, request)
@@ -0,0 +1,50 @@
1
+ """
2
+ spotifywebapi
3
+
4
+ This file was automatically generated by APIMATIC v3.0 (
5
+ https://www.apimatic.io ).
6
+ """
7
+
8
+ import os
9
+ from typing import Optional
10
+
11
+ from apimatic_core.http.configurations.proxy_settings import (
12
+ ProxySettings as CoreProxySettings,
13
+ )
14
+
15
+
16
+ class ProxySettings(CoreProxySettings):
17
+ """A simple data model for configuring HTTP(S) proxy settings."""
18
+
19
+ @classmethod
20
+ def from_environment(cls) -> Optional["ProxySettings"]:
21
+ """
22
+ Create an instance of this class using environment-based configuration.
23
+
24
+ This method attempts to construct and return an instance using relevant
25
+ environment variables, if available. If the required configuration is
26
+ not present, it may return `None` to indicate that no valid instance
27
+ could be created.
28
+
29
+ Returns:
30
+ Optional[cls]: A configured instance of this class, or `None` if
31
+ configuration data is missing or invalid.
32
+
33
+ """
34
+ address = os.getenv("PROXY_ADDRESS", None)
35
+ if not address:
36
+ return None
37
+
38
+ port = os.getenv("PROXY_PORT", None)
39
+ if port is not None:
40
+ try:
41
+ port = int(port)
42
+ except (TypeError, ValueError):
43
+ port = None
44
+
45
+ return cls(
46
+ address=address,
47
+ port=port,
48
+ username=os.getenv("PROXY_USERNAME", None),
49
+ password=os.getenv("PROXY_PASSWORD", None),
50
+ )
@@ -0,0 +1,142 @@
1
+ # ruff: noqa: D104 | Missing docstring in public package
2
+ # ruff: noqa: RUF022 | `__all__` is not sorted
3
+ __all__ = [
4
+ "album_base",
5
+ "album_group_enum",
6
+ "album_object",
7
+ "album_restriction_object",
8
+ "album_type_enum",
9
+ "artist_discography_album_object",
10
+ "artist_object",
11
+ "audio_analysis_object",
12
+ "audio_features_object",
13
+ "audiobook_base",
14
+ "audiobook_object",
15
+ "author_object",
16
+ "categories",
17
+ "category_object",
18
+ "chapter_base",
19
+ "chapter_object",
20
+ "chapter_restriction_object",
21
+ "context_object",
22
+ "copyright_object",
23
+ "currently_playing_context_object",
24
+ "currently_playing_object",
25
+ "cursor_object",
26
+ "cursor_paged_artists",
27
+ "cursor_paging_object",
28
+ "cursor_paging_play_history_object",
29
+ "cursor_paging_simplified_artist_object",
30
+ "device_object",
31
+ "disallows_object",
32
+ "episode_base",
33
+ "episode_object",
34
+ "episode_restriction_object",
35
+ "error_object",
36
+ "explicit_content_settings_object",
37
+ "external_id_object",
38
+ "external_url_object",
39
+ "followers_object",
40
+ "image_object",
41
+ "include_external_enum",
42
+ "item_type_1_enum",
43
+ "item_type_2_enum",
44
+ "item_type_3_enum",
45
+ "item_type_enum",
46
+ "linked_track_object",
47
+ "many_albums",
48
+ "many_artists",
49
+ "many_audio_features",
50
+ "many_audiobooks",
51
+ "many_chapters",
52
+ "many_devices",
53
+ "many_episodes",
54
+ "many_genres",
55
+ "many_simplified_shows",
56
+ "many_tracks",
57
+ "markets",
58
+ "me_albums_request",
59
+ "me_episodes_request",
60
+ "me_episodes_request_1",
61
+ "me_following_request",
62
+ "me_following_request_1",
63
+ "me_player_play_request",
64
+ "me_player_request",
65
+ "me_shows_request",
66
+ "me_tracks_request",
67
+ "me_tracks_request_1",
68
+ "meta",
69
+ "mode_enum",
70
+ "narrator_object",
71
+ "o_auth_provider_error_enum",
72
+ "o_auth_scope_enum",
73
+ "o_auth_token",
74
+ "paged_albums",
75
+ "paged_categories",
76
+ "paging_artist_discography_album_object",
77
+ "paging_artist_object",
78
+ "paging_featured_playlist_object",
79
+ "paging_object",
80
+ "paging_playlist_object",
81
+ "paging_playlist_track_object",
82
+ "paging_saved_album_object",
83
+ "paging_saved_audiobook_object",
84
+ "paging_saved_episode_object",
85
+ "paging_saved_show_object",
86
+ "paging_saved_track_object",
87
+ "paging_simplified_album_object",
88
+ "paging_simplified_audiobook_object",
89
+ "paging_simplified_chapter_object",
90
+ "paging_simplified_episode_object",
91
+ "paging_simplified_show_object",
92
+ "paging_simplified_track_object",
93
+ "paging_track_object",
94
+ "play_history_object",
95
+ "playlist_object",
96
+ "playlist_owner_object",
97
+ "playlist_snapshot_id",
98
+ "playlist_track_object",
99
+ "playlist_tracks_ref_object",
100
+ "playlist_user_object",
101
+ "playlists_followers_request",
102
+ "playlists_request",
103
+ "playlists_tracks_request",
104
+ "playlists_tracks_request_1",
105
+ "playlists_tracks_request_2",
106
+ "private_user_object",
107
+ "public_user_object",
108
+ "queue_object",
109
+ "reason_enum",
110
+ "recommendation_seed_object",
111
+ "recommendations_object",
112
+ "release_date_precision_enum",
113
+ "resume_point_object",
114
+ "saved_album_object",
115
+ "saved_audiobook_object",
116
+ "saved_episode_object",
117
+ "saved_show_object",
118
+ "saved_track_object",
119
+ "search_items",
120
+ "section_object",
121
+ "segment_object",
122
+ "show_base",
123
+ "show_object",
124
+ "simplified_album_object",
125
+ "simplified_artist_object",
126
+ "simplified_playlist_object",
127
+ "simplified_track_object",
128
+ "time_interval_object",
129
+ "track",
130
+ "track_1",
131
+ "track_object",
132
+ "track_restriction_object",
133
+ "type_2_enum",
134
+ "type_3_enum",
135
+ "type_4_enum",
136
+ "type_5_enum",
137
+ "type_6_enum",
138
+ "type_8_enum",
139
+ "type_9_enum",
140
+ "type_enum",
141
+ "users_playlists_request",
142
+ ]