Class: SpotifyWebApi::AudiobooksController
- Inherits:
-
BaseController
- Object
- BaseController
- SpotifyWebApi::AudiobooksController
- Defined in:
- lib/spotify_web_api/controllers/audiobooks_controller.rb
Overview
AudiobooksController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#check_users_saved_audiobooks(ids) ⇒ Array[TrueClass | FalseClass]
Check if one or more audiobooks are already saved in the current Spotify user’s library.
-
#get_an_audiobook(id, market: nil) ⇒ AudiobookObject
Get Spotify catalog information for a single audiobook.
-
#get_audiobook_chapters(id, market: nil, limit: 20, offset: 0) ⇒ PagingSimplifiedChapterObject
Get Spotify catalog information about an audiobook’s chapters.
-
#get_multiple_audiobooks(ids, market: nil) ⇒ ManyAudiobooks
Get Spotify catalog information for several audiobooks identified by their Spotify IDs.
-
#get_users_saved_audiobooks(limit: 20, offset: 0) ⇒ PagingSavedAudiobookObject
Get a list of the audiobooks saved in the current Spotify user’s ‘Your Music’ library.
-
#remove_audiobooks_user(ids) ⇒ void
Remove one or more audiobooks from the Spotify user’s library.
-
#save_audiobooks_user(ids) ⇒ void
Save one or more audiobooks to the current Spotify user’s library.
Methods inherited from BaseController
#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent
Constructor Details
This class inherits a constructor from SpotifyWebApi::BaseController
Instance Method Details
#check_users_saved_audiobooks(ids) ⇒ Array[TrueClass | FalseClass]
Check if one or more audiobooks are already saved in the current Spotify user’s library.
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# File 'lib/spotify_web_api/controllers/audiobooks_controller.rb', line 229 def check_users_saved_audiobooks(ids) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/me/audiobooks/contains', Server::DEFAULT) .query_param(new_parameter(ids, key: 'ids')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('oauth_2_0'))) .response(new_response_handler .deserializer(APIHelper.method(:deserialize_primitive_types)) .is_api_response(true) .is_response_array(true) .is_primitive_response(true) .local_error('401', "Bad or expired token. This can happen if the user revoked a'\ ' token or\nthe access token has expired. You should'\ ' re-authenticate the user.\n", UnauthorizedException) .local_error('403', "Bad OAuth request (wrong consumer key, bad nonce, expired'\ '\ntimestamp...). Unfortunately, re-authenticating the user'\ ' won't help here.\n", ForbiddenException) .local_error('429', "The app has exceeded its rate limits.\n", TooManyRequestsException)) .execute end |
#get_an_audiobook(id, market: nil) ⇒ AudiobookObject
Get Spotify catalog information for a single audiobook. Audiobooks are only available within the US, UK, Canada, Ireland, New Zealand and Australia markets.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/spotify_web_api/controllers/audiobooks_controller.rb', line 15 def get_an_audiobook(id, market: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/audiobooks/{id}', Server::DEFAULT) .template_param(new_parameter(id, key: 'id') .should_encode(true)) .query_param(new_parameter(market, key: 'market')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('oauth_2_0'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(AudiobookObject.method(:from_hash)) .is_api_response(true) .local_error('400', "The request contains malformed data in path, query parameters,'\ ' or body.\n", BadRequestException) .local_error('401', "Bad or expired token. This can happen if the user revoked a'\ ' token or\nthe access token has expired. You should'\ ' re-authenticate the user.\n", UnauthorizedException) .local_error('403', "Bad OAuth request (wrong consumer key, bad nonce, expired'\ '\ntimestamp...). Unfortunately, re-authenticating the user'\ ' won't help here.\n", ForbiddenException) .local_error('404', "The requested resource cannot be found.\n", NotFoundException) .local_error('429', "The app has exceeded its rate limits.\n", TooManyRequestsException)) .execute end |
#get_audiobook_chapters(id, market: nil, limit: 20, offset: 0) ⇒ PagingSimplifiedChapterObject
Get Spotify catalog information about an audiobook’s chapters. Audiobooks are only available within the US, UK, Canada, Ireland, New Zealand and Australia markets.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/spotify_web_api/controllers/audiobooks_controller.rb', line 97 def get_audiobook_chapters(id, market: nil, limit: 20, offset: 0) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/audiobooks/{id}/chapters', Server::DEFAULT) .template_param(new_parameter(id, key: 'id') .should_encode(true)) .query_param(new_parameter(market, key: 'market')) .query_param(new_parameter(limit, key: 'limit')) .query_param(new_parameter(offset, key: 'offset')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('oauth_2_0'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(PagingSimplifiedChapterObject.method(:from_hash)) .is_api_response(true) .local_error('401', "Bad or expired token. This can happen if the user revoked a'\ ' token or\nthe access token has expired. You should'\ ' re-authenticate the user.\n", UnauthorizedException) .local_error('403', "Bad OAuth request (wrong consumer key, bad nonce, expired'\ '\ntimestamp...). Unfortunately, re-authenticating the user'\ ' won't help here.\n", ForbiddenException) .local_error('429', "The app has exceeded its rate limits.\n", TooManyRequestsException)) .execute end |
#get_multiple_audiobooks(ids, market: nil) ⇒ ManyAudiobooks
Get Spotify catalog information for several audiobooks identified by their Spotify IDs. Audiobooks are only available within the US, UK, Canada, Ireland, New Zealand and Australia markets.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/spotify_web_api/controllers/audiobooks_controller.rb', line 59 def get_multiple_audiobooks(ids, market: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/audiobooks', Server::DEFAULT) .query_param(new_parameter(ids, key: 'ids')) .query_param(new_parameter(market, key: 'market')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('oauth_2_0'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ManyAudiobooks.method(:from_hash)) .is_api_response(true) .local_error('401', "Bad or expired token. This can happen if the user revoked a'\ ' token or\nthe access token has expired. You should'\ ' re-authenticate the user.\n", UnauthorizedException) .local_error('403', "Bad OAuth request (wrong consumer key, bad nonce, expired'\ '\ntimestamp...). Unfortunately, re-authenticating the user'\ ' won't help here.\n", ForbiddenException) .local_error('429', "The app has exceeded its rate limits.\n", TooManyRequestsException)) .execute end |
#get_users_saved_audiobooks(limit: 20, offset: 0) ⇒ PagingSavedAudiobookObject
Get a list of the audiobooks saved in the current Spotify user’s ‘Your Music’ library.
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/spotify_web_api/controllers/audiobooks_controller.rb', line 137 def get_users_saved_audiobooks(limit: 20, offset: 0) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/me/audiobooks', Server::DEFAULT) .query_param(new_parameter(limit, key: 'limit')) .query_param(new_parameter(offset, key: 'offset')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('oauth_2_0'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(PagingSavedAudiobookObject.method(:from_hash)) .is_api_response(true) .local_error('401', "Bad or expired token. This can happen if the user revoked a'\ ' token or\nthe access token has expired. You should'\ ' re-authenticate the user.\n", UnauthorizedException) .local_error('403', "Bad OAuth request (wrong consumer key, bad nonce, expired'\ '\ntimestamp...). Unfortunately, re-authenticating the user'\ ' won't help here.\n", ForbiddenException) .local_error('429', "The app has exceeded its rate limits.\n", TooManyRequestsException)) .execute end |
#remove_audiobooks_user(ids) ⇒ void
This method returns an undefined value.
Remove one or more audiobooks from the Spotify user’s library.
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/spotify_web_api/controllers/audiobooks_controller.rb', line 199 def remove_audiobooks_user(ids) new_api_call_builder .request(new_request_builder(HttpMethodEnum::DELETE, '/me/audiobooks', Server::DEFAULT) .query_param(new_parameter(ids, key: 'ids')) .auth(Single.new('oauth_2_0'))) .response(new_response_handler .is_response_void(true) .is_api_response(true) .local_error('401', "Bad or expired token. This can happen if the user revoked a'\ ' token or\nthe access token has expired. You should'\ ' re-authenticate the user.\n", UnauthorizedException) .local_error('403', "Bad OAuth request (wrong consumer key, bad nonce, expired'\ '\ntimestamp...). Unfortunately, re-authenticating the user'\ ' won't help here.\n", ForbiddenException) .local_error('429', "The app has exceeded its rate limits.\n", TooManyRequestsException)) .execute end |
#save_audiobooks_user(ids) ⇒ void
This method returns an undefined value.
Save one or more audiobooks to the current Spotify user’s library.
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/spotify_web_api/controllers/audiobooks_controller.rb', line 170 def save_audiobooks_user(ids) new_api_call_builder .request(new_request_builder(HttpMethodEnum::PUT, '/me/audiobooks', Server::DEFAULT) .query_param(new_parameter(ids, key: 'ids')) .auth(Single.new('oauth_2_0'))) .response(new_response_handler .is_response_void(true) .is_api_response(true) .local_error('401', "Bad or expired token. This can happen if the user revoked a'\ ' token or\nthe access token has expired. You should'\ ' re-authenticate the user.\n", UnauthorizedException) .local_error('403', "Bad OAuth request (wrong consumer key, bad nonce, expired'\ '\ntimestamp...). Unfortunately, re-authenticating the user'\ ' won't help here.\n", ForbiddenException) .local_error('429', "The app has exceeded its rate limits.\n", TooManyRequestsException)) .execute end |