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.
- checksums.yaml +7 -0
- data/LICENSE +30 -0
- data/README.md +170 -0
- data/bin/console +15 -0
- data/lib/spotify_web_api/api_helper.rb +10 -0
- data/lib/spotify_web_api/client.rb +165 -0
- data/lib/spotify_web_api/configuration.rb +244 -0
- data/lib/spotify_web_api/controllers/albums_controller.rb +297 -0
- data/lib/spotify_web_api/controllers/artists_controller.rb +188 -0
- data/lib/spotify_web_api/controllers/audiobooks_controller.rb +258 -0
- data/lib/spotify_web_api/controllers/base_controller.rb +60 -0
- data/lib/spotify_web_api/controllers/categories_controller.rb +84 -0
- data/lib/spotify_web_api/controllers/chapters_controller.rb +82 -0
- data/lib/spotify_web_api/controllers/episodes_controller.rb +241 -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 +525 -0
- data/lib/spotify_web_api/controllers/playlists_controller.rb +538 -0
- data/lib/spotify_web_api/controllers/search_controller.rb +61 -0
- data/lib/spotify_web_api/controllers/shows_controller.rb +263 -0
- data/lib/spotify_web_api/controllers/tracks_controller.rb +534 -0
- data/lib/spotify_web_api/controllers/users_controller.rb +402 -0
- data/lib/spotify_web_api/exceptions/api_exception.rb +21 -0
- data/lib/spotify_web_api/exceptions/bad_request_exception.rb +46 -0
- data/lib/spotify_web_api/exceptions/forbidden_exception.rb +46 -0
- data/lib/spotify_web_api/exceptions/not_found_exception.rb +46 -0
- data/lib/spotify_web_api/exceptions/o_auth_provider_exception.rb +64 -0
- data/lib/spotify_web_api/exceptions/too_many_requests_exception.rb +46 -0
- data/lib/spotify_web_api/exceptions/unauthorized_exception.rb +46 -0
- data/lib/spotify_web_api/http/api_response.rb +19 -0
- data/lib/spotify_web_api/http/auth/o_auth2.rb +164 -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/http/proxy_settings.rb +22 -0
- data/lib/spotify_web_api/models/album_base.rb +189 -0
- data/lib/spotify_web_api/models/album_group_enum.rb +44 -0
- data/lib/spotify_web_api/models/album_object.rb +273 -0
- data/lib/spotify_web_api/models/album_restriction_object.rb +75 -0
- data/lib/spotify_web_api/models/album_type_enum.rb +40 -0
- data/lib/spotify_web_api/models/artist_discography_album_object.rb +216 -0
- data/lib/spotify_web_api/models/artist_object.rb +174 -0
- data/lib/spotify_web_api/models/audio_analysis_object.rb +171 -0
- data/lib/spotify_web_api/models/audio_features_object.rb +273 -0
- data/lib/spotify_web_api/models/audiobook_base.rb +270 -0
- data/lib/spotify_web_api/models/audiobook_object.rb +278 -0
- data/lib/spotify_web_api/models/author_object.rb +62 -0
- data/lib/spotify_web_api/models/base_model.rb +110 -0
- data/lib/spotify_web_api/models/categories.rb +125 -0
- data/lib/spotify_web_api/models/category_object.rb +95 -0
- data/lib/spotify_web_api/models/chapter_base.rb +265 -0
- data/lib/spotify_web_api/models/chapter_object.rb +273 -0
- data/lib/spotify_web_api/models/chapter_restriction_object.rb +71 -0
- data/lib/spotify_web_api/models/context_object.rb +102 -0
- data/lib/spotify_web_api/models/copyright_object.rb +82 -0
- data/lib/spotify_web_api/models/currently_playing_context_object.rb +168 -0
- data/lib/spotify_web_api/models/currently_playing_object.rb +138 -0
- data/lib/spotify_web_api/models/cursor_object.rb +71 -0
- data/lib/spotify_web_api/models/cursor_paged_artists.rb +60 -0
- data/lib/spotify_web_api/models/cursor_paging_object.rb +102 -0
- data/lib/spotify_web_api/models/cursor_paging_play_history_object.rb +120 -0
- data/lib/spotify_web_api/models/cursor_paging_simplified_artist_object.rb +120 -0
- data/lib/spotify_web_api/models/device_object.rb +153 -0
- data/lib/spotify_web_api/models/disallows_object.rb +171 -0
- data/lib/spotify_web_api/models/episode_base.rb +263 -0
- data/lib/spotify_web_api/models/episode_object.rb +368 -0
- data/lib/spotify_web_api/models/episode_restriction_object.rb +80 -0
- data/lib/spotify_web_api/models/error_object.rb +71 -0
- data/lib/spotify_web_api/models/explicit_content_settings_object.rb +74 -0
- data/lib/spotify_web_api/models/external_id_object.rb +94 -0
- data/lib/spotify_web_api/models/external_url_object.rb +73 -0
- data/lib/spotify_web_api/models/followers_object.rb +84 -0
- data/lib/spotify_web_api/models/image_object.rb +106 -0
- data/lib/spotify_web_api/models/include_external_enum.rb +29 -0
- data/lib/spotify_web_api/models/item_type1_enum.rb +26 -0
- data/lib/spotify_web_api/models/item_type2_enum.rb +36 -0
- data/lib/spotify_web_api/models/item_type3_enum.rb +36 -0
- data/lib/spotify_web_api/models/item_type_enum.rb +56 -0
- data/lib/spotify_web_api/models/linked_track_object.rb +113 -0
- data/lib/spotify_web_api/models/many_albums.rb +69 -0
- data/lib/spotify_web_api/models/many_artists.rb +69 -0
- data/lib/spotify_web_api/models/many_audio_features.rb +69 -0
- data/lib/spotify_web_api/models/many_audiobooks.rb +69 -0
- data/lib/spotify_web_api/models/many_chapters.rb +69 -0
- data/lib/spotify_web_api/models/many_devices.rb +69 -0
- data/lib/spotify_web_api/models/many_episodes.rb +69 -0
- data/lib/spotify_web_api/models/many_genres.rb +60 -0
- data/lib/spotify_web_api/models/many_simplified_shows.rb +69 -0
- data/lib/spotify_web_api/models/many_tracks.rb +69 -0
- data/lib/spotify_web_api/models/markets.rb +62 -0
- data/lib/spotify_web_api/models/me_albums_request.rb +67 -0
- data/lib/spotify_web_api/models/me_episodes_request.rb +64 -0
- data/lib/spotify_web_api/models/me_episodes_request1.rb +66 -0
- data/lib/spotify_web_api/models/me_following_request.rb +65 -0
- data/lib/spotify_web_api/models/me_following_request1.rb +67 -0
- data/lib/spotify_web_api/models/me_player_play_request.rb +103 -0
- data/lib/spotify_web_api/models/me_player_request.rb +75 -0
- data/lib/spotify_web_api/models/me_shows_request.rb +67 -0
- data/lib/spotify_web_api/models/me_tracks_request.rb +65 -0
- data/lib/spotify_web_api/models/me_tracks_request1.rb +67 -0
- data/lib/spotify_web_api/models/meta.rb +127 -0
- data/lib/spotify_web_api/models/mode_enum.rb +50 -0
- data/lib/spotify_web_api/models/narrator_object.rb +62 -0
- data/lib/spotify_web_api/models/o_auth_provider_error_enum.rb +62 -0
- data/lib/spotify_web_api/models/o_auth_scope_enum.rb +124 -0
- data/lib/spotify_web_api/models/o_auth_token.rb +96 -0
- data/lib/spotify_web_api/models/paged_albums.rb +60 -0
- data/lib/spotify_web_api/models/paged_categories.rb +60 -0
- data/lib/spotify_web_api/models/paging_artist_discography_album_object.rb +125 -0
- data/lib/spotify_web_api/models/paging_artist_object.rb +125 -0
- data/lib/spotify_web_api/models/paging_featured_playlist_object.rb +71 -0
- data/lib/spotify_web_api/models/paging_object.rb +107 -0
- data/lib/spotify_web_api/models/paging_playlist_object.rb +125 -0
- data/lib/spotify_web_api/models/paging_playlist_track_object.rb +125 -0
- data/lib/spotify_web_api/models/paging_saved_album_object.rb +125 -0
- data/lib/spotify_web_api/models/paging_saved_audiobook_object.rb +125 -0
- data/lib/spotify_web_api/models/paging_saved_episode_object.rb +125 -0
- data/lib/spotify_web_api/models/paging_saved_show_object.rb +125 -0
- data/lib/spotify_web_api/models/paging_saved_track_object.rb +125 -0
- data/lib/spotify_web_api/models/paging_simplified_album_object.rb +125 -0
- data/lib/spotify_web_api/models/paging_simplified_audiobook_object.rb +125 -0
- data/lib/spotify_web_api/models/paging_simplified_chapter_object.rb +125 -0
- data/lib/spotify_web_api/models/paging_simplified_episode_object.rb +125 -0
- data/lib/spotify_web_api/models/paging_simplified_show_object.rb +125 -0
- data/lib/spotify_web_api/models/paging_simplified_track_object.rb +125 -0
- data/lib/spotify_web_api/models/paging_track_object.rb +125 -0
- data/lib/spotify_web_api/models/play_history_object.rb +90 -0
- data/lib/spotify_web_api/models/playlist_object.rb +213 -0
- data/lib/spotify_web_api/models/playlist_owner_object.rb +124 -0
- data/lib/spotify_web_api/models/playlist_snapshot_id.rb +62 -0
- data/lib/spotify_web_api/models/playlist_track_object.rb +116 -0
- data/lib/spotify_web_api/models/playlist_tracks_ref_object.rb +72 -0
- data/lib/spotify_web_api/models/playlist_user_object.rb +122 -0
- data/lib/spotify_web_api/models/playlists_followers_request.rb +63 -0
- data/lib/spotify_web_api/models/playlists_request.rb +96 -0
- data/lib/spotify_web_api/models/playlists_tracks_request.rb +84 -0
- data/lib/spotify_web_api/models/playlists_tracks_request1.rb +112 -0
- data/lib/spotify_web_api/models/playlists_tracks_request2.rb +87 -0
- data/lib/spotify_web_api/models/private_user_object.rb +200 -0
- data/lib/spotify_web_api/models/public_user_object.rb +144 -0
- data/lib/spotify_web_api/models/queue_object.rb +86 -0
- data/lib/spotify_web_api/models/reason_enum.rb +43 -0
- data/lib/spotify_web_api/models/recommendation_seed_object.rb +120 -0
- data/lib/spotify_web_api/models/recommendations_object.rb +86 -0
- data/lib/spotify_web_api/models/release_date_precision_enum.rb +40 -0
- data/lib/spotify_web_api/models/resume_point_object.rb +84 -0
- data/lib/spotify_web_api/models/saved_album_object.rb +85 -0
- data/lib/spotify_web_api/models/saved_audiobook_object.rb +85 -0
- data/lib/spotify_web_api/models/saved_episode_object.rb +82 -0
- data/lib/spotify_web_api/models/saved_show_object.rb +85 -0
- data/lib/spotify_web_api/models/saved_track_object.rb +85 -0
- data/lib/spotify_web_api/models/search_items.rb +122 -0
- data/lib/spotify_web_api/models/section_object.rb +201 -0
- data/lib/spotify_web_api/models/segment_object.rb +184 -0
- data/lib/spotify_web_api/models/show_base.rb +327 -0
- data/lib/spotify_web_api/models/show_object.rb +243 -0
- data/lib/spotify_web_api/models/simplified_album_object.rb +284 -0
- data/lib/spotify_web_api/models/simplified_artist_object.rb +122 -0
- data/lib/spotify_web_api/models/simplified_playlist_object.rb +203 -0
- data/lib/spotify_web_api/models/simplified_track_object.rb +251 -0
- data/lib/spotify_web_api/models/time_interval_object.rb +81 -0
- data/lib/spotify_web_api/models/track.rb +367 -0
- data/lib/spotify_web_api/models/track1.rb +62 -0
- data/lib/spotify_web_api/models/track_object.rb +301 -0
- data/lib/spotify_web_api/models/track_restriction_object.rb +80 -0
- data/lib/spotify_web_api/models/type2_enum.rb +26 -0
- data/lib/spotify_web_api/models/type3_enum.rb +26 -0
- data/lib/spotify_web_api/models/type4_enum.rb +26 -0
- data/lib/spotify_web_api/models/type5_enum.rb +26 -0
- data/lib/spotify_web_api/models/type6_enum.rb +26 -0
- data/lib/spotify_web_api/models/type8_enum.rb +26 -0
- data/lib/spotify_web_api/models/type9_enum.rb +26 -0
- data/lib/spotify_web_api/models/type_enum.rb +26 -0
- data/lib/spotify_web_api/models/users_playlists_request.rb +101 -0
- data/lib/spotify_web_api/utilities/date_time_helper.rb +11 -0
- data/lib/spotify_web_api/utilities/file_wrapper.rb +28 -0
- data/lib/spotify_web_api/utilities/union_type_lookup.rb +73 -0
- data/lib/spotify_web_api.rb +200 -0
- metadata +264 -0
|
@@ -0,0 +1,402 @@
|
|
|
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
|
+
# UsersController
|
|
8
|
+
class UsersController < BaseController
|
|
9
|
+
# Get detailed profile information about the current user (including the
|
|
10
|
+
# current user's username).
|
|
11
|
+
# @return [ApiResponse] Complete http response with raw body and status code.
|
|
12
|
+
def get_current_users_profile
|
|
13
|
+
@api_call
|
|
14
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
15
|
+
'/me',
|
|
16
|
+
Server::DEFAULT)
|
|
17
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
18
|
+
.auth(Single.new('oauth_2_0')))
|
|
19
|
+
.response(new_response_handler
|
|
20
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
21
|
+
.deserialize_into(PrivateUserObject.method(:from_hash))
|
|
22
|
+
.is_api_response(true)
|
|
23
|
+
.local_error('401',
|
|
24
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
|
25
|
+
' token or\nthe access token has expired. You should'\
|
|
26
|
+
' re-authenticate the user.\n",
|
|
27
|
+
UnauthorizedException)
|
|
28
|
+
.local_error('403',
|
|
29
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
|
30
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
|
31
|
+
' won't help here.\n",
|
|
32
|
+
ForbiddenException)
|
|
33
|
+
.local_error('429',
|
|
34
|
+
"The app has exceeded its rate limits.\n",
|
|
35
|
+
TooManyRequestsException))
|
|
36
|
+
.execute
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Get public profile information about a Spotify user.
|
|
40
|
+
# @param [String] user_id Required parameter: TODO: type description here
|
|
41
|
+
# @return [ApiResponse] Complete http response with raw body and status code.
|
|
42
|
+
def get_users_profile(user_id)
|
|
43
|
+
@api_call
|
|
44
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
45
|
+
'/users/{user_id}',
|
|
46
|
+
Server::DEFAULT)
|
|
47
|
+
.template_param(new_parameter(user_id, key: 'user_id')
|
|
48
|
+
.should_encode(true))
|
|
49
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
50
|
+
.auth(Single.new('oauth_2_0')))
|
|
51
|
+
.response(new_response_handler
|
|
52
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
53
|
+
.deserialize_into(PublicUserObject.method(:from_hash))
|
|
54
|
+
.is_api_response(true)
|
|
55
|
+
.local_error('401',
|
|
56
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
|
57
|
+
' token or\nthe access token has expired. You should'\
|
|
58
|
+
' re-authenticate the user.\n",
|
|
59
|
+
UnauthorizedException)
|
|
60
|
+
.local_error('403',
|
|
61
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
|
62
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
|
63
|
+
' won't help here.\n",
|
|
64
|
+
ForbiddenException)
|
|
65
|
+
.local_error('429',
|
|
66
|
+
"The app has exceeded its rate limits.\n",
|
|
67
|
+
TooManyRequestsException))
|
|
68
|
+
.execute
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Add the current user as a follower of a playlist.
|
|
72
|
+
# @param [String] playlist_id Required parameter: TODO: type description
|
|
73
|
+
# here
|
|
74
|
+
# @param [PlaylistsFollowersRequest] body Optional parameter: TODO: type
|
|
75
|
+
# description here
|
|
76
|
+
# @return [ApiResponse] Complete http response with raw body and status code.
|
|
77
|
+
def follow_playlist(playlist_id,
|
|
78
|
+
body: nil)
|
|
79
|
+
@api_call
|
|
80
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
|
81
|
+
'/playlists/{playlist_id}/followers',
|
|
82
|
+
Server::DEFAULT)
|
|
83
|
+
.template_param(new_parameter(playlist_id, key: 'playlist_id')
|
|
84
|
+
.should_encode(true))
|
|
85
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
|
86
|
+
.body_param(new_parameter(body))
|
|
87
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
|
88
|
+
.auth(Single.new('oauth_2_0')))
|
|
89
|
+
.response(new_response_handler
|
|
90
|
+
.is_response_void(true)
|
|
91
|
+
.is_api_response(true)
|
|
92
|
+
.local_error('401',
|
|
93
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
|
94
|
+
' token or\nthe access token has expired. You should'\
|
|
95
|
+
' re-authenticate the user.\n",
|
|
96
|
+
UnauthorizedException)
|
|
97
|
+
.local_error('403',
|
|
98
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
|
99
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
|
100
|
+
' won't help here.\n",
|
|
101
|
+
ForbiddenException)
|
|
102
|
+
.local_error('429',
|
|
103
|
+
"The app has exceeded its rate limits.\n",
|
|
104
|
+
TooManyRequestsException))
|
|
105
|
+
.execute
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Remove the current user as a follower of a playlist.
|
|
109
|
+
# @param [String] playlist_id Required parameter: TODO: type description
|
|
110
|
+
# here
|
|
111
|
+
# @return [ApiResponse] Complete http response with raw body and status code.
|
|
112
|
+
def unfollow_playlist(playlist_id)
|
|
113
|
+
@api_call
|
|
114
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
|
115
|
+
'/playlists/{playlist_id}/followers',
|
|
116
|
+
Server::DEFAULT)
|
|
117
|
+
.template_param(new_parameter(playlist_id, key: 'playlist_id')
|
|
118
|
+
.should_encode(true))
|
|
119
|
+
.auth(Single.new('oauth_2_0')))
|
|
120
|
+
.response(new_response_handler
|
|
121
|
+
.is_response_void(true)
|
|
122
|
+
.is_api_response(true)
|
|
123
|
+
.local_error('401',
|
|
124
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
|
125
|
+
' token or\nthe access token has expired. You should'\
|
|
126
|
+
' re-authenticate the user.\n",
|
|
127
|
+
UnauthorizedException)
|
|
128
|
+
.local_error('403',
|
|
129
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
|
130
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
|
131
|
+
' won't help here.\n",
|
|
132
|
+
ForbiddenException)
|
|
133
|
+
.local_error('429',
|
|
134
|
+
"The app has exceeded its rate limits.\n",
|
|
135
|
+
TooManyRequestsException))
|
|
136
|
+
.execute
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# Get the current user's followed artists.
|
|
140
|
+
# @param [ItemType1Enum] type Required parameter: Example:
|
|
141
|
+
# @param [String] after Optional parameter: TODO: type description here
|
|
142
|
+
# @param [Integer] limit Optional parameter: Example:20
|
|
143
|
+
# @return [ApiResponse] Complete http response with raw body and status code.
|
|
144
|
+
def get_followed(type,
|
|
145
|
+
after: nil,
|
|
146
|
+
limit: 20)
|
|
147
|
+
@api_call
|
|
148
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
149
|
+
'/me/following',
|
|
150
|
+
Server::DEFAULT)
|
|
151
|
+
.query_param(new_parameter(type, key: 'type'))
|
|
152
|
+
.query_param(new_parameter(after, key: 'after'))
|
|
153
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
|
154
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
155
|
+
.auth(Single.new('oauth_2_0')))
|
|
156
|
+
.response(new_response_handler
|
|
157
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
158
|
+
.deserialize_into(CursorPagedArtists.method(:from_hash))
|
|
159
|
+
.is_api_response(true)
|
|
160
|
+
.local_error('401',
|
|
161
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
|
162
|
+
' token or\nthe access token has expired. You should'\
|
|
163
|
+
' re-authenticate the user.\n",
|
|
164
|
+
UnauthorizedException)
|
|
165
|
+
.local_error('403',
|
|
166
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
|
167
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
|
168
|
+
' won't help here.\n",
|
|
169
|
+
ForbiddenException)
|
|
170
|
+
.local_error('429',
|
|
171
|
+
"The app has exceeded its rate limits.\n",
|
|
172
|
+
TooManyRequestsException))
|
|
173
|
+
.execute
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
# Add the current user as a follower of one or more artists or other Spotify
|
|
177
|
+
# users.
|
|
178
|
+
# @param [ItemType2Enum] type Required parameter: Example:
|
|
179
|
+
# @param [String] ids Required parameter: TODO: type description here
|
|
180
|
+
# @param [MeFollowingRequest] body Optional parameter: TODO: type
|
|
181
|
+
# description here
|
|
182
|
+
# @return [ApiResponse] Complete http response with raw body and status code.
|
|
183
|
+
def follow_artists_users(type,
|
|
184
|
+
ids,
|
|
185
|
+
body: nil)
|
|
186
|
+
@api_call
|
|
187
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
|
188
|
+
'/me/following',
|
|
189
|
+
Server::DEFAULT)
|
|
190
|
+
.query_param(new_parameter(type, key: 'type'))
|
|
191
|
+
.query_param(new_parameter(ids, key: 'ids'))
|
|
192
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
|
193
|
+
.body_param(new_parameter(body))
|
|
194
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
|
195
|
+
.auth(Single.new('oauth_2_0')))
|
|
196
|
+
.response(new_response_handler
|
|
197
|
+
.is_response_void(true)
|
|
198
|
+
.is_api_response(true)
|
|
199
|
+
.local_error('401',
|
|
200
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
|
201
|
+
' token or\nthe access token has expired. You should'\
|
|
202
|
+
' re-authenticate the user.\n",
|
|
203
|
+
UnauthorizedException)
|
|
204
|
+
.local_error('403',
|
|
205
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
|
206
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
|
207
|
+
' won't help here.\n",
|
|
208
|
+
ForbiddenException)
|
|
209
|
+
.local_error('429',
|
|
210
|
+
"The app has exceeded its rate limits.\n",
|
|
211
|
+
TooManyRequestsException))
|
|
212
|
+
.execute
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
# Remove the current user as a follower of one or more artists or other
|
|
216
|
+
# Spotify users.
|
|
217
|
+
# @param [ItemType3Enum] type Required parameter: Example:
|
|
218
|
+
# @param [String] ids Required parameter: TODO: type description here
|
|
219
|
+
# @param [MeFollowingRequest1] body Optional parameter: TODO: type
|
|
220
|
+
# description here
|
|
221
|
+
# @return [ApiResponse] Complete http response with raw body and status code.
|
|
222
|
+
def unfollow_artists_users(type,
|
|
223
|
+
ids,
|
|
224
|
+
body: nil)
|
|
225
|
+
@api_call
|
|
226
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
|
227
|
+
'/me/following',
|
|
228
|
+
Server::DEFAULT)
|
|
229
|
+
.query_param(new_parameter(type, key: 'type'))
|
|
230
|
+
.query_param(new_parameter(ids, key: 'ids'))
|
|
231
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
|
232
|
+
.body_param(new_parameter(body))
|
|
233
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
|
234
|
+
.auth(Single.new('oauth_2_0')))
|
|
235
|
+
.response(new_response_handler
|
|
236
|
+
.is_response_void(true)
|
|
237
|
+
.is_api_response(true)
|
|
238
|
+
.local_error('401',
|
|
239
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
|
240
|
+
' token or\nthe access token has expired. You should'\
|
|
241
|
+
' re-authenticate the user.\n",
|
|
242
|
+
UnauthorizedException)
|
|
243
|
+
.local_error('403',
|
|
244
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
|
245
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
|
246
|
+
' won't help here.\n",
|
|
247
|
+
ForbiddenException)
|
|
248
|
+
.local_error('429',
|
|
249
|
+
"The app has exceeded its rate limits.\n",
|
|
250
|
+
TooManyRequestsException))
|
|
251
|
+
.execute
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
# Check to see if the current user is following one or more artists or other
|
|
255
|
+
# Spotify users.
|
|
256
|
+
# @param [ItemType3Enum] type Required parameter: Example:
|
|
257
|
+
# @param [String] ids Required parameter: TODO: type description here
|
|
258
|
+
# @return [ApiResponse] Complete http response with raw body and status code.
|
|
259
|
+
def check_current_user_follows(type,
|
|
260
|
+
ids)
|
|
261
|
+
@api_call
|
|
262
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
263
|
+
'/me/following/contains',
|
|
264
|
+
Server::DEFAULT)
|
|
265
|
+
.query_param(new_parameter(type, key: 'type'))
|
|
266
|
+
.query_param(new_parameter(ids, key: 'ids'))
|
|
267
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
268
|
+
.auth(Single.new('oauth_2_0')))
|
|
269
|
+
.response(new_response_handler
|
|
270
|
+
.deserializer(APIHelper.method(:deserialize_primitive_types))
|
|
271
|
+
.is_api_response(true)
|
|
272
|
+
.is_response_array(true)
|
|
273
|
+
.is_primitive_response(true)
|
|
274
|
+
.local_error('401',
|
|
275
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
|
276
|
+
' token or\nthe access token has expired. You should'\
|
|
277
|
+
' re-authenticate the user.\n",
|
|
278
|
+
UnauthorizedException)
|
|
279
|
+
.local_error('403',
|
|
280
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
|
281
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
|
282
|
+
' won't help here.\n",
|
|
283
|
+
ForbiddenException)
|
|
284
|
+
.local_error('429',
|
|
285
|
+
"The app has exceeded its rate limits.\n",
|
|
286
|
+
TooManyRequestsException))
|
|
287
|
+
.execute
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
# Check to see if one or more Spotify users are following a specified
|
|
291
|
+
# playlist.
|
|
292
|
+
# @param [String] playlist_id Required parameter: TODO: type description
|
|
293
|
+
# here
|
|
294
|
+
# @param [String] ids Required parameter: TODO: type description here
|
|
295
|
+
# @return [ApiResponse] Complete http response with raw body and status code.
|
|
296
|
+
def check_if_user_follows_playlist(playlist_id,
|
|
297
|
+
ids)
|
|
298
|
+
@api_call
|
|
299
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
300
|
+
'/playlists/{playlist_id}/followers/contains',
|
|
301
|
+
Server::DEFAULT)
|
|
302
|
+
.template_param(new_parameter(playlist_id, key: 'playlist_id')
|
|
303
|
+
.should_encode(true))
|
|
304
|
+
.query_param(new_parameter(ids, key: 'ids'))
|
|
305
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
306
|
+
.auth(Single.new('oauth_2_0')))
|
|
307
|
+
.response(new_response_handler
|
|
308
|
+
.deserializer(APIHelper.method(:deserialize_primitive_types))
|
|
309
|
+
.is_api_response(true)
|
|
310
|
+
.is_response_array(true)
|
|
311
|
+
.is_primitive_response(true)
|
|
312
|
+
.local_error('401',
|
|
313
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
|
314
|
+
' token or\nthe access token has expired. You should'\
|
|
315
|
+
' re-authenticate the user.\n",
|
|
316
|
+
UnauthorizedException)
|
|
317
|
+
.local_error('403',
|
|
318
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
|
319
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
|
320
|
+
' won't help here.\n",
|
|
321
|
+
ForbiddenException)
|
|
322
|
+
.local_error('429',
|
|
323
|
+
"The app has exceeded its rate limits.\n",
|
|
324
|
+
TooManyRequestsException))
|
|
325
|
+
.execute
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
# Get the current user's top artists based on calculated affinity.
|
|
329
|
+
# @param [String] time_range Optional parameter: Example:medium_term
|
|
330
|
+
# @param [Integer] limit Optional parameter: Example:20
|
|
331
|
+
# @param [Integer] offset Optional parameter: Example:0
|
|
332
|
+
# @return [ApiResponse] Complete http response with raw body and status code.
|
|
333
|
+
def get_users_top_artists(time_range: 'medium_term',
|
|
334
|
+
limit: 20,
|
|
335
|
+
offset: 0)
|
|
336
|
+
@api_call
|
|
337
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
338
|
+
'/me/top/artists',
|
|
339
|
+
Server::DEFAULT)
|
|
340
|
+
.query_param(new_parameter(time_range, key: 'time_range'))
|
|
341
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
|
342
|
+
.query_param(new_parameter(offset, key: 'offset'))
|
|
343
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
344
|
+
.auth(Single.new('oauth_2_0')))
|
|
345
|
+
.response(new_response_handler
|
|
346
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
347
|
+
.deserialize_into(PagingArtistObject.method(:from_hash))
|
|
348
|
+
.is_api_response(true)
|
|
349
|
+
.local_error('401',
|
|
350
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
|
351
|
+
' token or\nthe access token has expired. You should'\
|
|
352
|
+
' re-authenticate the user.\n",
|
|
353
|
+
UnauthorizedException)
|
|
354
|
+
.local_error('403',
|
|
355
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
|
356
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
|
357
|
+
' won't help here.\n",
|
|
358
|
+
ForbiddenException)
|
|
359
|
+
.local_error('429',
|
|
360
|
+
"The app has exceeded its rate limits.\n",
|
|
361
|
+
TooManyRequestsException))
|
|
362
|
+
.execute
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
# Get the current user's top tracks based on calculated affinity.
|
|
366
|
+
# @param [String] time_range Optional parameter: Example:medium_term
|
|
367
|
+
# @param [Integer] limit Optional parameter: Example:20
|
|
368
|
+
# @param [Integer] offset Optional parameter: Example:0
|
|
369
|
+
# @return [ApiResponse] Complete http response with raw body and status code.
|
|
370
|
+
def get_users_top_tracks(time_range: 'medium_term',
|
|
371
|
+
limit: 20,
|
|
372
|
+
offset: 0)
|
|
373
|
+
@api_call
|
|
374
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
375
|
+
'/me/top/tracks',
|
|
376
|
+
Server::DEFAULT)
|
|
377
|
+
.query_param(new_parameter(time_range, key: 'time_range'))
|
|
378
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
|
379
|
+
.query_param(new_parameter(offset, key: 'offset'))
|
|
380
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
381
|
+
.auth(Single.new('oauth_2_0')))
|
|
382
|
+
.response(new_response_handler
|
|
383
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
384
|
+
.deserialize_into(PagingTrackObject.method(:from_hash))
|
|
385
|
+
.is_api_response(true)
|
|
386
|
+
.local_error('401',
|
|
387
|
+
"Bad or expired token. This can happen if the user revoked a'\
|
|
388
|
+
' token or\nthe access token has expired. You should'\
|
|
389
|
+
' re-authenticate the user.\n",
|
|
390
|
+
UnauthorizedException)
|
|
391
|
+
.local_error('403',
|
|
392
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired'\
|
|
393
|
+
'\ntimestamp...). Unfortunately, re-authenticating the user'\
|
|
394
|
+
' won't help here.\n",
|
|
395
|
+
ForbiddenException)
|
|
396
|
+
.local_error('429',
|
|
397
|
+
"The app has exceeded its rate limits.\n",
|
|
398
|
+
TooManyRequestsException))
|
|
399
|
+
.execute
|
|
400
|
+
end
|
|
401
|
+
end
|
|
402
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
# Class for exceptions when there is a network error, status code error, etc.
|
|
8
|
+
class APIException < CoreLibrary::ApiException
|
|
9
|
+
# Provides a human-readable string representation of the object.
|
|
10
|
+
def to_s
|
|
11
|
+
class_name = self.class.name.split('::').last
|
|
12
|
+
"<#{class_name} status_code: #{@response_code}, reason: #{@reason}>"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
16
|
+
def inspect
|
|
17
|
+
class_name = self.class.name.split('::').last
|
|
18
|
+
"<#{class_name} status_code: #{@response_code.inspect}, reason: #{@reason.inspect}>"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
# BadRequest class.
|
|
8
|
+
class BadRequestException < APIException
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# TODO: Write general description for this method
|
|
13
|
+
# @return [ErrorObject]
|
|
14
|
+
attr_accessor :error
|
|
15
|
+
|
|
16
|
+
# The constructor.
|
|
17
|
+
# @param [String] reason The reason for raising an exception.
|
|
18
|
+
# @param [HttpResponse] response The HttpReponse of the API call.
|
|
19
|
+
def initialize(reason, response)
|
|
20
|
+
super(reason, response)
|
|
21
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
|
22
|
+
unbox(hash)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Populates this object by extracting properties from a hash.
|
|
26
|
+
# @param [Hash] hash The deserialized response sent by the server in the
|
|
27
|
+
# response body.
|
|
28
|
+
def unbox(hash)
|
|
29
|
+
return nil unless hash
|
|
30
|
+
|
|
31
|
+
@error = ErrorObject.from_hash(hash['error']) if hash['error']
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Provides a human-readable string representation of the object.
|
|
35
|
+
def to_s
|
|
36
|
+
class_name = self.class.name.split('::').last
|
|
37
|
+
"<#{class_name} error: #{@error}>"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
41
|
+
def inspect
|
|
42
|
+
class_name = self.class.name.split('::').last
|
|
43
|
+
"<#{class_name} error: #{@error.inspect}>"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
# Forbidden class.
|
|
8
|
+
class ForbiddenException < APIException
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# TODO: Write general description for this method
|
|
13
|
+
# @return [ErrorObject]
|
|
14
|
+
attr_accessor :error
|
|
15
|
+
|
|
16
|
+
# The constructor.
|
|
17
|
+
# @param [String] reason The reason for raising an exception.
|
|
18
|
+
# @param [HttpResponse] response The HttpReponse of the API call.
|
|
19
|
+
def initialize(reason, response)
|
|
20
|
+
super(reason, response)
|
|
21
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
|
22
|
+
unbox(hash)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Populates this object by extracting properties from a hash.
|
|
26
|
+
# @param [Hash] hash The deserialized response sent by the server in the
|
|
27
|
+
# response body.
|
|
28
|
+
def unbox(hash)
|
|
29
|
+
return nil unless hash
|
|
30
|
+
|
|
31
|
+
@error = ErrorObject.from_hash(hash['error']) if hash['error']
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Provides a human-readable string representation of the object.
|
|
35
|
+
def to_s
|
|
36
|
+
class_name = self.class.name.split('::').last
|
|
37
|
+
"<#{class_name} error: #{@error}>"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
41
|
+
def inspect
|
|
42
|
+
class_name = self.class.name.split('::').last
|
|
43
|
+
"<#{class_name} error: #{@error.inspect}>"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
# NotFound class.
|
|
8
|
+
class NotFoundException < APIException
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# TODO: Write general description for this method
|
|
13
|
+
# @return [ErrorObject]
|
|
14
|
+
attr_accessor :error
|
|
15
|
+
|
|
16
|
+
# The constructor.
|
|
17
|
+
# @param [String] reason The reason for raising an exception.
|
|
18
|
+
# @param [HttpResponse] response The HttpReponse of the API call.
|
|
19
|
+
def initialize(reason, response)
|
|
20
|
+
super(reason, response)
|
|
21
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
|
22
|
+
unbox(hash)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Populates this object by extracting properties from a hash.
|
|
26
|
+
# @param [Hash] hash The deserialized response sent by the server in the
|
|
27
|
+
# response body.
|
|
28
|
+
def unbox(hash)
|
|
29
|
+
return nil unless hash
|
|
30
|
+
|
|
31
|
+
@error = ErrorObject.from_hash(hash['error']) if hash['error']
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Provides a human-readable string representation of the object.
|
|
35
|
+
def to_s
|
|
36
|
+
class_name = self.class.name.split('::').last
|
|
37
|
+
"<#{class_name} error: #{@error}>"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
41
|
+
def inspect
|
|
42
|
+
class_name = self.class.name.split('::').last
|
|
43
|
+
"<#{class_name} error: #{@error.inspect}>"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
# OAuth 2 Authorization endpoint exception.
|
|
8
|
+
class OAuthProviderException < APIException
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# Gets or sets error code.
|
|
13
|
+
# @return [OAuthProviderErrorEnum]
|
|
14
|
+
attr_accessor :error
|
|
15
|
+
|
|
16
|
+
# Gets or sets human-readable text providing additional information on
|
|
17
|
+
# error.
|
|
18
|
+
# Used to assist the client developer in understanding the error that
|
|
19
|
+
# occurred.
|
|
20
|
+
# @return [String]
|
|
21
|
+
attr_accessor :error_description
|
|
22
|
+
|
|
23
|
+
# Gets or sets a URI identifying a human-readable web page with information
|
|
24
|
+
# about the error, used to provide the client developer with additional
|
|
25
|
+
# information about the error.
|
|
26
|
+
# @return [String]
|
|
27
|
+
attr_accessor :error_uri
|
|
28
|
+
|
|
29
|
+
# The constructor.
|
|
30
|
+
# @param [String] reason The reason for raising an exception.
|
|
31
|
+
# @param [HttpResponse] response The HttpReponse of the API call.
|
|
32
|
+
def initialize(reason, response)
|
|
33
|
+
super(reason, response)
|
|
34
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
|
35
|
+
unbox(hash)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Populates this object by extracting properties from a hash.
|
|
39
|
+
# @param [Hash] hash The deserialized response sent by the server in the
|
|
40
|
+
# response body.
|
|
41
|
+
def unbox(hash)
|
|
42
|
+
return nil unless hash
|
|
43
|
+
|
|
44
|
+
@error = hash.key?('error') ? hash['error'] : nil
|
|
45
|
+
@error_description =
|
|
46
|
+
hash.key?('error_description') ? hash['error_description'] : SKIP
|
|
47
|
+
@error_uri = hash.key?('error_uri') ? hash['error_uri'] : SKIP
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Provides a human-readable string representation of the object.
|
|
51
|
+
def to_s
|
|
52
|
+
class_name = self.class.name.split('::').last
|
|
53
|
+
"<#{class_name} error: #{@error}, error_description: #{@error_description}, error_uri:"\
|
|
54
|
+
" #{@error_uri}>"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
58
|
+
def inspect
|
|
59
|
+
class_name = self.class.name.split('::').last
|
|
60
|
+
"<#{class_name} error: #{@error.inspect}, error_description: #{@error_description.inspect},"\
|
|
61
|
+
" error_uri: #{@error_uri.inspect}>"
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
# TooManyRequests class.
|
|
8
|
+
class TooManyRequestsException < APIException
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# TODO: Write general description for this method
|
|
13
|
+
# @return [ErrorObject]
|
|
14
|
+
attr_accessor :error
|
|
15
|
+
|
|
16
|
+
# The constructor.
|
|
17
|
+
# @param [String] reason The reason for raising an exception.
|
|
18
|
+
# @param [HttpResponse] response The HttpReponse of the API call.
|
|
19
|
+
def initialize(reason, response)
|
|
20
|
+
super(reason, response)
|
|
21
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
|
22
|
+
unbox(hash)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Populates this object by extracting properties from a hash.
|
|
26
|
+
# @param [Hash] hash The deserialized response sent by the server in the
|
|
27
|
+
# response body.
|
|
28
|
+
def unbox(hash)
|
|
29
|
+
return nil unless hash
|
|
30
|
+
|
|
31
|
+
@error = ErrorObject.from_hash(hash['error']) if hash['error']
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Provides a human-readable string representation of the object.
|
|
35
|
+
def to_s
|
|
36
|
+
class_name = self.class.name.split('::').last
|
|
37
|
+
"<#{class_name} error: #{@error}>"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
41
|
+
def inspect
|
|
42
|
+
class_name = self.class.name.split('::').last
|
|
43
|
+
"<#{class_name} error: #{@error.inspect}>"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|