spotify-api-sdk 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +30 -0
  3. data/README.md +107 -0
  4. data/lib/spotify_web_api/api_helper.rb +10 -0
  5. data/lib/spotify_web_api/client.rb +154 -0
  6. data/lib/spotify_web_api/configuration.rb +180 -0
  7. data/lib/spotify_web_api/controllers/albums_controller.rb +295 -0
  8. data/lib/spotify_web_api/controllers/artists_controller.rb +187 -0
  9. data/lib/spotify_web_api/controllers/audiobooks_controller.rb +258 -0
  10. data/lib/spotify_web_api/controllers/base_controller.rb +66 -0
  11. data/lib/spotify_web_api/controllers/categories_controller.rb +83 -0
  12. data/lib/spotify_web_api/controllers/chapters_controller.rb +82 -0
  13. data/lib/spotify_web_api/controllers/episodes_controller.rb +239 -0
  14. data/lib/spotify_web_api/controllers/genres_controller.rb +39 -0
  15. data/lib/spotify_web_api/controllers/markets_controller.rb +38 -0
  16. data/lib/spotify_web_api/controllers/o_auth_authorization_controller.rb +82 -0
  17. data/lib/spotify_web_api/controllers/player_controller.rb +509 -0
  18. data/lib/spotify_web_api/controllers/playlists_controller.rb +521 -0
  19. data/lib/spotify_web_api/controllers/search_controller.rb +60 -0
  20. data/lib/spotify_web_api/controllers/shows_controller.rb +261 -0
  21. data/lib/spotify_web_api/controllers/tracks_controller.rb +491 -0
  22. data/lib/spotify_web_api/controllers/users_controller.rb +396 -0
  23. data/lib/spotify_web_api/exceptions/api_exception.rb +10 -0
  24. data/lib/spotify_web_api/exceptions/bad_request_exception.rb +32 -0
  25. data/lib/spotify_web_api/exceptions/forbidden_exception.rb +32 -0
  26. data/lib/spotify_web_api/exceptions/not_found_exception.rb +32 -0
  27. data/lib/spotify_web_api/exceptions/o_auth_provider_exception.rb +48 -0
  28. data/lib/spotify_web_api/exceptions/too_many_requests_exception.rb +32 -0
  29. data/lib/spotify_web_api/exceptions/unauthorized_exception.rb +32 -0
  30. data/lib/spotify_web_api/http/api_response.rb +21 -0
  31. data/lib/spotify_web_api/http/auth/o_auth2.rb +146 -0
  32. data/lib/spotify_web_api/http/http_call_back.rb +10 -0
  33. data/lib/spotify_web_api/http/http_method_enum.rb +10 -0
  34. data/lib/spotify_web_api/http/http_request.rb +10 -0
  35. data/lib/spotify_web_api/http/http_response.rb +10 -0
  36. data/lib/spotify_web_api/models/album_base.rb +168 -0
  37. data/lib/spotify_web_api/models/album_group_enum.rb +29 -0
  38. data/lib/spotify_web_api/models/album_object.rb +247 -0
  39. data/lib/spotify_web_api/models/album_restriction_object.rb +53 -0
  40. data/lib/spotify_web_api/models/album_type_enum.rb +26 -0
  41. data/lib/spotify_web_api/models/artist_discography_album_object.rb +194 -0
  42. data/lib/spotify_web_api/models/artist_object.rb +147 -0
  43. data/lib/spotify_web_api/models/audio_analysis_object.rb +156 -0
  44. data/lib/spotify_web_api/models/audio_features_object.rb +249 -0
  45. data/lib/spotify_web_api/models/audiobook_base.rb +245 -0
  46. data/lib/spotify_web_api/models/audiobook_object.rb +253 -0
  47. data/lib/spotify_web_api/models/author_object.rb +50 -0
  48. data/lib/spotify_web_api/models/base_model.rb +62 -0
  49. data/lib/spotify_web_api/models/categories.rb +110 -0
  50. data/lib/spotify_web_api/models/category_object.rb +82 -0
  51. data/lib/spotify_web_api/models/chapter_base.rb +237 -0
  52. data/lib/spotify_web_api/models/chapter_object.rb +245 -0
  53. data/lib/spotify_web_api/models/chapter_restriction_object.rb +59 -0
  54. data/lib/spotify_web_api/models/context_object.rb +78 -0
  55. data/lib/spotify_web_api/models/copyright_object.rb +60 -0
  56. data/lib/spotify_web_api/models/currently_playing_context_object.rb +137 -0
  57. data/lib/spotify_web_api/models/currently_playing_object.rb +109 -0
  58. data/lib/spotify_web_api/models/cursor_object.rb +59 -0
  59. data/lib/spotify_web_api/models/cursor_paged_artists.rb +48 -0
  60. data/lib/spotify_web_api/models/cursor_paging_object.rb +88 -0
  61. data/lib/spotify_web_api/models/cursor_paging_play_history_object.rb +106 -0
  62. data/lib/spotify_web_api/models/cursor_paging_simplified_artist_object.rb +106 -0
  63. data/lib/spotify_web_api/models/device_object.rb +126 -0
  64. data/lib/spotify_web_api/models/disallows_object.rb +140 -0
  65. data/lib/spotify_web_api/models/episode_base.rb +237 -0
  66. data/lib/spotify_web_api/models/episode_object.rb +246 -0
  67. data/lib/spotify_web_api/models/episode_restriction_object.rb +58 -0
  68. data/lib/spotify_web_api/models/error_object.rb +59 -0
  69. data/lib/spotify_web_api/models/explicit_content_settings_object.rb +61 -0
  70. data/lib/spotify_web_api/models/external_id_object.rb +72 -0
  71. data/lib/spotify_web_api/models/external_url_object.rb +51 -0
  72. data/lib/spotify_web_api/models/followers_object.rb +62 -0
  73. data/lib/spotify_web_api/models/image_object.rb +67 -0
  74. data/lib/spotify_web_api/models/include_external_enum.rb +23 -0
  75. data/lib/spotify_web_api/models/item_type1_enum.rb +20 -0
  76. data/lib/spotify_web_api/models/item_type2_enum.rb +23 -0
  77. data/lib/spotify_web_api/models/item_type3_enum.rb +23 -0
  78. data/lib/spotify_web_api/models/item_type_enum.rb +38 -0
  79. data/lib/spotify_web_api/models/linked_track_object.rb +89 -0
  80. data/lib/spotify_web_api/models/many_albums.rb +57 -0
  81. data/lib/spotify_web_api/models/many_artists.rb +57 -0
  82. data/lib/spotify_web_api/models/many_audio_features.rb +57 -0
  83. data/lib/spotify_web_api/models/many_audiobooks.rb +57 -0
  84. data/lib/spotify_web_api/models/many_chapters.rb +57 -0
  85. data/lib/spotify_web_api/models/many_devices.rb +57 -0
  86. data/lib/spotify_web_api/models/many_episodes.rb +57 -0
  87. data/lib/spotify_web_api/models/many_genres.rb +48 -0
  88. data/lib/spotify_web_api/models/many_simplified_shows.rb +57 -0
  89. data/lib/spotify_web_api/models/many_tracks.rb +57 -0
  90. data/lib/spotify_web_api/models/markets.rb +50 -0
  91. data/lib/spotify_web_api/models/me_albums_request.rb +55 -0
  92. data/lib/spotify_web_api/models/me_episodes_request.rb +52 -0
  93. data/lib/spotify_web_api/models/me_episodes_request1.rb +54 -0
  94. data/lib/spotify_web_api/models/me_following_request.rb +53 -0
  95. data/lib/spotify_web_api/models/me_following_request1.rb +55 -0
  96. data/lib/spotify_web_api/models/me_player_play_request.rb +89 -0
  97. data/lib/spotify_web_api/models/me_player_request.rb +63 -0
  98. data/lib/spotify_web_api/models/me_shows_request.rb +55 -0
  99. data/lib/spotify_web_api/models/me_tracks_request.rb +53 -0
  100. data/lib/spotify_web_api/models/me_tracks_request1.rb +55 -0
  101. data/lib/spotify_web_api/models/meta.rb +110 -0
  102. data/lib/spotify_web_api/models/mode_enum.rb +30 -0
  103. data/lib/spotify_web_api/models/narrator_object.rb +50 -0
  104. data/lib/spotify_web_api/models/o_auth_provider_error_enum.rb +45 -0
  105. data/lib/spotify_web_api/models/o_auth_scope_enum.rb +94 -0
  106. data/lib/spotify_web_api/models/o_auth_token.rb +96 -0
  107. data/lib/spotify_web_api/models/paged_albums.rb +48 -0
  108. data/lib/spotify_web_api/models/paged_categories.rb +48 -0
  109. data/lib/spotify_web_api/models/paging_artist_discography_album_object.rb +110 -0
  110. data/lib/spotify_web_api/models/paging_artist_object.rb +110 -0
  111. data/lib/spotify_web_api/models/paging_featured_playlist_object.rb +59 -0
  112. data/lib/spotify_web_api/models/paging_object.rb +93 -0
  113. data/lib/spotify_web_api/models/paging_playlist_object.rb +110 -0
  114. data/lib/spotify_web_api/models/paging_playlist_track_object.rb +110 -0
  115. data/lib/spotify_web_api/models/paging_saved_album_object.rb +110 -0
  116. data/lib/spotify_web_api/models/paging_saved_audiobook_object.rb +110 -0
  117. data/lib/spotify_web_api/models/paging_saved_episode_object.rb +110 -0
  118. data/lib/spotify_web_api/models/paging_saved_show_object.rb +110 -0
  119. data/lib/spotify_web_api/models/paging_saved_track_object.rb +110 -0
  120. data/lib/spotify_web_api/models/paging_simplified_album_object.rb +110 -0
  121. data/lib/spotify_web_api/models/paging_simplified_audiobook_object.rb +110 -0
  122. data/lib/spotify_web_api/models/paging_simplified_chapter_object.rb +110 -0
  123. data/lib/spotify_web_api/models/paging_simplified_episode_object.rb +110 -0
  124. data/lib/spotify_web_api/models/paging_simplified_show_object.rb +110 -0
  125. data/lib/spotify_web_api/models/paging_simplified_track_object.rb +110 -0
  126. data/lib/spotify_web_api/models/paging_track_object.rb +110 -0
  127. data/lib/spotify_web_api/models/play_history_object.rb +77 -0
  128. data/lib/spotify_web_api/models/playlist_object.rb +193 -0
  129. data/lib/spotify_web_api/models/playlist_owner_object.rb +109 -0
  130. data/lib/spotify_web_api/models/playlist_snapshot_id.rb +50 -0
  131. data/lib/spotify_web_api/models/playlist_track_object.rb +90 -0
  132. data/lib/spotify_web_api/models/playlist_tracks_ref_object.rb +60 -0
  133. data/lib/spotify_web_api/models/playlist_user_object.rb +98 -0
  134. data/lib/spotify_web_api/models/playlists_followers_request.rb +51 -0
  135. data/lib/spotify_web_api/models/playlists_request.rb +82 -0
  136. data/lib/spotify_web_api/models/playlists_tracks_request.rb +72 -0
  137. data/lib/spotify_web_api/models/playlists_tracks_request1.rb +97 -0
  138. data/lib/spotify_web_api/models/playlists_tracks_request2.rb +75 -0
  139. data/lib/spotify_web_api/models/private_user_object.rb +181 -0
  140. data/lib/spotify_web_api/models/public_user_object.rb +128 -0
  141. data/lib/spotify_web_api/models/queue_object.rb +60 -0
  142. data/lib/spotify_web_api/models/reason_enum.rb +29 -0
  143. data/lib/spotify_web_api/models/recommendation_seed_object.rb +104 -0
  144. data/lib/spotify_web_api/models/recommendations_object.rb +74 -0
  145. data/lib/spotify_web_api/models/release_date_precision_enum.rb +26 -0
  146. data/lib/spotify_web_api/models/resume_point_object.rb +60 -0
  147. data/lib/spotify_web_api/models/saved_album_object.rb +73 -0
  148. data/lib/spotify_web_api/models/saved_audiobook_object.rb +73 -0
  149. data/lib/spotify_web_api/models/saved_episode_object.rb +70 -0
  150. data/lib/spotify_web_api/models/saved_show_object.rb +73 -0
  151. data/lib/spotify_web_api/models/saved_track_object.rb +73 -0
  152. data/lib/spotify_web_api/models/search_items.rb +107 -0
  153. data/lib/spotify_web_api/models/section_object.rb +180 -0
  154. data/lib/spotify_web_api/models/segment_object.rb +166 -0
  155. data/lib/spotify_web_api/models/show_base.rb +211 -0
  156. data/lib/spotify_web_api/models/show_object.rb +219 -0
  157. data/lib/spotify_web_api/models/simplified_album_object.rb +186 -0
  158. data/lib/spotify_web_api/models/simplified_artist_object.rb +98 -0
  159. data/lib/spotify_web_api/models/simplified_playlist_object.rb +184 -0
  160. data/lib/spotify_web_api/models/simplified_track_object.rb +227 -0
  161. data/lib/spotify_web_api/models/time_interval_object.rb +68 -0
  162. data/lib/spotify_web_api/models/track.rb +331 -0
  163. data/lib/spotify_web_api/models/track1.rb +50 -0
  164. data/lib/spotify_web_api/models/track_object.rb +265 -0
  165. data/lib/spotify_web_api/models/track_restriction_object.rb +58 -0
  166. data/lib/spotify_web_api/models/type2_enum.rb +20 -0
  167. data/lib/spotify_web_api/models/type3_enum.rb +20 -0
  168. data/lib/spotify_web_api/models/type4_enum.rb +20 -0
  169. data/lib/spotify_web_api/models/type6_enum.rb +20 -0
  170. data/lib/spotify_web_api/models/type7_enum.rb +20 -0
  171. data/lib/spotify_web_api/models/type8_enum.rb +20 -0
  172. data/lib/spotify_web_api/models/type9_enum.rb +20 -0
  173. data/lib/spotify_web_api/models/type_enum.rb +20 -0
  174. data/lib/spotify_web_api/models/users_playlists_request.rb +87 -0
  175. data/lib/spotify_web_api/utilities/date_time_helper.rb +11 -0
  176. data/lib/spotify_web_api/utilities/file_wrapper.rb +16 -0
  177. data/lib/spotify_web_api.rb +198 -0
  178. metadata +264 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 71d2212384a72b7ecd0ad0744af52b6ef68ac50835ffb47da97348163c6c83e1
