spotify-apimatic-sdk 1.0.0

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 (181) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +30 -0
  3. data/README.md +170 -0
  4. data/bin/console +15 -0
  5. data/lib/spotify_web_api/api_helper.rb +10 -0
  6. data/lib/spotify_web_api/client.rb +165 -0
  7. data/lib/spotify_web_api/configuration.rb +244 -0
  8. data/lib/spotify_web_api/controllers/albums_controller.rb +297 -0
  9. data/lib/spotify_web_api/controllers/artists_controller.rb +188 -0
  10. data/lib/spotify_web_api/controllers/audiobooks_controller.rb +258 -0
  11. data/lib/spotify_web_api/controllers/base_controller.rb +60 -0
  12. data/lib/spotify_web_api/controllers/categories_controller.rb +84 -0
  13. data/lib/spotify_web_api/controllers/chapters_controller.rb +82 -0
  14. data/lib/spotify_web_api/controllers/episodes_controller.rb +241 -0
  15. data/lib/spotify_web_api/controllers/genres_controller.rb +39 -0
  16. data/lib/spotify_web_api/controllers/markets_controller.rb +38 -0
  17. data/lib/spotify_web_api/controllers/o_auth_authorization_controller.rb +82 -0
  18. data/lib/spotify_web_api/controllers/player_controller.rb +525 -0
  19. data/lib/spotify_web_api/controllers/playlists_controller.rb +538 -0
  20. data/lib/spotify_web_api/controllers/search_controller.rb +61 -0
  21. data/lib/spotify_web_api/controllers/shows_controller.rb +263 -0
  22. data/lib/spotify_web_api/controllers/tracks_controller.rb +534 -0
  23. data/lib/spotify_web_api/controllers/users_controller.rb +402 -0
  24. data/lib/spotify_web_api/exceptions/api_exception.rb +21 -0
  25. data/lib/spotify_web_api/exceptions/bad_request_exception.rb +46 -0
  26. data/lib/spotify_web_api/exceptions/forbidden_exception.rb +46 -0
  27. data/lib/spotify_web_api/exceptions/not_found_exception.rb +46 -0
  28. data/lib/spotify_web_api/exceptions/o_auth_provider_exception.rb +64 -0
  29. data/lib/spotify_web_api/exceptions/too_many_requests_exception.rb +46 -0
  30. data/lib/spotify_web_api/exceptions/unauthorized_exception.rb +46 -0
  31. data/lib/spotify_web_api/http/api_response.rb +19 -0
  32. data/lib/spotify_web_api/http/auth/o_auth2.rb +164 -0
  33. data/lib/spotify_web_api/http/http_call_back.rb +10 -0
  34. data/lib/spotify_web_api/http/http_method_enum.rb +10 -0
  35. data/lib/spotify_web_api/http/http_request.rb +10 -0
  36. data/lib/spotify_web_api/http/http_response.rb +10 -0
  37. data/lib/spotify_web_api/http/proxy_settings.rb +22 -0
  38. data/lib/spotify_web_api/models/album_base.rb +189 -0
  39. data/lib/spotify_web_api/models/album_group_enum.rb +44 -0
  40. data/lib/spotify_web_api/models/album_object.rb +273 -0
  41. data/lib/spotify_web_api/models/album_restriction_object.rb +75 -0
  42. data/lib/spotify_web_api/models/album_type_enum.rb +40 -0
  43. data/lib/spotify_web_api/models/artist_discography_album_object.rb +216 -0
  44. data/lib/spotify_web_api/models/artist_object.rb +174 -0
  45. data/lib/spotify_web_api/models/audio_analysis_object.rb +171 -0
  46. data/lib/spotify_web_api/models/audio_features_object.rb +273 -0
  47. data/lib/spotify_web_api/models/audiobook_base.rb +270 -0
  48. data/lib/spotify_web_api/models/audiobook_object.rb +278 -0
  49. data/lib/spotify_web_api/models/author_object.rb +62 -0
  50. data/lib/spotify_web_api/models/base_model.rb +110 -0
  51. data/lib/spotify_web_api/models/categories.rb +125 -0
  52. data/lib/spotify_web_api/models/category_object.rb +95 -0
  53. data/lib/spotify_web_api/models/chapter_base.rb +265 -0
  54. data/lib/spotify_web_api/models/chapter_object.rb +273 -0
  55. data/lib/spotify_web_api/models/chapter_restriction_object.rb +71 -0
  56. data/lib/spotify_web_api/models/context_object.rb +102 -0
  57. data/lib/spotify_web_api/models/copyright_object.rb +82 -0
  58. data/lib/spotify_web_api/models/currently_playing_context_object.rb +168 -0
  59. data/lib/spotify_web_api/models/currently_playing_object.rb +138 -0
  60. data/lib/spotify_web_api/models/cursor_object.rb +71 -0
  61. data/lib/spotify_web_api/models/cursor_paged_artists.rb +60 -0
  62. data/lib/spotify_web_api/models/cursor_paging_object.rb +102 -0
  63. data/lib/spotify_web_api/models/cursor_paging_play_history_object.rb +120 -0
  64. data/lib/spotify_web_api/models/cursor_paging_simplified_artist_object.rb +120 -0
  65. data/lib/spotify_web_api/models/device_object.rb +153 -0
  66. data/lib/spotify_web_api/models/disallows_object.rb +171 -0
  67. data/lib/spotify_web_api/models/episode_base.rb +263 -0
  68. data/lib/spotify_web_api/models/episode_object.rb +368 -0
  69. data/lib/spotify_web_api/models/episode_restriction_object.rb +80 -0
  70. data/lib/spotify_web_api/models/error_object.rb +71 -0
  71. data/lib/spotify_web_api/models/explicit_content_settings_object.rb +74 -0
  72. data/lib/spotify_web_api/models/external_id_object.rb +94 -0
  73. data/lib/spotify_web_api/models/external_url_object.rb +73 -0
  74. data/lib/spotify_web_api/models/followers_object.rb +84 -0
  75. data/lib/spotify_web_api/models/image_object.rb +106 -0
  76. data/lib/spotify_web_api/models/include_external_enum.rb +29 -0
  77. data/lib/spotify_web_api/models/item_type1_enum.rb +26 -0
  78. data/lib/spotify_web_api/models/item_type2_enum.rb +36 -0
  79. data/lib/spotify_web_api/models/item_type3_enum.rb +36 -0
  80. data/lib/spotify_web_api/models/item_type_enum.rb +56 -0
  81. data/lib/spotify_web_api/models/linked_track_object.rb +113 -0
  82. data/lib/spotify_web_api/models/many_albums.rb +69 -0
  83. data/lib/spotify_web_api/models/many_artists.rb +69 -0
  84. data/lib/spotify_web_api/models/many_audio_features.rb +69 -0
  85. data/lib/spotify_web_api/models/many_audiobooks.rb +69 -0
  86. data/lib/spotify_web_api/models/many_chapters.rb +69 -0
  87. data/lib/spotify_web_api/models/many_devices.rb +69 -0
  88. data/lib/spotify_web_api/models/many_episodes.rb +69 -0
  89. data/lib/spotify_web_api/models/many_genres.rb +60 -0
  90. data/lib/spotify_web_api/models/many_simplified_shows.rb +69 -0
  91. data/lib/spotify_web_api/models/many_tracks.rb +69 -0
  92. data/lib/spotify_web_api/models/markets.rb +62 -0
  93. data/lib/spotify_web_api/models/me_albums_request.rb +67 -0
  94. data/lib/spotify_web_api/models/me_episodes_request.rb +64 -0
  95. data/lib/spotify_web_api/models/me_episodes_request1.rb +66 -0
  96. data/lib/spotify_web_api/models/me_following_request.rb +65 -0
  97. data/lib/spotify_web_api/models/me_following_request1.rb +67 -0
  98. data/lib/spotify_web_api/models/me_player_play_request.rb +103 -0
  99. data/lib/spotify_web_api/models/me_player_request.rb +75 -0
  100. data/lib/spotify_web_api/models/me_shows_request.rb +67 -0
  101. data/lib/spotify_web_api/models/me_tracks_request.rb +65 -0
  102. data/lib/spotify_web_api/models/me_tracks_request1.rb +67 -0
  103. data/lib/spotify_web_api/models/meta.rb +127 -0
  104. data/lib/spotify_web_api/models/mode_enum.rb +50 -0
  105. data/lib/spotify_web_api/models/narrator_object.rb +62 -0
  106. data/lib/spotify_web_api/models/o_auth_provider_error_enum.rb +62 -0
  107. data/lib/spotify_web_api/models/o_auth_scope_enum.rb +124 -0
  108. data/lib/spotify_web_api/models/o_auth_token.rb +96 -0
  109. data/lib/spotify_web_api/models/paged_albums.rb +60 -0
  110. data/lib/spotify_web_api/models/paged_categories.rb +60 -0
  111. data/lib/spotify_web_api/models/paging_artist_discography_album_object.rb +125 -0
  112. data/lib/spotify_web_api/models/paging_artist_object.rb +125 -0
  113. data/lib/spotify_web_api/models/paging_featured_playlist_object.rb +71 -0
  114. data/lib/spotify_web_api/models/paging_object.rb +107 -0
  115. data/lib/spotify_web_api/models/paging_playlist_object.rb +125 -0
  116. data/lib/spotify_web_api/models/paging_playlist_track_object.rb +125 -0
  117. data/lib/spotify_web_api/models/paging_saved_album_object.rb +125 -0
  118. data/lib/spotify_web_api/models/paging_saved_audiobook_object.rb +125 -0
  119. data/lib/spotify_web_api/models/paging_saved_episode_object.rb +125 -0
  120. data/lib/spotify_web_api/models/paging_saved_show_object.rb +125 -0
  121. data/lib/spotify_web_api/models/paging_saved_track_object.rb +125 -0
  122. data/lib/spotify_web_api/models/paging_simplified_album_object.rb +125 -0
  123. data/lib/spotify_web_api/models/paging_simplified_audiobook_object.rb +125 -0
  124. data/lib/spotify_web_api/models/paging_simplified_chapter_object.rb +125 -0
  125. data/lib/spotify_web_api/models/paging_simplified_episode_object.rb +125 -0
  126. data/lib/spotify_web_api/models/paging_simplified_show_object.rb +125 -0
  127. data/lib/spotify_web_api/models/paging_simplified_track_object.rb +125 -0
  128. data/lib/spotify_web_api/models/paging_track_object.rb +125 -0
  129. data/lib/spotify_web_api/models/play_history_object.rb +90 -0
  130. data/lib/spotify_web_api/models/playlist_object.rb +213 -0
  131. data/lib/spotify_web_api/models/playlist_owner_object.rb +124 -0
  132. data/lib/spotify_web_api/models/playlist_snapshot_id.rb +62 -0
  133. data/lib/spotify_web_api/models/playlist_track_object.rb +116 -0
  134. data/lib/spotify_web_api/models/playlist_tracks_ref_object.rb +72 -0
  135. data/lib/spotify_web_api/models/playlist_user_object.rb +122 -0
  136. data/lib/spotify_web_api/models/playlists_followers_request.rb +63 -0
  137. data/lib/spotify_web_api/models/playlists_request.rb +96 -0
  138. data/lib/spotify_web_api/models/playlists_tracks_request.rb +84 -0
  139. data/lib/spotify_web_api/models/playlists_tracks_request1.rb +112 -0
  140. data/lib/spotify_web_api/models/playlists_tracks_request2.rb +87 -0
  141. data/lib/spotify_web_api/models/private_user_object.rb +200 -0
  142. data/lib/spotify_web_api/models/public_user_object.rb +144 -0
  143. data/lib/spotify_web_api/models/queue_object.rb +86 -0
  144. data/lib/spotify_web_api/models/reason_enum.rb +43 -0
  145. data/lib/spotify_web_api/models/recommendation_seed_object.rb +120 -0
  146. data/lib/spotify_web_api/models/recommendations_object.rb +86 -0
  147. data/lib/spotify_web_api/models/release_date_precision_enum.rb +40 -0
  148. data/lib/spotify_web_api/models/resume_point_object.rb +84 -0
  149. data/lib/spotify_web_api/models/saved_album_object.rb +85 -0
  150. data/lib/spotify_web_api/models/saved_audiobook_object.rb +85 -0
  151. data/lib/spotify_web_api/models/saved_episode_object.rb +82 -0
  152. data/lib/spotify_web_api/models/saved_show_object.rb +85 -0
  153. data/lib/spotify_web_api/models/saved_track_object.rb +85 -0
  154. data/lib/spotify_web_api/models/search_items.rb +122 -0
  155. data/lib/spotify_web_api/models/section_object.rb +201 -0
  156. data/lib/spotify_web_api/models/segment_object.rb +184 -0
  157. data/lib/spotify_web_api/models/show_base.rb +327 -0
  158. data/lib/spotify_web_api/models/show_object.rb +243 -0
  159. data/lib/spotify_web_api/models/simplified_album_object.rb +284 -0
  160. data/lib/spotify_web_api/models/simplified_artist_object.rb +122 -0
  161. data/lib/spotify_web_api/models/simplified_playlist_object.rb +203 -0
  162. data/lib/spotify_web_api/models/simplified_track_object.rb +251 -0
  163. data/lib/spotify_web_api/models/time_interval_object.rb +81 -0
  164. data/lib/spotify_web_api/models/track.rb +367 -0
  165. data/lib/spotify_web_api/models/track1.rb +62 -0
  166. data/lib/spotify_web_api/models/track_object.rb +301 -0
  167. data/lib/spotify_web_api/models/track_restriction_object.rb +80 -0
  168. data/lib/spotify_web_api/models/type2_enum.rb +26 -0
  169. data/lib/spotify_web_api/models/type3_enum.rb +26 -0
  170. data/lib/spotify_web_api/models/type4_enum.rb +26 -0
  171. data/lib/spotify_web_api/models/type5_enum.rb +26 -0
  172. data/lib/spotify_web_api/models/type6_enum.rb +26 -0
  173. data/lib/spotify_web_api/models/type8_enum.rb +26 -0
  174. data/lib/spotify_web_api/models/type9_enum.rb +26 -0
  175. data/lib/spotify_web_api/models/type_enum.rb +26 -0
  176. data/lib/spotify_web_api/models/users_playlists_request.rb +101 -0
  177. data/lib/spotify_web_api/utilities/date_time_helper.rb +11 -0
  178. data/lib/spotify_web_api/utilities/file_wrapper.rb +28 -0
  179. data/lib/spotify_web_api/utilities/union_type_lookup.rb +73 -0
  180. data/lib/spotify_web_api.rb +200 -0
  181. metadata +264 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5d4fa592a0d734a3686d5528f04197b37e642e51e86f4250947c6dce6e192d69
