spotify-api-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.
- checksums.yaml +7 -0
- data/LICENSE +30 -0
- data/README.md +107 -0
- data/lib/spotify_web_api/api_helper.rb +10 -0
- data/lib/spotify_web_api/client.rb +154 -0
- data/lib/spotify_web_api/configuration.rb +180 -0
- data/lib/spotify_web_api/controllers/albums_controller.rb +295 -0
- data/lib/spotify_web_api/controllers/artists_controller.rb +187 -0
- data/lib/spotify_web_api/controllers/audiobooks_controller.rb +258 -0
- data/lib/spotify_web_api/controllers/base_controller.rb +66 -0
- data/lib/spotify_web_api/controllers/categories_controller.rb +83 -0
- data/lib/spotify_web_api/controllers/chapters_controller.rb +82 -0
- data/lib/spotify_web_api/controllers/episodes_controller.rb +239 -0
- data/lib/spotify_web_api/controllers/genres_controller.rb +39 -0
- data/lib/spotify_web_api/controllers/markets_controller.rb +38 -0
- data/lib/spotify_web_api/controllers/o_auth_authorization_controller.rb +82 -0
- data/lib/spotify_web_api/controllers/player_controller.rb +509 -0
- data/lib/spotify_web_api/controllers/playlists_controller.rb +521 -0
- data/lib/spotify_web_api/controllers/search_controller.rb +60 -0
- data/lib/spotify_web_api/controllers/shows_controller.rb +261 -0
- data/lib/spotify_web_api/controllers/tracks_controller.rb +491 -0
- data/lib/spotify_web_api/controllers/users_controller.rb +396 -0
- data/lib/spotify_web_api/exceptions/api_exception.rb +10 -0
- data/lib/spotify_web_api/exceptions/bad_request_exception.rb +32 -0
- data/lib/spotify_web_api/exceptions/forbidden_exception.rb +32 -0
- data/lib/spotify_web_api/exceptions/not_found_exception.rb +32 -0
- data/lib/spotify_web_api/exceptions/o_auth_provider_exception.rb +48 -0
- data/lib/spotify_web_api/exceptions/too_many_requests_exception.rb +32 -0
- data/lib/spotify_web_api/exceptions/unauthorized_exception.rb +32 -0
- data/lib/spotify_web_api/http/api_response.rb +21 -0
- data/lib/spotify_web_api/http/auth/o_auth2.rb +146 -0
- data/lib/spotify_web_api/http/http_call_back.rb +10 -0
- data/lib/spotify_web_api/http/http_method_enum.rb +10 -0
- data/lib/spotify_web_api/http/http_request.rb +10 -0
- data/lib/spotify_web_api/http/http_response.rb +10 -0
- data/lib/spotify_web_api/models/album_base.rb +168 -0
- data/lib/spotify_web_api/models/album_group_enum.rb +29 -0
- data/lib/spotify_web_api/models/album_object.rb +247 -0
- data/lib/spotify_web_api/models/album_restriction_object.rb +53 -0
- data/lib/spotify_web_api/models/album_type_enum.rb +26 -0
- data/lib/spotify_web_api/models/artist_discography_album_object.rb +194 -0
- data/lib/spotify_web_api/models/artist_object.rb +147 -0
- data/lib/spotify_web_api/models/audio_analysis_object.rb +156 -0
- data/lib/spotify_web_api/models/audio_features_object.rb +249 -0
- data/lib/spotify_web_api/models/audiobook_base.rb +245 -0
- data/lib/spotify_web_api/models/audiobook_object.rb +253 -0
- data/lib/spotify_web_api/models/author_object.rb +50 -0
- data/lib/spotify_web_api/models/base_model.rb +62 -0
- data/lib/spotify_web_api/models/categories.rb +110 -0
- data/lib/spotify_web_api/models/category_object.rb +82 -0
- data/lib/spotify_web_api/models/chapter_base.rb +237 -0
- data/lib/spotify_web_api/models/chapter_object.rb +245 -0
- data/lib/spotify_web_api/models/chapter_restriction_object.rb +59 -0
- data/lib/spotify_web_api/models/context_object.rb +78 -0
- data/lib/spotify_web_api/models/copyright_object.rb +60 -0
- data/lib/spotify_web_api/models/currently_playing_context_object.rb +137 -0
- data/lib/spotify_web_api/models/currently_playing_object.rb +109 -0
- data/lib/spotify_web_api/models/cursor_object.rb +59 -0
- data/lib/spotify_web_api/models/cursor_paged_artists.rb +48 -0
- data/lib/spotify_web_api/models/cursor_paging_object.rb +88 -0
- data/lib/spotify_web_api/models/cursor_paging_play_history_object.rb +106 -0
- data/lib/spotify_web_api/models/cursor_paging_simplified_artist_object.rb +106 -0
- data/lib/spotify_web_api/models/device_object.rb +126 -0
- data/lib/spotify_web_api/models/disallows_object.rb +140 -0
- data/lib/spotify_web_api/models/episode_base.rb +237 -0
- data/lib/spotify_web_api/models/episode_object.rb +246 -0
- data/lib/spotify_web_api/models/episode_restriction_object.rb +58 -0
- data/lib/spotify_web_api/models/error_object.rb +59 -0
- data/lib/spotify_web_api/models/explicit_content_settings_object.rb +61 -0
- data/lib/spotify_web_api/models/external_id_object.rb +72 -0
- data/lib/spotify_web_api/models/external_url_object.rb +51 -0
- data/lib/spotify_web_api/models/followers_object.rb +62 -0
- data/lib/spotify_web_api/models/image_object.rb +67 -0
- data/lib/spotify_web_api/models/include_external_enum.rb +23 -0
- data/lib/spotify_web_api/models/item_type1_enum.rb +20 -0
- data/lib/spotify_web_api/models/item_type2_enum.rb +23 -0
- data/lib/spotify_web_api/models/item_type3_enum.rb +23 -0
- data/lib/spotify_web_api/models/item_type_enum.rb +38 -0
- data/lib/spotify_web_api/models/linked_track_object.rb +89 -0
- data/lib/spotify_web_api/models/many_albums.rb +57 -0
- data/lib/spotify_web_api/models/many_artists.rb +57 -0
- data/lib/spotify_web_api/models/many_audio_features.rb +57 -0
- data/lib/spotify_web_api/models/many_audiobooks.rb +57 -0
- data/lib/spotify_web_api/models/many_chapters.rb +57 -0
- data/lib/spotify_web_api/models/many_devices.rb +57 -0
- data/lib/spotify_web_api/models/many_episodes.rb +57 -0
- data/lib/spotify_web_api/models/many_genres.rb +48 -0
- data/lib/spotify_web_api/models/many_simplified_shows.rb +57 -0
- data/lib/spotify_web_api/models/many_tracks.rb +57 -0
- data/lib/spotify_web_api/models/markets.rb +50 -0
- data/lib/spotify_web_api/models/me_albums_request.rb +55 -0
- data/lib/spotify_web_api/models/me_episodes_request.rb +52 -0
- data/lib/spotify_web_api/models/me_episodes_request1.rb +54 -0
- data/lib/spotify_web_api/models/me_following_request.rb +53 -0
- data/lib/spotify_web_api/models/me_following_request1.rb +55 -0
- data/lib/spotify_web_api/models/me_player_play_request.rb +89 -0
- data/lib/spotify_web_api/models/me_player_request.rb +63 -0
- data/lib/spotify_web_api/models/me_shows_request.rb +55 -0
- data/lib/spotify_web_api/models/me_tracks_request.rb +53 -0
- data/lib/spotify_web_api/models/me_tracks_request1.rb +55 -0
- data/lib/spotify_web_api/models/meta.rb +110 -0
- data/lib/spotify_web_api/models/mode_enum.rb +30 -0
- data/lib/spotify_web_api/models/narrator_object.rb +50 -0
- data/lib/spotify_web_api/models/o_auth_provider_error_enum.rb +45 -0
- data/lib/spotify_web_api/models/o_auth_scope_enum.rb +94 -0
- data/lib/spotify_web_api/models/o_auth_token.rb +96 -0
- data/lib/spotify_web_api/models/paged_albums.rb +48 -0
- data/lib/spotify_web_api/models/paged_categories.rb +48 -0
- data/lib/spotify_web_api/models/paging_artist_discography_album_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_artist_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_featured_playlist_object.rb +59 -0
- data/lib/spotify_web_api/models/paging_object.rb +93 -0
- data/lib/spotify_web_api/models/paging_playlist_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_playlist_track_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_saved_album_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_saved_audiobook_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_saved_episode_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_saved_show_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_saved_track_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_simplified_album_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_simplified_audiobook_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_simplified_chapter_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_simplified_episode_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_simplified_show_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_simplified_track_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_track_object.rb +110 -0
- data/lib/spotify_web_api/models/play_history_object.rb +77 -0
- data/lib/spotify_web_api/models/playlist_object.rb +193 -0
- data/lib/spotify_web_api/models/playlist_owner_object.rb +109 -0
- data/lib/spotify_web_api/models/playlist_snapshot_id.rb +50 -0
- data/lib/spotify_web_api/models/playlist_track_object.rb +90 -0
- data/lib/spotify_web_api/models/playlist_tracks_ref_object.rb +60 -0
- data/lib/spotify_web_api/models/playlist_user_object.rb +98 -0
- data/lib/spotify_web_api/models/playlists_followers_request.rb +51 -0
- data/lib/spotify_web_api/models/playlists_request.rb +82 -0
- data/lib/spotify_web_api/models/playlists_tracks_request.rb +72 -0
- data/lib/spotify_web_api/models/playlists_tracks_request1.rb +97 -0
- data/lib/spotify_web_api/models/playlists_tracks_request2.rb +75 -0
- data/lib/spotify_web_api/models/private_user_object.rb +181 -0
- data/lib/spotify_web_api/models/public_user_object.rb +128 -0
- data/lib/spotify_web_api/models/queue_object.rb +60 -0
- data/lib/spotify_web_api/models/reason_enum.rb +29 -0
- data/lib/spotify_web_api/models/recommendation_seed_object.rb +104 -0
- data/lib/spotify_web_api/models/recommendations_object.rb +74 -0
- data/lib/spotify_web_api/models/release_date_precision_enum.rb +26 -0
- data/lib/spotify_web_api/models/resume_point_object.rb +60 -0
- data/lib/spotify_web_api/models/saved_album_object.rb +73 -0
- data/lib/spotify_web_api/models/saved_audiobook_object.rb +73 -0
- data/lib/spotify_web_api/models/saved_episode_object.rb +70 -0
- data/lib/spotify_web_api/models/saved_show_object.rb +73 -0
- data/lib/spotify_web_api/models/saved_track_object.rb +73 -0
- data/lib/spotify_web_api/models/search_items.rb +107 -0
- data/lib/spotify_web_api/models/section_object.rb +180 -0
- data/lib/spotify_web_api/models/segment_object.rb +166 -0
- data/lib/spotify_web_api/models/show_base.rb +211 -0
- data/lib/spotify_web_api/models/show_object.rb +219 -0
- data/lib/spotify_web_api/models/simplified_album_object.rb +186 -0
- data/lib/spotify_web_api/models/simplified_artist_object.rb +98 -0
- data/lib/spotify_web_api/models/simplified_playlist_object.rb +184 -0
- data/lib/spotify_web_api/models/simplified_track_object.rb +227 -0
- data/lib/spotify_web_api/models/time_interval_object.rb +68 -0
- data/lib/spotify_web_api/models/track.rb +331 -0
- data/lib/spotify_web_api/models/track1.rb +50 -0
- data/lib/spotify_web_api/models/track_object.rb +265 -0
- data/lib/spotify_web_api/models/track_restriction_object.rb +58 -0
- data/lib/spotify_web_api/models/type2_enum.rb +20 -0
- data/lib/spotify_web_api/models/type3_enum.rb +20 -0
- data/lib/spotify_web_api/models/type4_enum.rb +20 -0
- data/lib/spotify_web_api/models/type6_enum.rb +20 -0
- data/lib/spotify_web_api/models/type7_enum.rb +20 -0
- data/lib/spotify_web_api/models/type8_enum.rb +20 -0
- data/lib/spotify_web_api/models/type9_enum.rb +20 -0
- data/lib/spotify_web_api/models/type_enum.rb +20 -0
- data/lib/spotify_web_api/models/users_playlists_request.rb +87 -0
- data/lib/spotify_web_api/utilities/date_time_helper.rb +11 -0
- data/lib/spotify_web_api/utilities/file_wrapper.rb +16 -0
- data/lib/spotify_web_api.rb +198 -0
- metadata +264 -0
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
# spotify_web_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
|
4
|
+
# ( https://apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module SpotifyWebApi
|
|
7
|
+
# TracksController
|
|
8
|
+
class TracksController < BaseController
|
|
9
|
+
# Get Spotify catalog information for a single track identified by its
|
|
10
|
+
# unique Spotify ID.
|
|
11
|
+
# @param [String] id Required parameter: Example:
|
|
12
|
+
# @param [String] market Optional parameter: Example:
|
|
13
|
+
# @return [TrackObject] response from the API call
|
|
14
|
+
def get_track(id,
|
|
15
|
+
market: nil)
|
|
16
|
+
new_api_call_builder
|
|
17
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
18
|
+
'/tracks/{id}',
|
|
19
|
+
Server::DEFAULT)
|
|
20
|
+
.template_param(new_parameter(id, key: 'id')
|
|
21
|
+
.should_encode(true))
|
|
22
|
+
.query_param(new_parameter(market, key: 'market'))
|
|
23
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
24
|
+
.auth(Single.new('oauth_2_0')))
|
|
25
|
+
.response(new_response_handler
|
|
26
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
27
|
+
.deserialize_into(TrackObject.method(:from_hash))
|
|
28
|
+
.is_api_response(true)
|
|
29
|
+
.local_error('401',
|
|
30
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
|
31
|
+
' token or\nthe access token has expired. You should'\
|
|
32
|
+
' re-authenticate the user.\n",
|
|
33
|
+
UnauthorizedException)
|
|
34
|
+
.local_error('403',
|
|
35
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
|
36
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
|
37
|
+
' won't help here.\n",
|
|
38
|
+
ForbiddenException)
|
|
39
|
+
.local_error('429',
|
|
40
|
+
"The app has exceeded its rate limits.\n",
|
|
41
|
+
TooManyRequestsException))
|
|
42
|
+
.execute
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Get Spotify catalog information for multiple tracks based on their Spotify
|
|
46
|
+
# IDs.
|
|
47
|
+
# @param [String] ids Required parameter: Example:
|
|
48
|
+
# @param [String] market Optional parameter: Example:
|
|
49
|
+
# @return [ManyTracks] response from the API call
|
|
50
|
+
def get_several_tracks(ids,
|
|
51
|
+
market: nil)
|
|
52
|
+
new_api_call_builder
|
|
53
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
54
|
+
'/tracks',
|
|
55
|
+
Server::DEFAULT)
|
|
56
|
+
.query_param(new_parameter(ids, key: 'ids'))
|
|
57
|
+
.query_param(new_parameter(market, key: 'market'))
|
|
58
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
59
|
+
.auth(Single.new('oauth_2_0')))
|
|
60
|
+
.response(new_response_handler
|
|
61
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
62
|
+
.deserialize_into(ManyTracks.method(:from_hash))
|
|
63
|
+
.is_api_response(true)
|
|
64
|
+
.local_error('401',
|
|
65
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
|
66
|
+
' token or\nthe access token has expired. You should'\
|
|
67
|
+
' re-authenticate the user.\n",
|
|
68
|
+
UnauthorizedException)
|
|
69
|
+
.local_error('403',
|
|
70
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
|
71
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
|
72
|
+
' won't help here.\n",
|
|
73
|
+
ForbiddenException)
|
|
74
|
+
.local_error('429',
|
|
75
|
+
"The app has exceeded its rate limits.\n",
|
|
76
|
+
TooManyRequestsException))
|
|
77
|
+
.execute
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Get a list of the songs saved in the current Spotify user's 'Your Music'
|
|
81
|
+
# library.
|
|
82
|
+
# @param [String] market Optional parameter: Example:
|
|
83
|
+
# @param [Integer] limit Optional parameter: Example:20
|
|
84
|
+
# @param [Integer] offset Optional parameter: Example:0
|
|
85
|
+
# @return [PagingSavedTrackObject] response from the API call
|
|
86
|
+
def get_users_saved_tracks(market: nil,
|
|
87
|
+
limit: 20,
|
|
88
|
+
offset: 0)
|
|
89
|
+
new_api_call_builder
|
|
90
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
91
|
+
'/me/tracks',
|
|
92
|
+
Server::DEFAULT)
|
|
93
|
+
.query_param(new_parameter(market, key: 'market'))
|
|
94
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
|
95
|
+
.query_param(new_parameter(offset, key: 'offset'))
|
|
96
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
97
|
+
.auth(Single.new('oauth_2_0')))
|
|
98
|
+
.response(new_response_handler
|
|
99
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
100
|
+
.deserialize_into(PagingSavedTrackObject.method(:from_hash))
|
|
101
|
+
.is_api_response(true)
|
|
102
|
+
.local_error('401',
|
|
103
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
|
104
|
+
' token or\nthe access token has expired. You should'\
|
|
105
|
+
' re-authenticate the user.\n",
|
|
106
|
+
UnauthorizedException)
|
|
107
|
+
.local_error('403',
|
|
108
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
|
109
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
|
110
|
+
' won't help here.\n",
|
|
111
|
+
ForbiddenException)
|
|
112
|
+
.local_error('429',
|
|
113
|
+
"The app has exceeded its rate limits.\n",
|
|
114
|
+
TooManyRequestsException))
|
|
115
|
+
.execute
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Save one or more tracks to the current user's 'Your Music' library.
|
|
119
|
+
# @param [String] ids Required parameter: Example:
|
|
120
|
+
# @param [MeTracksRequest] body Optional parameter: Example:
|
|
121
|
+
# @return [void] response from the API call
|
|
122
|
+
def save_tracks_user(ids,
|
|
123
|
+
body: nil)
|
|
124
|
+
new_api_call_builder
|
|
125
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
|
126
|
+
'/me/tracks',
|
|
127
|
+
Server::DEFAULT)
|
|
128
|
+
.query_param(new_parameter(ids, key: 'ids'))
|
|
129
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
|
130
|
+
.body_param(new_parameter(body))
|
|
131
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
|
132
|
+
.auth(Single.new('oauth_2_0')))
|
|
133
|
+
.response(new_response_handler
|
|
134
|
+
.is_response_void(true)
|
|
135
|
+
.is_api_response(true)
|
|
136
|
+
.local_error('401',
|
|
137
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
|
138
|
+
' token or\nthe access token has expired. You should'\
|
|
139
|
+
' re-authenticate the user.\n",
|
|
140
|
+
UnauthorizedException)
|
|
141
|
+
.local_error('403',
|
|
142
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
|
143
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
|
144
|
+
' won't help here.\n",
|
|
145
|
+
ForbiddenException)
|
|
146
|
+
.local_error('429',
|
|
147
|
+
"The app has exceeded its rate limits.\n",
|
|
148
|
+
TooManyRequestsException))
|
|
149
|
+
.execute
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# Remove one or more tracks from the current user's 'Your Music' library.
|
|
153
|
+
# @param [String] ids Required parameter: Example:
|
|
154
|
+
# @param [MeTracksRequest1] body Optional parameter: Example:
|
|
155
|
+
# @return [void] response from the API call
|
|
156
|
+
def remove_tracks_user(ids,
|
|
157
|
+
body: nil)
|
|
158
|
+
new_api_call_builder
|
|
159
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
|
160
|
+
'/me/tracks',
|
|
161
|
+
Server::DEFAULT)
|
|
162
|
+
.query_param(new_parameter(ids, key: 'ids'))
|
|
163
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
|
164
|
+
.body_param(new_parameter(body))
|
|
165
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
|
166
|
+
.auth(Single.new('oauth_2_0')))
|
|
167
|
+
.response(new_response_handler
|
|
168
|
+
.is_response_void(true)
|
|
169
|
+
.is_api_response(true)
|
|
170
|
+
.local_error('401',
|
|
171
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
|
172
|
+
' token or\nthe access token has expired. You should'\
|
|
173
|
+
' re-authenticate the user.\n",
|
|
174
|
+
UnauthorizedException)
|
|
175
|
+
.local_error('403',
|
|
176
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
|
177
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
|
178
|
+
' won't help here.\n",
|
|
179
|
+
ForbiddenException)
|
|
180
|
+
.local_error('429',
|
|
181
|
+
"The app has exceeded its rate limits.\n",
|
|
182
|
+
TooManyRequestsException))
|
|
183
|
+
.execute
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# Check if one or more tracks is already saved in the current Spotify user's
|
|
187
|
+
# 'Your Music' library.
|
|
188
|
+
# @param [String] ids Required parameter: Example:
|
|
189
|
+
# @return [Array[TrueClass | FalseClass]] response from the API call
|
|
190
|
+
def check_users_saved_tracks(ids)
|
|
191
|
+
new_api_call_builder
|
|
192
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
193
|
+
'/me/tracks/contains',
|
|
194
|
+
Server::DEFAULT)
|
|
195
|
+
.query_param(new_parameter(ids, key: 'ids'))
|
|
196
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
197
|
+
.auth(Single.new('oauth_2_0')))
|
|
198
|
+
.response(new_response_handler
|
|
199
|
+
.deserializer(APIHelper.method(:deserialize_primitive_types))
|
|
200
|
+
.is_api_response(true)
|
|
201
|
+
.is_response_array(true)
|
|
202
|
+
.is_primitive_response(true)
|
|
203
|
+
.local_error('401',
|
|
204
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
|
205
|
+
' token or\nthe access token has expired. You should'\
|
|
206
|
+
' re-authenticate the user.\n",
|
|
207
|
+
UnauthorizedException)
|
|
208
|
+
.local_error('403',
|
|
209
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
|
210
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
|
211
|
+
' won't help here.\n",
|
|
212
|
+
ForbiddenException)
|
|
213
|
+
.local_error('429',
|
|
214
|
+
"The app has exceeded its rate limits.\n",
|
|
215
|
+
TooManyRequestsException))
|
|
216
|
+
.execute
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# Get audio features for multiple tracks based on their Spotify IDs.
|
|
220
|
+
# @param [String] ids Required parameter: Example:
|
|
221
|
+
# @return [ManyAudioFeatures] response from the API call
|
|
222
|
+
def get_several_audio_features(ids)
|
|
223
|
+
new_api_call_builder
|
|
224
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
225
|
+
'/audio-features',
|
|
226
|
+
Server::DEFAULT)
|
|
227
|
+
.query_param(new_parameter(ids, key: 'ids'))
|
|
228
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
229
|
+
.auth(Single.new('oauth_2_0')))
|
|
230
|
+
.response(new_response_handler
|
|
231
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
232
|
+
.deserialize_into(ManyAudioFeatures.method(:from_hash))
|
|
233
|
+
.is_api_response(true)
|
|
234
|
+
.local_error('401',
|
|
235
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
|
236
|
+
' token or\nthe access token has expired. You should'\
|
|
237
|
+
' re-authenticate the user.\n",
|
|
238
|
+
UnauthorizedException)
|
|
239
|
+
.local_error('403',
|
|
240
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
|
241
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
|
242
|
+
' won't help here.\n",
|
|
243
|
+
ForbiddenException)
|
|
244
|
+
.local_error('429',
|
|
245
|
+
"The app has exceeded its rate limits.\n",
|
|
246
|
+
TooManyRequestsException))
|
|
247
|
+
.execute
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
# Get audio feature information for a single track identified by its unique
|
|
251
|
+
# Spotify ID.
|
|
252
|
+
# @param [String] id Required parameter: Example:
|
|
253
|
+
# @return [AudioFeaturesObject] response from the API call
|
|
254
|
+
def get_audio_features(id)
|
|
255
|
+
new_api_call_builder
|
|
256
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
257
|
+
'/audio-features/{id}',
|
|
258
|
+
Server::DEFAULT)
|
|
259
|
+
.template_param(new_parameter(id, key: 'id')
|
|
260
|
+
.should_encode(true))
|
|
261
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
262
|
+
.auth(Single.new('oauth_2_0')))
|
|
263
|
+
.response(new_response_handler
|
|
264
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
265
|
+
.deserialize_into(AudioFeaturesObject.method(:from_hash))
|
|
266
|
+
.is_api_response(true)
|
|
267
|
+
.local_error('401',
|
|
268
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
|
269
|
+
' token or\nthe access token has expired. You should'\
|
|
270
|
+
' re-authenticate the user.\n",
|
|
271
|
+
UnauthorizedException)
|
|
272
|
+
.local_error('403',
|
|
273
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
|
274
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
|
275
|
+
' won't help here.\n",
|
|
276
|
+
ForbiddenException)
|
|
277
|
+
.local_error('429',
|
|
278
|
+
"The app has exceeded its rate limits.\n",
|
|
279
|
+
TooManyRequestsException))
|
|
280
|
+
.execute
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
# Get a low-level audio analysis for a track in the Spotify catalog. The
|
|
284
|
+
# audio analysis describes the track’s structure and musical content,
|
|
285
|
+
# including rhythm, pitch, and timbre.
|
|
286
|
+
# @param [String] id Required parameter: Example:
|
|
287
|
+
# @return [AudioAnalysisObject] response from the API call
|
|
288
|
+
def get_audio_analysis(id)
|
|
289
|
+
new_api_call_builder
|
|
290
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
291
|
+
'/audio-analysis/{id}',
|
|
292
|
+
Server::DEFAULT)
|
|
293
|
+
.template_param(new_parameter(id, key: 'id')
|
|
294
|
+
.should_encode(true))
|
|
295
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
296
|
+
.auth(Single.new('oauth_2_0')))
|
|
297
|
+
.response(new_response_handler
|
|
298
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
299
|
+
.deserialize_into(AudioAnalysisObject.method(:from_hash))
|
|
300
|
+
.is_api_response(true)
|
|
301
|
+
.local_error('401',
|
|
302
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
|
303
|
+
' token or\nthe access token has expired. You should'\
|
|
304
|
+
' re-authenticate the user.\n",
|
|
305
|
+
UnauthorizedException)
|
|
306
|
+
.local_error('403',
|
|
307
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
|
308
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
|
309
|
+
' won't help here.\n",
|
|
310
|
+
ForbiddenException)
|
|
311
|
+
.local_error('429',
|
|
312
|
+
"The app has exceeded its rate limits.\n",
|
|
313
|
+
TooManyRequestsException))
|
|
314
|
+
.execute
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
# Recommendations are generated based on the available information for a
|
|
318
|
+
# given seed entity and matched against similar artists and tracks. If there
|
|
319
|
+
# is sufficient information about the provided seeds, a list of tracks will
|
|
320
|
+
# be returned together with pool size details.
|
|
321
|
+
# For artists and tracks that are very new or obscure there might not be
|
|
322
|
+
# enough data to generate a list of tracks.
|
|
323
|
+
# @param [Integer] limit Optional parameter: Example:20
|
|
324
|
+
# @param [String] market Optional parameter: Example:
|
|
325
|
+
# @param [String] seed_artists Optional parameter: Example:
|
|
326
|
+
# @param [String] seed_genres Optional parameter: Example:
|
|
327
|
+
# @param [String] seed_tracks Optional parameter: Example:
|
|
328
|
+
# @param [Float] min_acousticness Optional parameter: Example:
|
|
329
|
+
# @param [Float] max_acousticness Optional parameter: Example:
|
|
330
|
+
# @param [Float] target_acousticness Optional parameter: Example:
|
|
331
|
+
# @param [Float] min_danceability Optional parameter: Example:
|
|
332
|
+
# @param [Float] max_danceability Optional parameter: Example:
|
|
333
|
+
# @param [Float] target_danceability Optional parameter: Example:
|
|
334
|
+
# @param [Integer] min_duration_ms Optional parameter: Example:
|
|
335
|
+
# @param [Integer] max_duration_ms Optional parameter: Example:
|
|
336
|
+
# @param [Integer] target_duration_ms Optional parameter: Example:
|
|
337
|
+
# @param [Float] min_energy Optional parameter: Example:
|
|
338
|
+
# @param [Float] max_energy Optional parameter: Example:
|
|
339
|
+
# @param [Float] target_energy Optional parameter: Example:
|
|
340
|
+
# @param [Float] min_instrumentalness Optional parameter: Example:
|
|
341
|
+
# @param [Float] max_instrumentalness Optional parameter: Example:
|
|
342
|
+
# @param [Float] target_instrumentalness Optional parameter: Example:
|
|
343
|
+
# @param [Integer] min_key Optional parameter: Example:
|
|
344
|
+
# @param [Integer] max_key Optional parameter: Example:
|
|
345
|
+
# @param [Integer] target_key Optional parameter: Example:
|
|
346
|
+
# @param [Float] min_liveness Optional parameter: Example:
|
|
347
|
+
# @param [Float] max_liveness Optional parameter: Example:
|
|
348
|
+
# @param [Float] target_liveness Optional parameter: Example:
|
|
349
|
+
# @param [Float] min_loudness Optional parameter: Example:
|
|
350
|
+
# @param [Float] max_loudness Optional parameter: Example:
|
|
351
|
+
# @param [Float] target_loudness Optional parameter: Example:
|
|
352
|
+
# @param [Integer] min_mode Optional parameter: Example:
|
|
353
|
+
# @param [Integer] max_mode Optional parameter: Example:
|
|
354
|
+
# @param [Integer] target_mode Optional parameter: Example:
|
|
355
|
+
# @param [Integer] min_popularity Optional parameter: Example:
|
|
356
|
+
# @param [Integer] max_popularity Optional parameter: Example:
|
|
357
|
+
# @param [Integer] target_popularity Optional parameter: Example:
|
|
358
|
+
# @param [Float] min_speechiness Optional parameter: Example:
|
|
359
|
+
# @param [Float] max_speechiness Optional parameter: Example:
|
|
360
|
+
# @param [Float] target_speechiness Optional parameter: Example:
|
|
361
|
+
# @param [Float] min_tempo Optional parameter: Example:
|
|
362
|
+
# @param [Float] max_tempo Optional parameter: Example:
|
|
363
|
+
# @param [Float] target_tempo Optional parameter: Example:
|
|
364
|
+
# @param [Integer] min_time_signature Optional parameter: Example:
|
|
365
|
+
# @param [Integer] max_time_signature Optional parameter: Example:
|
|
366
|
+
# @param [Integer] target_time_signature Optional parameter: Example:
|
|
367
|
+
# @param [Float] min_valence Optional parameter: Example:
|
|
368
|
+
# @param [Float] max_valence Optional parameter: Example:
|
|
369
|
+
# @param [Float] target_valence Optional parameter: Example:
|
|
370
|
+
# @return [RecommendationsObject] response from the API call
|
|
371
|
+
def get_recommendations(limit: 20,
|
|
372
|
+
market: nil,
|
|
373
|
+
seed_artists: nil,
|
|
374
|
+
seed_genres: nil,
|
|
375
|
+
seed_tracks: nil,
|
|
376
|
+
min_acousticness: nil,
|
|
377
|
+
max_acousticness: nil,
|
|
378
|
+
target_acousticness: nil,
|
|
379
|
+
min_danceability: nil,
|
|
380
|
+
max_danceability: nil,
|
|
381
|
+
target_danceability: nil,
|
|
382
|
+
min_duration_ms: nil,
|
|
383
|
+
max_duration_ms: nil,
|
|
384
|
+
target_duration_ms: nil,
|
|
385
|
+
min_energy: nil,
|
|
386
|
+
max_energy: nil,
|
|
387
|
+
target_energy: nil,
|
|
388
|
+
min_instrumentalness: nil,
|
|
389
|
+
max_instrumentalness: nil,
|
|
390
|
+
target_instrumentalness: nil,
|
|
391
|
+
min_key: nil,
|
|
392
|
+
max_key: nil,
|
|
393
|
+
target_key: nil,
|
|
394
|
+
min_liveness: nil,
|
|
395
|
+
max_liveness: nil,
|
|
396
|
+
target_liveness: nil,
|
|
397
|
+
min_loudness: nil,
|
|
398
|
+
max_loudness: nil,
|
|
399
|
+
target_loudness: nil,
|
|
400
|
+
min_mode: nil,
|
|
401
|
+
max_mode: nil,
|
|
402
|
+
target_mode: nil,
|
|
403
|
+
min_popularity: nil,
|
|
404
|
+
max_popularity: nil,
|
|
405
|
+
target_popularity: nil,
|
|
406
|
+
min_speechiness: nil,
|
|
407
|
+
max_speechiness: nil,
|
|
408
|
+
target_speechiness: nil,
|
|
409
|
+
min_tempo: nil,
|
|
410
|
+
max_tempo: nil,
|
|
411
|
+
target_tempo: nil,
|
|
412
|
+
min_time_signature: nil,
|
|
413
|
+
max_time_signature: nil,
|
|
414
|
+
target_time_signature: nil,
|
|
415
|
+
min_valence: nil,
|
|
416
|
+
max_valence: nil,
|
|
417
|
+
target_valence: nil)
|
|
418
|
+
new_api_call_builder
|
|
419
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
420
|
+
'/recommendations',
|
|
421
|
+
Server::DEFAULT)
|
|
422
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
|
423
|
+
.query_param(new_parameter(market, key: 'market'))
|
|
424
|
+
.query_param(new_parameter(seed_artists, key: 'seed_artists'))
|
|
425
|
+
.query_param(new_parameter(seed_genres, key: 'seed_genres'))
|
|
426
|
+
.query_param(new_parameter(seed_tracks, key: 'seed_tracks'))
|
|
427
|
+
.query_param(new_parameter(min_acousticness, key: 'min_acousticness'))
|
|
428
|
+
.query_param(new_parameter(max_acousticness, key: 'max_acousticness'))
|
|
429
|
+
.query_param(new_parameter(target_acousticness, key: 'target_acousticness'))
|
|
430
|
+
.query_param(new_parameter(min_danceability, key: 'min_danceability'))
|
|
431
|
+
.query_param(new_parameter(max_danceability, key: 'max_danceability'))
|
|
432
|
+
.query_param(new_parameter(target_danceability, key: 'target_danceability'))
|
|
433
|
+
.query_param(new_parameter(min_duration_ms, key: 'min_duration_ms'))
|
|
434
|
+
.query_param(new_parameter(max_duration_ms, key: 'max_duration_ms'))
|
|
435
|
+
.query_param(new_parameter(target_duration_ms, key: 'target_duration_ms'))
|
|
436
|
+
.query_param(new_parameter(min_energy, key: 'min_energy'))
|
|
437
|
+
.query_param(new_parameter(max_energy, key: 'max_energy'))
|
|
438
|
+
.query_param(new_parameter(target_energy, key: 'target_energy'))
|
|
439
|
+
.query_param(new_parameter(min_instrumentalness, key: 'min_instrumentalness'))
|
|
440
|
+
.query_param(new_parameter(max_instrumentalness, key: 'max_instrumentalness'))
|
|
441
|
+
.query_param(new_parameter(target_instrumentalness, key: 'target_instrumentalness'))
|
|
442
|
+
.query_param(new_parameter(min_key, key: 'min_key'))
|
|
443
|
+
.query_param(new_parameter(max_key, key: 'max_key'))
|
|
444
|
+
.query_param(new_parameter(target_key, key: 'target_key'))
|
|
445
|
+
.query_param(new_parameter(min_liveness, key: 'min_liveness'))
|
|
446
|
+
.query_param(new_parameter(max_liveness, key: 'max_liveness'))
|
|
447
|
+
.query_param(new_parameter(target_liveness, key: 'target_liveness'))
|
|
448
|
+
.query_param(new_parameter(min_loudness, key: 'min_loudness'))
|
|
449
|
+
.query_param(new_parameter(max_loudness, key: 'max_loudness'))
|
|
450
|
+
.query_param(new_parameter(target_loudness, key: 'target_loudness'))
|
|
451
|
+
.query_param(new_parameter(min_mode, key: 'min_mode'))
|
|
452
|
+
.query_param(new_parameter(max_mode, key: 'max_mode'))
|
|
453
|
+
.query_param(new_parameter(target_mode, key: 'target_mode'))
|
|
454
|
+
.query_param(new_parameter(min_popularity, key: 'min_popularity'))
|
|
455
|
+
.query_param(new_parameter(max_popularity, key: 'max_popularity'))
|
|
456
|
+
.query_param(new_parameter(target_popularity, key: 'target_popularity'))
|
|
457
|
+
.query_param(new_parameter(min_speechiness, key: 'min_speechiness'))
|
|
458
|
+
.query_param(new_parameter(max_speechiness, key: 'max_speechiness'))
|
|
459
|
+
.query_param(new_parameter(target_speechiness, key: 'target_speechiness'))
|
|
460
|
+
.query_param(new_parameter(min_tempo, key: 'min_tempo'))
|
|
461
|
+
.query_param(new_parameter(max_tempo, key: 'max_tempo'))
|
|
462
|
+
.query_param(new_parameter(target_tempo, key: 'target_tempo'))
|
|
463
|
+
.query_param(new_parameter(min_time_signature, key: 'min_time_signature'))
|
|
464
|
+
.query_param(new_parameter(max_time_signature, key: 'max_time_signature'))
|
|
465
|
+
.query_param(new_parameter(target_time_signature, key: 'target_time_signature'))
|
|
466
|
+
.query_param(new_parameter(min_valence, key: 'min_valence'))
|
|
467
|
+
.query_param(new_parameter(max_valence, key: 'max_valence'))
|
|
468
|
+
.query_param(new_parameter(target_valence, key: 'target_valence'))
|
|
469
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
470
|
+
.auth(Single.new('oauth_2_0')))
|
|
471
|
+
.response(new_response_handler
|
|
472
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
473
|
+
.deserialize_into(RecommendationsObject.method(:from_hash))
|
|
474
|
+
.is_api_response(true)
|
|
475
|
+
.local_error('401',
|
|
476
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
|
477
|
+
' token or\nthe access token has expired. You should'\
|
|
478
|
+
' re-authenticate the user.\n",
|
|
479
|
+
UnauthorizedException)
|
|
480
|
+
.local_error('403',
|
|
481
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
|
482
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
|
483
|
+
' won't help here.\n",
|
|
484
|
+
ForbiddenException)
|
|
485
|
+
.local_error('429',
|
|
486
|
+
"The app has exceeded its rate limits.\n",
|
|
487
|
+
TooManyRequestsException))
|
|
488
|
+
.execute
|
|
489
|
+
end
|
|
490
|
+
end
|
|
491
|
+
end
|