4
+ data.tar.gz: c8eef64c44514d78405c6785fb7ea17d91d66ecf7b72c85632387dbfd9b3726b
5
+ SHA512:
6
+ metadata.gz: 3ce3bef8ef90c1e032214562eaa8c2e31fc7fbcf07bf8fa0c854ed1ec3e447303819e2dff86b9bb0c3d2299a6765037fad3c50e0d2fd26ef3bdf4102853ef288
7
+ data.tar.gz: e62a110b19a3d24d130369e0939efee4b60020fabeae9d6a07d9148ac3ce7d74a9d53714425788e7b37f081994a88fca9db4c42e1be82603a5d31c15a3759d69
data/LICENSE ADDED
@@ -0,0 +1,30 @@
1
+ This SDK was generated by APIMATIC.
2
+
3
+ License:
4
+ ========
5
+ The MIT License (MIT)
6
+ http://opensource.org/licenses/MIT
7
+
8
+ Copyright (c) 2014 - 2023 APIMATIC Limited
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in
18
+ all copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26
+ THE SOFTWARE.
27
+
28
+ Trade Mark:
29
+ ==========
30
+ APIMATIC is a trade mark for APIMATIC Limited
data/README.md ADDED
@@ -0,0 +1,107 @@
1
+
2
+ # Getting Started with Spotify Web API
3
+
4
+ ## Introduction
5
+
6
+ You can use Spotify's Web API to discover music and podcasts, manage your Spotify library, control audio playback, and much more. Browse our available Web API endpoints using the sidebar at left, or via the navigation bar on top of this page on smaller screens.
7
+
8
+ In order to make successful Web API requests your app will need a valid access token. One can be obtained through <a href="https://developer.spotify.com/documentation/general/guides/authorization-guide/">OAuth 2.0</a>.
9
+
10
+ The base URI for all Web API requests is `https://api.spotify.com/v1`.
11
+
12
+ Need help? See our <a href="https://developer.spotify.com/documentation/web-api/guides/">Web API guides</a> for more information, or visit the <a href="https://community.spotify.com/t5/Spotify-for-Developers/bd-p/Spotify_Developer">Spotify for Developers community forum</a> to ask questions and connect with other developers.
13
+
14
+ ## Install the Package
15
+
16
+ Install the gem from the command line:
17
+
18
+ ```ruby
19
+ gem install spotify-api-sdk -v 1.0.0
20
+ ```
21
+
22
+ Or add the gem to your Gemfile and run `bundle`:
23
+
24
+ ```ruby
25
+ gem 'spotify-api-sdk', '1.0.0'
26
+ ```
27
+
28
+ For additional gem details, see the [RubyGems page for the spotify-api-sdk gem](https://rubygems.org/gems/spotify-api-sdk/versions/1.0.0).
29
+
30
+ ## Initialize the API Client
31
+
32
+ **_Note:_** Documentation for the client can be found [here.](https://www.github.com/sdks-io/spotify-api-ruby-sdk/tree/1.0.0/doc/client.md)
33
+
34
+ The following parameters are configurable for the API Client:
35
+
36
+ | Parameter | Type | Description |
37
+ | --- | --- | --- |
38
+ | `environment` | `Environment` | The API environment. <br> **Default: `Environment.PRODUCTION`** |
39
+ | `connection` | `Faraday::Connection` | The Faraday connection object passed by the SDK user for making requests |
40
+ | `adapter` | `Faraday::Adapter` | The Faraday adapter object passed by the SDK user for performing http requests |
41
+ | `timeout` | `Float` | The value to use for connection timeout. <br> **Default: 60** |
42
+ | `max_retries` | `Integer` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
43
+ | `retry_interval` | `Float` | Pause in seconds between retries. <br> **Default: 1** |
44
+ | `backoff_factor` | `Float` | The amount to multiply each successive retry's interval amount by in order to provide backoff. <br> **Default: 2** |
45
+ | `retry_statuses` | `Array` | A list of HTTP statuses to retry. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
46
+ | `retry_methods` | `Array` | A list of HTTP methods to retry. <br> **Default: %i[get put]** |
47
+ | `http_callback` | `HttpCallBack` | The Http CallBack allows defining callables for pre and post API calls. |
48
+ | `authorization_code_auth_credentials` | [`AuthorizationCodeAuthCredentials`](https://www.github.com/sdks-io/spotify-api-ruby-sdk/tree/1.0.0/doc/auth/oauth-2-authorization-code-grant.md) | The credential object for OAuth 2 Authorization Code Grant |
49
+
50
+ The API client can be initialized as follows:
51
+
52
+ ```ruby
53
+ client = SpotifyWebApi::Client.new(
54
+ authorization_code_auth_credentials: AuthorizationCodeAuthCredentials.new(
55
+ o_auth_client_id: 'OAuthClientId',
56
+ o_auth_client_secret: 'OAuthClientSecret',
57
+ o_auth_redirect_uri: 'OAuthRedirectUri',
58
+ o_auth_scopes: [
59
+ OAuthScopeEnum::APP_REMOTE_CONTROL,
60
+ OAuthScopeEnum::PLAYLIST_READ_PRIVATE
61
+ ]
62
+ ),
63
+ environment: Environment::PRODUCTION
64
+ )
65
+ ```
66
+
67
+ API calls return an `ApiResponse` object that includes the following fields:
68
+
69
+ | Field | Description |
70
+ | --- | --- |
71
+ | `status_code` | Status code of the HTTP response |
72
+ | `reason_phrase` | Reason phrase of the HTTP response |
73
+ | `headers` | Headers of the HTTP response as a Hash |
74
+ | `raw_body` | The body of the HTTP response as a String |
75
+ | `request` | HTTP request info |
76
+ | `errors` | Errors, if they exist |
77
+ | `data` | The deserialized body of the HTTP response |
78
+
79
+ ## Authorization
80
+
81
+ This API uses the following authentication schemes.
82
+
83
+ * [`oauth_2_0 (OAuth 2 Authorization Code Grant)`](https://www.github.com/sdks-io/spotify-api-ruby-sdk/tree/1.0.0/doc/auth/oauth-2-authorization-code-grant.md)
84
+
85
+ ## List of APIs
86
+
87
+ * [Albums](https://www.github.com/sdks-io/spotify-api-ruby-sdk/tree/1.0.0/doc/controllers/albums.md)
88
+ * [Artists](https://www.github.com/sdks-io/spotify-api-ruby-sdk/tree/1.0.0/doc/controllers/artists.md)
89
+ * [Audiobooks](https://www.github.com/sdks-io/spotify-api-ruby-sdk/tree/1.0.0/doc/controllers/audiobooks.md)
90
+ * [Categories](https://www.github.com/sdks-io/spotify-api-ruby-sdk/tree/1.0.0/doc/controllers/categories.md)
91
+ * [Chapters](https://www.github.com/sdks-io/spotify-api-ruby-sdk/tree/1.0.0/doc/controllers/chapters.md)
92
+ * [Episodes](https://www.github.com/sdks-io/spotify-api-ruby-sdk/tree/1.0.0/doc/controllers/episodes.md)
93
+ * [Genres](https://www.github.com/sdks-io/spotify-api-ruby-sdk/tree/1.0.0/doc/controllers/genres.md)
94
+ * [Markets](https://www.github.com/sdks-io/spotify-api-ruby-sdk/tree/1.0.0/doc/controllers/markets.md)
95
+ * [Player](https://www.github.com/sdks-io/spotify-api-ruby-sdk/tree/1.0.0/doc/controllers/player.md)
96
+ * [Playlists](https://www.github.com/sdks-io/spotify-api-ruby-sdk/tree/1.0.0/doc/controllers/playlists.md)
97
+ * [Search](https://www.github.com/sdks-io/spotify-api-ruby-sdk/tree/1.0.0/doc/controllers/search.md)
98
+ * [Shows](https://www.github.com/sdks-io/spotify-api-ruby-sdk/tree/1.0.0/doc/controllers/shows.md)
99
+ * [Tracks](https://www.github.com/sdks-io/spotify-api-ruby-sdk/tree/1.0.0/doc/controllers/tracks.md)
100
+ * [Users](https://www.github.com/sdks-io/spotify-api-ruby-sdk/tree/1.0.0/doc/controllers/users.md)
101
+
102
+ ## Classes Documentation
103
+
104
+ * [Utility Classes](https://www.github.com/sdks-io/spotify-api-ruby-sdk/tree/1.0.0/doc/utility-classes.md)
105
+ * [HttpResponse](https://www.github.com/sdks-io/spotify-api-ruby-sdk/tree/1.0.0/doc/http-response.md)
106
+ * [HttpRequest](https://www.github.com/sdks-io/spotify-api-ruby-sdk/tree/1.0.0/doc/http-request.md)
107
+
@@ -0,0 +1,10 @@
1
+ # spotify_web_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SpotifyWebApi
7
+ # API utility class
8
+ class APIHelper < CoreLibrary::ApiHelper
9
+ end
10
+ end
@@ -0,0 +1,154 @@
1
+ # spotify_web_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SpotifyWebApi
7
+ # spotify_web_api client class.
8
+ class Client
9
+ include CoreLibrary
10
+ attr_reader :config, :auth_managers
11
+
12
+ # Returns the configured authentication oauth_2_0 instance.
13
+ def oauth_2_0
14
+ @auth_managers['oauth_2_0']
15
+ end
16
+
17
+ # Access to albums controller.
18
+ # @return [AlbumsController] Returns the controller instance.
19
+ def albums
20
+ @albums ||= AlbumsController.new @global_configuration
21
+ end
22
+
23
+ # Access to artists controller.
24
+ # @return [ArtistsController] Returns the controller instance.
25
+ def artists
26
+ @artists ||= ArtistsController.new @global_configuration
27
+ end
28
+
29
+ # Access to audiobooks controller.
30
+ # @return [AudiobooksController] Returns the controller instance.
31
+ def audiobooks
32
+ @audiobooks ||= AudiobooksController.new @global_configuration
33
+ end
34
+
35
+ # Access to categories controller.
36
+ # @return [CategoriesController] Returns the controller instance.
37
+ def categories
38
+ @categories ||= CategoriesController.new @global_configuration
39
+ end
40
+
41
+ # Access to chapters controller.
42
+ # @return [ChaptersController] Returns the controller instance.
43
+ def chapters
44
+ @chapters ||= ChaptersController.new @global_configuration
45
+ end
46
+
47
+ # Access to episodes controller.
48
+ # @return [EpisodesController] Returns the controller instance.
49
+ def episodes
50
+ @episodes ||= EpisodesController.new @global_configuration
51
+ end
52
+
53
+ # Access to genres controller.
54
+ # @return [GenresController] Returns the controller instance.
55
+ def genres
56
+ @genres ||= GenresController.new @global_configuration
57
+ end
58
+
59
+ # Access to markets controller.
60
+ # @return [MarketsController] Returns the controller instance.
61
+ def markets
62
+ @markets ||= MarketsController.new @global_configuration
63
+ end
64
+
65
+ # Access to player controller.
66
+ # @return [PlayerController] Returns the controller instance.
67
+ def player
68
+ @player ||= PlayerController.new @global_configuration
69
+ end
70
+
71
+ # Access to playlists controller.
72
+ # @return [PlaylistsController] Returns the controller instance.
73
+ def playlists
74
+ @playlists ||= PlaylistsController.new @global_configuration
75
+ end
76
+
77
+ # Access to search controller.
78
+ # @return [SearchController] Returns the controller instance.
79
+ def search
80
+ @search ||= SearchController.new @global_configuration
81
+ end
82
+
83
+ # Access to shows controller.
84
+ # @return [ShowsController] Returns the controller instance.
85
+ def shows
86
+ @shows ||= ShowsController.new @global_configuration
87
+ end
88
+
89
+ # Access to tracks controller.
90
+ # @return [TracksController] Returns the controller instance.
91
+ def tracks
92
+ @tracks ||= TracksController.new @global_configuration
93
+ end
94
+
95
+ # Access to users controller.
96
+ # @return [UsersController] Returns the controller instance.
97
+ def users
98
+ @users ||= UsersController.new @global_configuration
99
+ end
100
+
101
+ # Access to o_auth_authorization controller.
102
+ # @return [OAuthAuthorizationController] Returns the controller instance.
103
+ def o_auth_authorization
104
+ @o_auth_authorization ||= OAuthAuthorizationController.new @global_configuration
105
+ end
106
+
107
+ def initialize(
108
+ connection: nil, adapter: :net_http_persistent, timeout: 60,
109
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
110
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
111
+ retry_methods: %i[get put], http_callback: nil,
112
+ environment: Environment::PRODUCTION, o_auth_client_id: nil,
113
+ o_auth_client_secret: nil, o_auth_redirect_uri: nil, o_auth_token: nil,
114
+ o_auth_scopes: nil, authorization_code_auth_credentials: nil, config: nil
115
+ )
116
+ @config = if config.nil?
117
+ Configuration.new(
118
+ connection: connection, adapter: adapter, timeout: timeout,
119
+ max_retries: max_retries, retry_interval: retry_interval,
120
+ backoff_factor: backoff_factor,
121
+ retry_statuses: retry_statuses,
122
+ retry_methods: retry_methods, http_callback: http_callback,
123
+ environment: environment,
124
+ o_auth_client_id: o_auth_client_id,
125
+ o_auth_client_secret: o_auth_client_secret,
126
+ o_auth_redirect_uri: o_auth_redirect_uri,
127
+ o_auth_token: o_auth_token, o_auth_scopes: o_auth_scopes,
128
+ authorization_code_auth_credentials: authorization_code_auth_credentials
129
+ )
130
+ else
131
+ config
132
+ end
133
+
134
+ @global_configuration = GlobalConfiguration.new(client_configuration: @config)
135
+ .base_uri_executor(@config.method(:get_base_uri))
136
+ .global_errors(BaseController::GLOBAL_ERRORS)
137
+ .user_agent(BaseController.user_agent)
138
+
139
+ initialize_auth_managers(@global_configuration)
140
+ @global_configuration = @global_configuration.auth_managers(@auth_managers)
141
+ end
142
+
143
+ # Initializes the auth managers hash used for authenticating API calls.
144
+ # @param [GlobalConfiguration] global_config The global configuration of the SDK)
145
+ def initialize_auth_managers(global_config)
146
+ @auth_managers = {}
147
+ http_client_config = global_config.client_configuration
148
+ %w[oauth_2_0].each { |auth| @auth_managers[auth] = nil }
149
+ @auth_managers['oauth_2_0'] = OAuth2.new(
150
+ http_client_config.authorization_code_auth_credentials, global_config
151
+ )
152
+ end
153
+ end
154
+ end
@@ -0,0 +1,180 @@
1
+ # spotify_web_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SpotifyWebApi
7
+ # An enum for SDK environments.
8
+ class Environment
9
+ ENVIRONMENT = [
10
+ PRODUCTION = 'production'.freeze
11
+ ].freeze
12
+ end
13
+
14
+ # An enum for API servers.
15
+ class Server
16
+ SERVER = [
17
+ DEFAULT = 'default'.freeze,
18
+ AUTH_SERVER = 'auth server'.freeze
19
+ ].freeze
20
+ end
21
+
22
+ # All configuration including auth info and base URI for the API access
23
+ # are configured in this class.
24
+ class Configuration < CoreLibrary::HttpClientConfiguration
25
+ def o_auth_client_id
26
+ @authorization_code_auth_credentials.o_auth_client_id
27
+ end
28
+
29
+ def o_auth_client_secret
30
+ @authorization_code_auth_credentials.o_auth_client_secret
31
+ end
32
+
33
+ def o_auth_redirect_uri
34
+ @authorization_code_auth_credentials.o_auth_redirect_uri
35
+ end
36
+
37
+ def o_auth_token
38
+ @authorization_code_auth_credentials.o_auth_token
39
+ end
40
+
41
+ def o_auth_scopes
42
+ @authorization_code_auth_credentials.o_auth_scopes
43
+ end
44
+
45
+ # The attribute readers for properties.
46
+ attr_reader :environment, :authorization_code_auth_credentials
47
+
48
+ class << self
49
+ attr_reader :environments
50
+ end
51
+
52
+ def initialize(
53
+ connection: nil, adapter: :net_http_persistent, timeout: 60,
54
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
55
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
56
+ retry_methods: %i[get put], http_callback: nil,
57
+ environment: Environment::PRODUCTION, o_auth_client_id: nil,
58
+ o_auth_client_secret: nil, o_auth_redirect_uri: nil, o_auth_token: nil,
59
+ o_auth_scopes: nil, authorization_code_auth_credentials: nil
60
+ )
61
+
62
+ super connection: connection, adapter: adapter, timeout: timeout,
63
+ max_retries: max_retries, retry_interval: retry_interval,
64
+ backoff_factor: backoff_factor, retry_statuses: retry_statuses,
65
+ retry_methods: retry_methods, http_callback: http_callback
66
+
67
+ # Current API environment
68
+ @environment = String(environment)
69
+
70
+ # OAuth 2 Client ID
71
+ @o_auth_client_id = o_auth_client_id
72
+
73
+ # OAuth 2 Client Secret
74
+ @o_auth_client_secret = o_auth_client_secret
75
+
76
+ # OAuth 2 Redirection endpoint or Callback Uri
77
+ @o_auth_redirect_uri = o_auth_redirect_uri
78
+
79
+ # Object for storing information about the OAuth token
80
+ @o_auth_token = if o_auth_token.is_a? OAuthToken
81
+ OAuthToken.from_hash o_auth_token.to_hash
82
+ else
83
+ o_auth_token
84
+ end
85
+
86
+ # List of scopes that apply to the OAuth token
87
+ @o_auth_scopes = o_auth_scopes
88
+
89
+ # Initializing OAuth 2 Authorization Code Grant credentials with the provided auth parameters
90
+ @authorization_code_auth_credentials = create_auth_credentials_object(
91
+ o_auth_client_id, o_auth_client_secret, o_auth_redirect_uri,
92
+ o_auth_token, o_auth_scopes, authorization_code_auth_credentials
93
+ )
94
+
95
+ # The Http Client to use for making requests.
96
+ set_http_client CoreLibrary::FaradayClient.new(self)
97
+ end
98
+
99
+ def clone_with(connection: nil, adapter: nil, timeout: nil,
100
+ max_retries: nil, retry_interval: nil, backoff_factor: nil,
101
+ retry_statuses: nil, retry_methods: nil, http_callback: nil,
102
+ environment: nil, o_auth_client_id: nil,
103
+ o_auth_client_secret: nil, o_auth_redirect_uri: nil,
104
+ o_auth_token: nil, o_auth_scopes: nil,
105
+ authorization_code_auth_credentials: nil)
106
+ connection ||= self.connection
107
+ adapter ||= self.adapter
108
+ timeout ||= self.timeout
109
+ max_retries ||= self.max_retries
110
+ retry_interval ||= self.retry_interval
111
+ backoff_factor ||= self.backoff_factor
112
+ retry_statuses ||= self.retry_statuses
113
+ retry_methods ||= self.retry_methods
114
+ http_callback ||= self.http_callback
115
+ environment ||= self.environment
116
+ authorization_code_auth_credentials = create_auth_credentials_object(
117
+ o_auth_client_id, o_auth_client_secret, o_auth_redirect_uri,
118
+ o_auth_token, o_auth_scopes,
119
+ authorization_code_auth_credentials || self.authorization_code_auth_credentials
120
+ )
121
+
122
+ Configuration.new(
123
+ connection: connection, adapter: adapter, timeout: timeout,
124
+ max_retries: max_retries, retry_interval: retry_interval,
125
+ backoff_factor: backoff_factor, retry_statuses: retry_statuses,
126
+ retry_methods: retry_methods, http_callback: http_callback,
127
+ environment: environment,
128
+ authorization_code_auth_credentials: authorization_code_auth_credentials
129
+ )
130
+ end
131
+
132
+ def create_auth_credentials_object(o_auth_client_id, o_auth_client_secret,
133
+ o_auth_redirect_uri, o_auth_token,
134
+ o_auth_scopes,
135
+ authorization_code_auth_credentials)
136
+ return authorization_code_auth_credentials if o_auth_client_id.nil? &&
137
+ o_auth_client_secret.nil? &&
138
+ o_auth_redirect_uri.nil? &&
139
+ o_auth_token.nil? &&
140
+ o_auth_scopes.nil?
141
+
142
+ warn('The \'o_auth_client_id\', \'o_auth_client_secret\', \'o_auth_redir'\
143
+ 'ect_uri\', \'o_auth_token\', \'o_auth_scopes\' params are deprecat'\
144
+ 'ed. Use \'authorization_code_auth_credentials\' param instead.')
145
+
146
+ unless authorization_code_auth_credentials.nil?
147
+ return authorization_code_auth_credentials.clone_with(
148
+ o_auth_client_id: o_auth_client_id,
149
+ o_auth_client_secret: o_auth_client_secret,
150
+ o_auth_redirect_uri: o_auth_redirect_uri,
151
+ o_auth_token: o_auth_token,
152
+ o_auth_scopes: o_auth_scopes
153
+ )
154
+ end
155
+
156
+ AuthorizationCodeAuthCredentials.new(
157
+ o_auth_client_id: o_auth_client_id,
158
+ o_auth_client_secret: o_auth_client_secret,
159
+ o_auth_redirect_uri: o_auth_redirect_uri, o_auth_token: o_auth_token,
160
+ o_auth_scopes: o_auth_scopes
161
+ )
162
+ end
163
+
164
+ # All the environments the SDK can run in.
165
+ ENVIRONMENTS = {
166
+ Environment::PRODUCTION => {
167
+ Server::DEFAULT => 'https://api.spotify.com/v1',
168
+ Server::AUTH_SERVER => 'https://accounts.spotify.com'
169
+ }
170
+ }.freeze
171
+
172
+ # Generates the appropriate base URI for the environment and the server.
173
+ # @param [Configuration::Server] server The server enum for which the base URI is
174
+ # required.
175
+ # @return [String] The base URI.
176
+ def get_base_uri(server = Server::DEFAULT)
177
+ ENVIRONMENTS[environment][server].clone
178
+ end
179
+ end
180
+ end