4
+ data.tar.gz: 8e31f99caa16f9bb5f4c5ab9d5cc09a7a1158b27f7552a9a360eefdd8e279601
5
+ SHA512:
6
+ metadata.gz: 12a396353ca7febf84cedfec1de8fffa2022e758e0c3935c7ef7c488e024da63bcb3b7baafbdb7b016f2b70f14bb653b18c8e93e48654d6ab18c462168d317a0
7
+ data.tar.gz: 2a6e53107befb9d88d82474f5fd343fe8ca140cbd6a8556325b35f83c597b16ba5aad11dcca5f12a2b91b1de62e1cc7706525fdb94a7d5c73fadce2d35f14d6d
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,170 @@
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
+ ```bash
19
+ gem install spotify-apimatic-sdk -v 1.0.0
20
+ ```
21
+
22
+ Or add the gem to your Gemfile and run `bundle`:
23
+
24
+ ```ruby
25
+ gem 'spotify-apimatic-sdk', '1.0.0'
26
+ ```
27
+
28
+ For additional gem details, see the [RubyGems page for the spotify-apimatic-sdk gem](https://rubygems.org/gems/spotify-apimatic-sdk/versions/1.0.0).
29
+
30
+ ## IRB Console Usage
31
+
32
+ You can explore the SDK interactively using IRB in two ways
33
+
34
+ ### 1. Use IRB with Installed Gem
35
+
36
+ Open your system terminal (Command Prompt, Git Bash or macOS Terminal) and type the following command to start the irb console.
37
+
38
+ ```bash
39
+ irb
40
+ ```
41
+
42
+ Now you can load the SDK in the IRB
43
+
44
+ ```ruby
45
+ require 'spotify_web_api'
46
+ include SpotifyWebApi
47
+ ```
48
+
49
+ ### 2. Use IRB within SDK
50
+
51
+ Open your system terminal (Command Prompt, Git Bash or macOS Terminal) and navigate to the root folder of SDK.
52
+
53
+ ```
54
+ cd path/to/spotify_web_api
55
+ ```
56
+
57
+ Now you can start the preconfigured irb console by running the following command
58
+
59
+ ```bash
60
+ ruby bin/console
61
+ ```
62
+
63
+ **_Note:_** This automatically loads the SDK from lib/
64
+
65
+ ## Initialize the API Client
66
+
67
+ **_Note:_** Documentation for the client can be found [here.](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/client.md)
68
+
69
+ The following parameters are configurable for the API Client:
70
+
71
+ | Parameter | Type | Description |
72
+ | --- | --- | --- |
73
+ | environment | [`Environment`](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/README.md#environments) | The API environment. <br> **Default: `Environment.PRODUCTION`** |
74
+ | connection | `Faraday::Connection` | The Faraday connection object passed by the SDK user for making requests |
75
+ | adapter | `Faraday::Adapter` | The Faraday adapter object passed by the SDK user for performing http requests |
76
+ | timeout | `Float` | The value to use for connection timeout. <br> **Default: 60** |
77
+ | max_retries | `Integer` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
78
+ | retry_interval | `Float` | Pause in seconds between retries. <br> **Default: 1** |
79
+ | backoff_factor | `Float` | The amount to multiply each successive retry's interval amount by in order to provide backoff. <br> **Default: 2** |
80
+ | retry_statuses | `Array` | A list of HTTP statuses to retry. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
81
+ | retry_methods | `Array` | A list of HTTP methods to retry. <br> **Default: %i[get put]** |
82
+ | http_callback | `HttpCallBack` | The Http CallBack allows defining callables for pre and post API calls. |
83
+ | proxy_settings | [`ProxySettings`](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/proxy-settings.md) | Optional proxy configuration to route HTTP requests through a proxy server. |
84
+ | authorization_code_auth_credentials | [`AuthorizationCodeAuthCredentials`](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/auth/oauth-2-authorization-code-grant.md) | The credential object for OAuth 2 Authorization Code Grant |
85
+
86
+ The API client can be initialized as follows:
87
+
88
+ ### Code-Based Client Initialization
89
+
90
+ ```ruby
91
+ require 'spotify_web_api'
92
+ include SpotifyWebApi
93
+
94
+ client = Client.new(
95
+ authorization_code_auth_credentials: AuthorizationCodeAuthCredentials.new(
96
+ o_auth_client_id: 'OAuthClientId',
97
+ o_auth_client_secret: 'OAuthClientSecret',
98
+ o_auth_redirect_uri: 'OAuthRedirectUri',
99
+ o_auth_scopes: [
100
+ OAuthScopeEnum::APP_REMOTE_CONTROL,
101
+ OAuthScopeEnum::PLAYLIST_READ_PRIVATE
102
+ ]
103
+ ),
104
+ environment: Environment::PRODUCTION
105
+ )
106
+ ```
107
+
108
+ ### Environment-Based Client Initialization
109
+
110
+ ```ruby
111
+ require 'spotify_web_api'
112
+ include SpotifyWebApi
113
+
114
+ # Create client from environment
115
+ client = Client.from_env
116
+ ```
117
+
118
+ See the [`Environment-Based Client Initialization`](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/environment-based-client-initialization.md) section for details.
119
+
120
+ ## Environments
121
+
122
+ The SDK can be configured to use a different environment for making API calls. Available environments are:
123
+
124
+ ### Fields
125
+
126
+ | Name | Description |
127
+ | --- | --- |
128
+ | PRODUCTION | **Default** |
129
+
130
+ ## Authorization
131
+
132
+ This API uses the following authentication schemes.
133
+
134
+ * [`oauth_2_0 (OAuth 2 Authorization Code Grant)`](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/auth/oauth-2-authorization-code-grant.md)
135
+
136
+ ## List of APIs
137
+
138
+ * [Albums](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/controllers/albums.md)
139
+ * [Artists](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/controllers/artists.md)
140
+ * [Audiobooks](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/controllers/audiobooks.md)
141
+ * [Categories](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/controllers/categories.md)
142
+ * [Chapters](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/controllers/chapters.md)
143
+ * [Episodes](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/controllers/episodes.md)
144
+ * [Genres](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/controllers/genres.md)
145
+ * [Markets](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/controllers/markets.md)
146
+ * [Player](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/controllers/player.md)
147
+ * [Playlists](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/controllers/playlists.md)
148
+ * [Search](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/controllers/search.md)
149
+ * [Shows](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/controllers/shows.md)
150
+ * [Tracks](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/controllers/tracks.md)
151
+ * [Users](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/controllers/users.md)
152
+
153
+ ## SDK Infrastructure
154
+
155
+ ### Configuration
156
+
157
+ * [ProxySettings](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/proxy-settings.md)
158
+ * [Environment-Based Client Initialization](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/environment-based-client-initialization.md)
159
+
160
+ ### HTTP
161
+
162
+ * [HttpResponse](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/http-response.md)
163
+ * [HttpRequest](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/http-request.md)
164
+
165
+ ### Utilities
166
+
167
+ * [ApiResponse](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/api-response.md)
168
+ * [ApiHelper](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/api-helper.md)
169
+ * [DateTimeHelper](https://www.github.com/sdks-io/spotify-apimatic-ruby-sdk/tree/1.0.0/doc/date-time-helper.md)
170
+
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Load the lib folder into Ruby's load path
4
+ $LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
5
+
6
+ # Require the gem
7
+ require 'spotify_web_api'
8
+
9
+ puts 'SpotifyWebApi SDK loaded!'
10
+ puts 'You can now create a client with: client = SpotifyWebApi::Client.new'
11
+ puts 'Or use from_env: client = SpotifyWebApi::Client.from_env'
12
+
13
+ # Start an interactive IRB session
14
+ require 'irb'
15
+ IRB.start
@@ -0,0 +1,10 @@
1
+ # spotify_web_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v3.0 (
4
+ # https://www.apimatic.io ).
5
+
6
+ module SpotifyWebApi
7
+ # API utility class
8
+ class APIHelper < CoreLibrary::ApiHelper
9
+ end
10
+ end
@@ -0,0 +1,165 @@
1
+ # spotify_web_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v3.0 (
4
+ # https://www.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
+ def user_agent_detail
13
+ config.user_agent_detail
14
+ end
15
+
16
+ # Returns the configured authentication oauth_2_0 instance.
17
+ def oauth_2_0
18
+ @auth_managers['oauth_2_0']
19
+ end
20
+
21
+ # Access to albums controller.
22
+ # @return [AlbumsController] Returns the controller instance.
23
+ def albums
24
+ @albums ||= AlbumsController.new @global_configuration
25
+ end
26
+
27
+ # Access to artists controller.
28
+ # @return [ArtistsController] Returns the controller instance.
29
+ def artists
30
+ @artists ||= ArtistsController.new @global_configuration
31
+ end
32
+
33
+ # Access to audiobooks controller.
34
+ # @return [AudiobooksController] Returns the controller instance.
35
+ def audiobooks
36
+ @audiobooks ||= AudiobooksController.new @global_configuration
37
+ end
38
+
39
+ # Access to categories controller.
40
+ # @return [CategoriesController] Returns the controller instance.
41
+ def categories
42
+ @categories ||= CategoriesController.new @global_configuration
43
+ end
44
+
45
+ # Access to chapters controller.
46
+ # @return [ChaptersController] Returns the controller instance.
47
+ def chapters
48
+ @chapters ||= ChaptersController.new @global_configuration
49
+ end
50
+
51
+ # Access to episodes controller.
52
+ # @return [EpisodesController] Returns the controller instance.
53
+ def episodes
54
+ @episodes ||= EpisodesController.new @global_configuration
55
+ end
56
+
57
+ # Access to genres controller.
58
+ # @return [GenresController] Returns the controller instance.
59
+ def genres
60
+ @genres ||= GenresController.new @global_configuration
61
+ end
62
+
63
+ # Access to markets controller.
64
+ # @return [MarketsController] Returns the controller instance.
65
+ def markets
66
+ @markets ||= MarketsController.new @global_configuration
67
+ end
68
+
69
+ # Access to player controller.
70
+ # @return [PlayerController] Returns the controller instance.
71
+ def player
72
+ @player ||= PlayerController.new @global_configuration
73
+ end
74
+
75
+ # Access to playlists controller.
76
+ # @return [PlaylistsController] Returns the controller instance.
77
+ def playlists
78
+ @playlists ||= PlaylistsController.new @global_configuration
79
+ end
80
+
81
+ # Access to search controller.
82
+ # @return [SearchController] Returns the controller instance.
83
+ def search
84
+ @search ||= SearchController.new @global_configuration
85
+ end
86
+
87
+ # Access to shows controller.
88
+ # @return [ShowsController] Returns the controller instance.
89
+ def shows
90
+ @shows ||= ShowsController.new @global_configuration
91
+ end
92
+
93
+ # Access to tracks controller.
94
+ # @return [TracksController] Returns the controller instance.
95
+ def tracks
96
+ @tracks ||= TracksController.new @global_configuration
97
+ end
98
+
99
+ # Access to users controller.
100
+ # @return [UsersController] Returns the controller instance.
101
+ def users
102
+ @users ||= UsersController.new @global_configuration
103
+ end
104
+
105
+ # Access to o_auth_authorization controller.
106
+ # @return [OAuthAuthorizationController] Returns the controller instance.
107
+ def o_auth_authorization
108
+ @o_auth_authorization ||= OAuthAuthorizationController.new @global_configuration
109
+ end
110
+
111
+ def initialize(
112
+ connection: nil, adapter: :net_http_persistent, timeout: 60,
113
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
114
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
115
+ retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
116
+ environment: Environment::PRODUCTION, o_auth_client_id: nil,
117
+ o_auth_client_secret: nil, o_auth_redirect_uri: nil, o_auth_token: nil,
118
+ o_auth_scopes: nil, authorization_code_auth_credentials: nil, config: nil
119
+ )
120
+ @config = if config.nil?
121
+ Configuration.new(
122
+ connection: connection, adapter: adapter, timeout: timeout,
123
+ max_retries: max_retries, retry_interval: retry_interval,
124
+ backoff_factor: backoff_factor,
125
+ retry_statuses: retry_statuses,
126
+ retry_methods: retry_methods, http_callback: http_callback,
127
+ proxy_settings: proxy_settings, environment: environment,
128
+ o_auth_client_id: o_auth_client_id,
129
+ o_auth_client_secret: o_auth_client_secret,
130
+ o_auth_redirect_uri: o_auth_redirect_uri,
131
+ o_auth_token: o_auth_token, o_auth_scopes: o_auth_scopes,
132
+ authorization_code_auth_credentials: authorization_code_auth_credentials
133
+ )
134
+ else
135
+ config
136
+ end
137
+
138
+ @global_configuration = GlobalConfiguration.new(client_configuration: @config)
139
+ .base_uri_executor(@config.method(:get_base_uri))
140
+ .global_errors(BaseController::GLOBAL_ERRORS)
141
+ .user_agent(BaseController.user_agent)
142
+
143
+ initialize_auth_managers(@global_configuration)
144
+ @global_configuration = @global_configuration.auth_managers(@auth_managers)
145
+ end
146
+
147
+ # Initializes the auth managers hash used for authenticating API calls.
148
+ # @param [GlobalConfiguration] global_config The global configuration of the SDK)
149
+ def initialize_auth_managers(global_config)
150
+ @auth_managers = {}
151
+ http_client_config = global_config.client_configuration
152
+ %w[oauth_2_0].each { |auth| @auth_managers[auth] = nil }
153
+ @auth_managers['oauth_2_0'] = OAuth2.new(
154
+ http_client_config.authorization_code_auth_credentials, global_config
155
+ )
156
+ end
157
+
158
+ # Creates a client directly from environment variables.
159
+ def self.from_env(**overrides)
160
+ default_config = Configuration.build_default_config_from_env
161
+ new_config = default_config.clone_with(**overrides)
162
+ new(config: new_config)
163
+ end
164
+ end
165
+ end
@@ -0,0 +1,244 @@
1
+ # spotify_web_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v3.0 (
4
+ # https://www.apimatic.io ).
5
+
6
+ module SpotifyWebApi
7
+ # An enum for SDK environments.
8
+ class Environment
9
+ ENVIRONMENT = [
10
+ PRODUCTION = 'production'.freeze
11
+ ].freeze
12
+
13
+ # Converts a string or symbol into a valid Environment constant.
14
+ def self.from_value(value, default_value = PRODUCTION)
15
+ return default_value if value.nil?
16
+
17
+ default_value
18
+ end
19
+ end
20
+
21
+ # An enum for API servers.
22
+ class Server
23
+ SERVER = [
24
+ DEFAULT = 'default'.freeze,
25
+ AUTH_SERVER = 'auth server'.freeze
26
+ ].freeze
27
+
28
+ # Converts a string or symbol into a valid Server constant.
29
+ def self.from_value(value, default_value = DEFAULT)
30
+ return default_value if value.nil?
31
+
32
+ str = value.to_s.strip.downcase
33
+ case str
34
+ when 'default' then DEFAULT
35
+ when 'auth_server' then AUTH_SERVER
36
+
37
+ else
38
+ warn "[Server] Unknown server '#{value}', falling back to #{default_value} "
39
+ default_value
40
+ end
41
+ end
42
+ end
43
+
44
+ # All configuration including auth info and base URI for the API access
45
+ # are configured in this class.
46
+ class Configuration < CoreLibrary::HttpClientConfiguration
47
+ def o_auth_client_id
48
+ @authorization_code_auth_credentials.o_auth_client_id
49
+ end
50
+
51
+ def o_auth_client_secret
52
+ @authorization_code_auth_credentials.o_auth_client_secret
53
+ end
54
+
55
+ def o_auth_redirect_uri
56
+ @authorization_code_auth_credentials.o_auth_redirect_uri
57
+ end
58
+
59
+ def o_auth_token
60
+ @authorization_code_auth_credentials.o_auth_token
61
+ end
62
+
63
+ def o_auth_scopes
64
+ @authorization_code_auth_credentials.o_auth_scopes
65
+ end
66
+
67
+ # The attribute readers for properties.
68
+ attr_reader :environment, :authorization_code_auth_credentials
69
+
70
+ class << self
71
+ attr_reader :environments
72
+ end
73
+
74
+ def initialize(
75
+ connection: nil, adapter: :net_http_persistent, timeout: 60,
76
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
77
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
78
+ retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
79
+ environment: Environment::PRODUCTION, o_auth_client_id: nil,
80
+ o_auth_client_secret: nil, o_auth_redirect_uri: nil, o_auth_token: nil,
81
+ o_auth_scopes: nil, authorization_code_auth_credentials: nil
82
+ )
83
+ super connection: connection, adapter: adapter, timeout: timeout,
84
+ max_retries: max_retries, retry_interval: retry_interval,
85
+ backoff_factor: backoff_factor, retry_statuses: retry_statuses,
86
+ retry_methods: retry_methods, http_callback: http_callback,
87
+ proxy_settings: proxy_settings
88
+
89
+ # Current API environment
90
+ @environment = String(environment)
91
+
92
+ # OAuth 2 Client ID
93
+ @o_auth_client_id = o_auth_client_id
94
+
95
+ # OAuth 2 Client Secret
96
+ @o_auth_client_secret = o_auth_client_secret
97
+
98
+ # OAuth 2 Redirection endpoint or Callback Uri
99
+ @o_auth_redirect_uri = o_auth_redirect_uri
100
+
101
+ # Object for storing information about the OAuth token
102
+ @o_auth_token = if o_auth_token.is_a? OAuthToken
103
+ OAuthToken.from_hash o_auth_token.to_hash
104
+ else
105
+ o_auth_token
106
+ end
107
+
108
+ # List of scopes that apply to the OAuth token
109
+ @o_auth_scopes = o_auth_scopes
110
+
111
+ # Initializing OAuth 2 Authorization Code Grant credentials with the provided auth parameters
112
+ @authorization_code_auth_credentials = create_auth_credentials_object(
113
+ o_auth_client_id, o_auth_client_secret, o_auth_redirect_uri,
114
+ o_auth_token, o_auth_scopes, authorization_code_auth_credentials
115
+ )
116
+
117
+ # The Http Client to use for making requests.
118
+ set_http_client CoreLibrary::FaradayClient.new(self)
119
+ end
120
+
121
+ def clone_with(connection: nil, adapter: nil, timeout: nil,
122
+ max_retries: nil, retry_interval: nil, backoff_factor: nil,
123
+ retry_statuses: nil, retry_methods: nil, http_callback: nil,
124
+ proxy_settings: nil, environment: nil, o_auth_client_id: nil,
125
+ o_auth_client_secret: nil, o_auth_redirect_uri: nil,
126
+ o_auth_token: nil, o_auth_scopes: nil,
127
+ authorization_code_auth_credentials: nil)
128
+ connection ||= self.connection
129
+ adapter ||= self.adapter
130
+ timeout ||= self.timeout
131
+ max_retries ||= self.max_retries
132
+ retry_interval ||= self.retry_interval
133
+ backoff_factor ||= self.backoff_factor
134
+ retry_statuses ||= self.retry_statuses
135
+ retry_methods ||= self.retry_methods
136
+ http_callback ||= self.http_callback
137
+ proxy_settings ||= self.proxy_settings
138
+ environment ||= self.environment
139
+ authorization_code_auth_credentials = create_auth_credentials_object(
140
+ o_auth_client_id, o_auth_client_secret, o_auth_redirect_uri,
141
+ o_auth_token, o_auth_scopes,
142
+ authorization_code_auth_credentials || self.authorization_code_auth_credentials
143
+ )
144
+
145
+ Configuration.new(
146
+ connection: connection, adapter: adapter, timeout: timeout,
147
+ max_retries: max_retries, retry_interval: retry_interval,
148
+ backoff_factor: backoff_factor, retry_statuses: retry_statuses,
149
+ retry_methods: retry_methods, http_callback: http_callback,
150
+ proxy_settings: proxy_settings, environment: environment,
151
+ authorization_code_auth_credentials: authorization_code_auth_credentials
152
+ )
153
+ end
154
+
155
+ def create_auth_credentials_object(o_auth_client_id, o_auth_client_secret,
156
+ o_auth_redirect_uri, o_auth_token,
157
+ o_auth_scopes,
158
+ authorization_code_auth_credentials)
159
+ return authorization_code_auth_credentials if o_auth_client_id.nil? &&
160
+ o_auth_client_secret.nil? &&
161
+ o_auth_redirect_uri.nil? &&
162
+ o_auth_token.nil? &&
163
+ o_auth_scopes.nil?
164
+
165
+ warn('The \'o_auth_client_id\', \'o_auth_client_secret\', \'o_auth_redir'\
166
+ 'ect_uri\', \'o_auth_token\', \'o_auth_scopes\' params are deprecat'\
167
+ 'ed. Use \'authorization_code_auth_credentials\' param instead.')
168
+
169
+ unless authorization_code_auth_credentials.nil?
170
+ return authorization_code_auth_credentials.clone_with(
171
+ o_auth_client_id: o_auth_client_id,
172
+ o_auth_client_secret: o_auth_client_secret,
173
+ o_auth_redirect_uri: o_auth_redirect_uri,
174
+ o_auth_token: o_auth_token,
175
+ o_auth_scopes: o_auth_scopes
176
+ )
177
+ end
178
+
179
+ AuthorizationCodeAuthCredentials.new(
180
+ o_auth_client_id: o_auth_client_id,
181
+ o_auth_client_secret: o_auth_client_secret,
182
+ o_auth_redirect_uri: o_auth_redirect_uri, o_auth_token: o_auth_token,
183
+ o_auth_scopes: o_auth_scopes
184
+ )
185
+ end
186
+
187
+ # All the environments the SDK can run in.
188
+ ENVIRONMENTS = {
189
+ Environment::PRODUCTION => {
190
+ Server::DEFAULT => 'https://api.spotify.com/v1',
191
+ Server::AUTH_SERVER => 'https://accounts.spotify.com'
192
+ }
193
+ }.freeze
194
+
195
+ # Generates the appropriate base URI for the environment and the server.
196
+ # @param [Configuration::Server] server The server enum for which the base URI is
197
+ # required.
198
+ # @return [String] The base URI.
199
+ def get_base_uri(server = Server::DEFAULT)
200
+ ENVIRONMENTS[environment][server].clone
201
+ end
202
+
203
+ # Builds a Configuration instance using environment variables.
204
+ def self.build_default_config_from_env
205
+ # === Core environment ===
206
+ environment = Environment.from_value(ENV.fetch('ENVIRONMENT', 'production'))
207
+ timeout = (ENV['TIMEOUT'] || 60).to_f
208
+ max_retries = (ENV['MAX_RETRIES'] || 0).to_i
209
+ retry_interval = (ENV['RETRY_INTERVAL'] || 1).to_f
210
+ backoff_factor = (ENV['BACKOFF_FACTOR'] || 2).to_f
211
+ retry_statuses = ENV.fetch('RETRY_STATUSES',
212
+ '[408, 413, 429, 500, 502, 503, 504, 521, 522, 524]').gsub(/[\[\]]/, '')
213
+ .split(',')
214
+ .map(&:strip)
215
+ .map do |item|
216
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
217
+ end
218
+ retry_methods = ENV.fetch('RETRY_METHODS', '%i[get put]').gsub(/[\[\]]/, '')
219
+ .split(',')
220
+ .map(&:strip)
221
+ .map do |item|
222
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
223
+ end
224
+
225
+ # === Authentication credentials ===
226
+ authorization_code_auth_credentials = AuthorizationCodeAuthCredentials.from_env
227
+
228
+ # === Proxy settings ===
229
+ proxy_settings = ProxySettings.from_env
230
+
231
+ Configuration.new(
232
+ environment: environment,
233
+ timeout: timeout,
234
+ max_retries: max_retries,
235
+ retry_interval: retry_interval,
236
+ backoff_factor: backoff_factor,
237
+ retry_statuses: retry_statuses,
238
+ retry_methods: retry_methods,
239
+ authorization_code_auth_credentials: authorization_code_auth_credentials,
240
+ proxy_settings: proxy_settings
241
+ )
242
+ end
243
+ end
244
+ end