spotify-api-sdk 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,258 @@
|
|
1
|
+
# spotify_web_api
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module SpotifyWebApi
|
7
|
+
# AudiobooksController
|
8
|
+
class AudiobooksController < BaseController
|
9
|
+
# Get Spotify catalog information for a single audiobook. Audiobooks are
|
10
|
+
# only available within the US, UK, Canada, Ireland, New Zealand and
|
11
|
+
# Australia markets.
|
12
|
+
# @param [String] id Required parameter: Example:
|
13
|
+
# @param [String] market Optional parameter: Example:
|
14
|
+
# @return [AudiobookObject] response from the API call
|
15
|
+
def get_an_audiobook(id,
|
16
|
+
market: nil)
|
17
|
+
new_api_call_builder
|
18
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
19
|
+
'/audiobooks/{id}',
|
20
|
+
Server::DEFAULT)
|
21
|
+
.template_param(new_parameter(id, key: 'id')
|
22
|
+
.should_encode(true))
|
23
|
+
.query_param(new_parameter(market, key: 'market'))
|
24
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
25
|
+
.auth(Single.new('oauth_2_0')))
|
26
|
+
.response(new_response_handler
|
27
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
28
|
+
.deserialize_into(AudiobookObject.method(:from_hash))
|
29
|
+
.is_api_response(true)
|
30
|
+
.local_error('400',
|
31
|
+
"The request contains malformed data in path, query parameters,'\
|
32
|
+
' or body.\n",
|
33
|
+
BadRequestException)
|
34
|
+
.local_error('401',
|
35
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
36
|
+
' token or\nthe access token has expired. You should'\
|
37
|
+
' re-authenticate the user.\n",
|
38
|
+
UnauthorizedException)
|
39
|
+
.local_error('403',
|
40
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
41
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
42
|
+
' won't help here.\n",
|
43
|
+
ForbiddenException)
|
44
|
+
.local_error('404',
|
45
|
+
"The requested resource cannot be found.\n",
|
46
|
+
NotFoundException)
|
47
|
+
.local_error('429',
|
48
|
+
"The app has exceeded its rate limits.\n",
|
49
|
+
TooManyRequestsException))
|
50
|
+
.execute
|
51
|
+
end
|
52
|
+
|
53
|
+
# Get Spotify catalog information for several audiobooks identified by their
|
54
|
+
# Spotify IDs. Audiobooks are only available within the US, UK, Canada,
|
55
|
+
# Ireland, New Zealand and Australia markets.
|
56
|
+
# @param [String] ids Required parameter: Example:
|
57
|
+
# @param [String] market Optional parameter: Example:
|
58
|
+
# @return [ManyAudiobooks] response from the API call
|
59
|
+
def get_multiple_audiobooks(ids,
|
60
|
+
market: nil)
|
61
|
+
new_api_call_builder
|
62
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
63
|
+
'/audiobooks',
|
64
|
+
Server::DEFAULT)
|
65
|
+
.query_param(new_parameter(ids, key: 'ids'))
|
66
|
+
.query_param(new_parameter(market, key: 'market'))
|
67
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
68
|
+
.auth(Single.new('oauth_2_0')))
|
69
|
+
.response(new_response_handler
|
70
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
71
|
+
.deserialize_into(ManyAudiobooks.method(:from_hash))
|
72
|
+
.is_api_response(true)
|
73
|
+
.local_error('401',
|
74
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
75
|
+
' token or\nthe access token has expired. You should'\
|
76
|
+
' re-authenticate the user.\n",
|
77
|
+
UnauthorizedException)
|
78
|
+
.local_error('403',
|
79
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
80
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
81
|
+
' won't help here.\n",
|
82
|
+
ForbiddenException)
|
83
|
+
.local_error('429',
|
84
|
+
"The app has exceeded its rate limits.\n",
|
85
|
+
TooManyRequestsException))
|
86
|
+
.execute
|
87
|
+
end
|
88
|
+
|
89
|
+
# Get Spotify catalog information about an audiobook's chapters. Audiobooks
|
90
|
+
# are only available within the US, UK, Canada, Ireland, New Zealand and
|
91
|
+
# Australia markets.
|
92
|
+
# @param [String] id Required parameter: Example:
|
93
|
+
# @param [String] market Optional parameter: Example:
|
94
|
+
# @param [Integer] limit Optional parameter: Example:20
|
95
|
+
# @param [Integer] offset Optional parameter: Example:0
|
96
|
+
# @return [PagingSimplifiedChapterObject] response from the API call
|
97
|
+
def get_audiobook_chapters(id,
|
98
|
+
market: nil,
|
99
|
+
limit: 20,
|
100
|
+
offset: 0)
|
101
|
+
new_api_call_builder
|
102
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
103
|
+
'/audiobooks/{id}/chapters',
|
104
|
+
Server::DEFAULT)
|
105
|
+
.template_param(new_parameter(id, key: 'id')
|
106
|
+
.should_encode(true))
|
107
|
+
.query_param(new_parameter(market, key: 'market'))
|
108
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
109
|
+
.query_param(new_parameter(offset, key: 'offset'))
|
110
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
111
|
+
.auth(Single.new('oauth_2_0')))
|
112
|
+
.response(new_response_handler
|
113
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
114
|
+
.deserialize_into(PagingSimplifiedChapterObject.method(:from_hash))
|
115
|
+
.is_api_response(true)
|
116
|
+
.local_error('401',
|
117
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
118
|
+
' token or\nthe access token has expired. You should'\
|
119
|
+
' re-authenticate the user.\n",
|
120
|
+
UnauthorizedException)
|
121
|
+
.local_error('403',
|
122
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
123
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
124
|
+
' won't help here.\n",
|
125
|
+
ForbiddenException)
|
126
|
+
.local_error('429',
|
127
|
+
"The app has exceeded its rate limits.\n",
|
128
|
+
TooManyRequestsException))
|
129
|
+
.execute
|
130
|
+
end
|
131
|
+
|
132
|
+
# Get a list of the audiobooks saved in the current Spotify user's 'Your
|
133
|
+
# Music' library.
|
134
|
+
# @param [Integer] limit Optional parameter: Example:20
|
135
|
+
# @param [Integer] offset Optional parameter: Example:0
|
136
|
+
# @return [PagingSavedAudiobookObject] response from the API call
|
137
|
+
def get_users_saved_audiobooks(limit: 20,
|
138
|
+
offset: 0)
|
139
|
+
new_api_call_builder
|
140
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
141
|
+
'/me/audiobooks',
|
142
|
+
Server::DEFAULT)
|
143
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
144
|
+
.query_param(new_parameter(offset, key: 'offset'))
|
145
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
146
|
+
.auth(Single.new('oauth_2_0')))
|
147
|
+
.response(new_response_handler
|
148
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
149
|
+
.deserialize_into(PagingSavedAudiobookObject.method(:from_hash))
|
150
|
+
.is_api_response(true)
|
151
|
+
.local_error('401',
|
152
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
153
|
+
' token or\nthe access token has expired. You should'\
|
154
|
+
' re-authenticate the user.\n",
|
155
|
+
UnauthorizedException)
|
156
|
+
.local_error('403',
|
157
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
158
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
159
|
+
' won't help here.\n",
|
160
|
+
ForbiddenException)
|
161
|
+
.local_error('429',
|
162
|
+
"The app has exceeded its rate limits.\n",
|
163
|
+
TooManyRequestsException))
|
164
|
+
.execute
|
165
|
+
end
|
166
|
+
|
167
|
+
# Save one or more audiobooks to the current Spotify user's library.
|
168
|
+
# @param [String] ids Required parameter: Example:
|
169
|
+
# @return [void] response from the API call
|
170
|
+
def save_audiobooks_user(ids)
|
171
|
+
new_api_call_builder
|
172
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
173
|
+
'/me/audiobooks',
|
174
|
+
Server::DEFAULT)
|
175
|
+
.query_param(new_parameter(ids, key: 'ids'))
|
176
|
+
.auth(Single.new('oauth_2_0')))
|
177
|
+
.response(new_response_handler
|
178
|
+
.is_response_void(true)
|
179
|
+
.is_api_response(true)
|
180
|
+
.local_error('401',
|
181
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
182
|
+
' token or\nthe access token has expired. You should'\
|
183
|
+
' re-authenticate the user.\n",
|
184
|
+
UnauthorizedException)
|
185
|
+
.local_error('403',
|
186
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
187
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
188
|
+
' won't help here.\n",
|
189
|
+
ForbiddenException)
|
190
|
+
.local_error('429',
|
191
|
+
"The app has exceeded its rate limits.\n",
|
192
|
+
TooManyRequestsException))
|
193
|
+
.execute
|
194
|
+
end
|
195
|
+
|
196
|
+
# Remove one or more audiobooks from the Spotify user's library.
|
197
|
+
# @param [String] ids Required parameter: Example:
|
198
|
+
# @return [void] response from the API call
|
199
|
+
def remove_audiobooks_user(ids)
|
200
|
+
new_api_call_builder
|
201
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
202
|
+
'/me/audiobooks',
|
203
|
+
Server::DEFAULT)
|
204
|
+
.query_param(new_parameter(ids, key: 'ids'))
|
205
|
+
.auth(Single.new('oauth_2_0')))
|
206
|
+
.response(new_response_handler
|
207
|
+
.is_response_void(true)
|
208
|
+
.is_api_response(true)
|
209
|
+
.local_error('401',
|
210
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
211
|
+
' token or\nthe access token has expired. You should'\
|
212
|
+
' re-authenticate the user.\n",
|
213
|
+
UnauthorizedException)
|
214
|
+
.local_error('403',
|
215
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
216
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
217
|
+
' won't help here.\n",
|
218
|
+
ForbiddenException)
|
219
|
+
.local_error('429',
|
220
|
+
"The app has exceeded its rate limits.\n",
|
221
|
+
TooManyRequestsException))
|
222
|
+
.execute
|
223
|
+
end
|
224
|
+
|
225
|
+
# Check if one or more audiobooks are already saved in the current Spotify
|
226
|
+
# user's library.
|
227
|
+
# @param [String] ids Required parameter: Example:
|
228
|
+
# @return [Array[TrueClass | FalseClass]] response from the API call
|
229
|
+
def check_users_saved_audiobooks(ids)
|
230
|
+
new_api_call_builder
|
231
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
232
|
+
'/me/audiobooks/contains',
|
233
|
+
Server::DEFAULT)
|
234
|
+
.query_param(new_parameter(ids, key: 'ids'))
|
235
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
236
|
+
.auth(Single.new('oauth_2_0')))
|
237
|
+
.response(new_response_handler
|
238
|
+
.deserializer(APIHelper.method(:deserialize_primitive_types))
|
239
|
+
.is_api_response(true)
|
240
|
+
.is_response_array(true)
|
241
|
+
.is_primitive_response(true)
|
242
|
+
.local_error('401',
|
243
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
244
|
+
' token or\nthe access token has expired. You should'\
|
245
|
+
' re-authenticate the user.\n",
|
246
|
+
UnauthorizedException)
|
247
|
+
.local_error('403',
|
248
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
249
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
250
|
+
' won't help here.\n",
|
251
|
+
ForbiddenException)
|
252
|
+
.local_error('429',
|
253
|
+
"The app has exceeded its rate limits.\n",
|
254
|
+
TooManyRequestsException))
|
255
|
+
.execute
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# spotify_web_api
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module SpotifyWebApi
|
7
|
+
# BaseController.
|
8
|
+
class BaseController
|
9
|
+
include CoreLibrary
|
10
|
+
attr_accessor :config, :http_call_back
|
11
|
+
|
12
|
+
def self.user_agent
|
13
|
+
'APIMATIC 3.0'
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
GLOBAL_ERRORS = {
|
18
|
+
'default' => ErrorCase.new
|
19
|
+
.error_message('HTTP response not OK.')
|
20
|
+
.exception_type(APIException)
|
21
|
+
}.freeze
|
22
|
+
|
23
|
+
# Initialization constructor.
|
24
|
+
# @param [GlobalConfiguration] global_configuration The instance of GlobalConfiguration.
|
25
|
+
def initialize(global_configuration)
|
26
|
+
@global_configuration = global_configuration
|
27
|
+
@config = @global_configuration.client_configuration
|
28
|
+
@http_call_back = @config.http_callback
|
29
|
+
@api_call = ApiCall.new(@global_configuration)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Creates a new builder for the Api Call instance.
|
33
|
+
# @return [ApiCall] The instance of ApiCall.
|
34
|
+
def new_api_call_builder
|
35
|
+
@api_call.new_builder
|
36
|
+
end
|
37
|
+
|
38
|
+
# Creates a new instance of the request builder.
|
39
|
+
# @param [String] http_method The HTTP method to use in the request.
|
40
|
+
# @param [String] path The endpoint path to use in the request.
|
41
|
+
# @param [String] server The server to extract the base uri for the request.
|
42
|
+
# @return [RequestBuilder] The instance of RequestBuilder.
|
43
|
+
def new_request_builder(http_method, path, server)
|
44
|
+
RequestBuilder.new
|
45
|
+
.http_method(http_method)
|
46
|
+
.path(path)
|
47
|
+
.server(server)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Creates a new instance of the response handler.
|
51
|
+
# @return [ResponseHandler] The instance of ResponseHandler.
|
52
|
+
def new_response_handler
|
53
|
+
ResponseHandler.new
|
54
|
+
end
|
55
|
+
|
56
|
+
# Creates a new instance of the parameter.
|
57
|
+
# @param [String|optional] key The key of the parameter.
|
58
|
+
# @param [Object] value The value of the parameter.
|
59
|
+
# @return [Parameter] The instance of Parameter.
|
60
|
+
def new_parameter(value, key: nil)
|
61
|
+
Parameter.new
|
62
|
+
.key(key)
|
63
|
+
.value(value)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# spotify_web_api
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module SpotifyWebApi
|
7
|
+
# CategoriesController
|
8
|
+
class CategoriesController < BaseController
|
9
|
+
# Get a list of categories used to tag items in Spotify (on, for example,
|
10
|
+
# the Spotify player’s “Browse” tab).
|
11
|
+
# @param [String] locale Optional parameter: Example:
|
12
|
+
# @param [Integer] limit Optional parameter: Example:20
|
13
|
+
# @param [Integer] offset Optional parameter: Example:0
|
14
|
+
# @return [PagedCategories] response from the API call
|
15
|
+
def get_categories(locale: nil,
|
16
|
+
limit: 20,
|
17
|
+
offset: 0)
|
18
|
+
new_api_call_builder
|
19
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
20
|
+
'/browse/categories',
|
21
|
+
Server::DEFAULT)
|
22
|
+
.query_param(new_parameter(locale, key: 'locale'))
|
23
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
24
|
+
.query_param(new_parameter(offset, key: 'offset'))
|
25
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
26
|
+
.auth(Single.new('oauth_2_0')))
|
27
|
+
.response(new_response_handler
|
28
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
29
|
+
.deserialize_into(PagedCategories.method(:from_hash))
|
30
|
+
.is_api_response(true)
|
31
|
+
.local_error('401',
|
32
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
33
|
+
' token or\nthe access token has expired. You should'\
|
34
|
+
' re-authenticate the user.\n",
|
35
|
+
UnauthorizedException)
|
36
|
+
.local_error('403',
|
37
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
38
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
39
|
+
' won't help here.\n",
|
40
|
+
ForbiddenException)
|
41
|
+
.local_error('429',
|
42
|
+
"The app has exceeded its rate limits.\n",
|
43
|
+
TooManyRequestsException))
|
44
|
+
.execute
|
45
|
+
end
|
46
|
+
|
47
|
+
# Get a single category used to tag items in Spotify (on, for example, the
|
48
|
+
# Spotify player’s “Browse” tab).
|
49
|
+
# @param [String] category_id Required parameter: Example:
|
50
|
+
# @param [String] locale Optional parameter: Example:
|
51
|
+
# @return [CategoryObject] response from the API call
|
52
|
+
def get_a_category(category_id,
|
53
|
+
locale: nil)
|
54
|
+
new_api_call_builder
|
55
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
56
|
+
'/browse/categories/{category_id}',
|
57
|
+
Server::DEFAULT)
|
58
|
+
.template_param(new_parameter(category_id, key: 'category_id')
|
59
|
+
.should_encode(true))
|
60
|
+
.query_param(new_parameter(locale, key: 'locale'))
|
61
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
62
|
+
.auth(Single.new('oauth_2_0')))
|
63
|
+
.response(new_response_handler
|
64
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
65
|
+
.deserialize_into(CategoryObject.method(:from_hash))
|
66
|
+
.is_api_response(true)
|
67
|
+
.local_error('401',
|
68
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
69
|
+
' token or\nthe access token has expired. You should'\
|
70
|
+
' re-authenticate the user.\n",
|
71
|
+
UnauthorizedException)
|
72
|
+
.local_error('403',
|
73
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
74
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
75
|
+
' won't help here.\n",
|
76
|
+
ForbiddenException)
|
77
|
+
.local_error('429',
|
78
|
+
"The app has exceeded its rate limits.\n",
|
79
|
+
TooManyRequestsException))
|
80
|
+
.execute
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# spotify_web_api
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module SpotifyWebApi
|
7
|
+
# ChaptersController
|
8
|
+
class ChaptersController < BaseController
|
9
|
+
# Get Spotify catalog information for a single audiobook chapter. Chapters
|
10
|
+
# are only available within the US, UK, Canada, Ireland, New Zealand and
|
11
|
+
# Australia markets.
|
12
|
+
# @param [String] id Required parameter: Example:
|
13
|
+
# @param [String] market Optional parameter: Example:
|
14
|
+
# @return [ChapterObject] response from the API call
|
15
|
+
def get_a_chapter(id,
|
16
|
+
market: nil)
|
17
|
+
new_api_call_builder
|
18
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
19
|
+
'/chapters/{id}',
|
20
|
+
Server::DEFAULT)
|
21
|
+
.template_param(new_parameter(id, key: 'id')
|
22
|
+
.should_encode(true))
|
23
|
+
.query_param(new_parameter(market, key: 'market'))
|
24
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
25
|
+
.auth(Single.new('oauth_2_0')))
|
26
|
+
.response(new_response_handler
|
27
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
28
|
+
.deserialize_into(ChapterObject.method(:from_hash))
|
29
|
+
.is_api_response(true)
|
30
|
+
.local_error('401',
|
31
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
32
|
+
' token or\nthe access token has expired. You should'\
|
33
|
+
' re-authenticate the user.\n",
|
34
|
+
UnauthorizedException)
|
35
|
+
.local_error('403',
|
36
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
37
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
38
|
+
' won't help here.\n",
|
39
|
+
ForbiddenException)
|
40
|
+
.local_error('429',
|
41
|
+
"The app has exceeded its rate limits.\n",
|
42
|
+
TooManyRequestsException))
|
43
|
+
.execute
|
44
|
+
end
|
45
|
+
|
46
|
+
# Get Spotify catalog information for several audiobook chapters identified
|
47
|
+
# by their Spotify IDs. Chapters are only available within the US, UK,
|
48
|
+
# Canada, Ireland, New Zealand and Australia markets.
|
49
|
+
# @param [String] ids Required parameter: Example:
|
50
|
+
# @param [String] market Optional parameter: Example:
|
51
|
+
# @return [ManyChapters] response from the API call
|
52
|
+
def get_several_chapters(ids,
|
53
|
+
market: nil)
|
54
|
+
new_api_call_builder
|
55
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
56
|
+
'/chapters',
|
57
|
+
Server::DEFAULT)
|
58
|
+
.query_param(new_parameter(ids, key: 'ids'))
|
59
|
+
.query_param(new_parameter(market, key: 'market'))
|
60
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
61
|
+
.auth(Single.new('oauth_2_0')))
|
62
|
+
.response(new_response_handler
|
63
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
64
|
+
.deserialize_into(ManyChapters.method(:from_hash))
|
65
|
+
.is_api_response(true)
|
66
|
+
.local_error('401',
|
67
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
68
|
+
' token or\nthe access token has expired. You should'\
|
69
|
+
' re-authenticate the user.\n",
|
70
|
+
UnauthorizedException)
|
71
|
+
.local_error('403',
|
72
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
73
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
74
|
+
' won't help here.\n",
|
75
|
+
ForbiddenException)
|
76
|
+
.local_error('429',
|
77
|
+
"The app has exceeded its rate limits.\n",
|
78
|
+
TooManyRequestsException))
|
79
|
+
.execute
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|