Class: SpotifyWebApi::ShowsController
- Inherits:
-
BaseController
- Object
- BaseController
- SpotifyWebApi::ShowsController
- Defined in:
- lib/spotify_web_api/controllers/shows_controller.rb
Overview
ShowsController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#check_users_saved_shows(ids) ⇒ Array[TrueClass | FalseClass]
Check if one or more shows is already saved in the current Spotify user’s library.
-
#get_a_show(id, market: nil) ⇒ ShowObject
Get Spotify catalog information for a single show identified by its unique Spotify ID.
-
#get_a_shows_episodes(id, market: nil, limit: 20, offset: 0) ⇒ PagingSimplifiedEpisodeObject
Get Spotify catalog information about an show’s episodes.
-
#get_multiple_shows(ids, market: nil) ⇒ ManySimplifiedShows
Get Spotify catalog information for several shows based on their Spotify IDs.
-
#get_users_saved_shows(limit: 20, offset: 0) ⇒ PagingSavedShowObject
Get a list of shows saved in the current Spotify user’s library.
-
#remove_shows_user(ids, market: nil, body: nil) ⇒ void
Delete one or more shows from current Spotify user’s library.
-
#save_shows_user(ids, body: nil) ⇒ void
Save one or more shows to 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_shows(ids) ⇒ Array[TrueClass | FalseClass]
Check if one or more shows is already saved in the current Spotify user’s library.
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 257 258 259 |
# File 'lib/spotify_web_api/controllers/shows_controller.rb', line 232 def check_users_saved_shows(ids) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/me/shows/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_a_show(id, market: nil) ⇒ ShowObject
Get Spotify catalog information for a single show identified by its unique Spotify ID.
14 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 |
# File 'lib/spotify_web_api/controllers/shows_controller.rb', line 14 def get_a_show(id, market: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/shows/{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(ShowObject.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_a_shows_episodes(id, market: nil, limit: 20, offset: 0) ⇒ PagingSimplifiedEpisodeObject
Get Spotify catalog information about an show’s episodes. Optional parameters can be used to limit the number of episodes returned.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/spotify_web_api/controllers/shows_controller.rb', line 87 def get_a_shows_episodes(id, market: nil, limit: 20, offset: 0) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/shows/{id}/episodes', 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(PagingSimplifiedEpisodeObject.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_shows(ids, market: nil) ⇒ ManySimplifiedShows
Get Spotify catalog information for several shows based on their Spotify IDs.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/spotify_web_api/controllers/shows_controller.rb', line 50 def get_multiple_shows(ids, market: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/shows', 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(ManySimplifiedShows.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_shows(limit: 20, offset: 0) ⇒ PagingSavedShowObject
Get a list of shows saved in the current Spotify user’s library. Optional parameters can be used to limit the number of shows returned.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/spotify_web_api/controllers/shows_controller.rb', line 127 def get_users_saved_shows(limit: 20, offset: 0) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/me/shows', 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(PagingSavedShowObject.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_shows_user(ids, market: nil, body: nil) ⇒ void
This method returns an undefined value.
Delete one or more shows from current Spotify user’s library.
196 197 198 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 224 225 226 |
# File 'lib/spotify_web_api/controllers/shows_controller.rb', line 196 def remove_shows_user(ids, market: nil, body: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::DELETE, '/me/shows', Server::DEFAULT) .query_param(new_parameter(ids, key: 'ids')) .header_param(new_parameter('application/json', key: 'Content-Type')) .query_param(new_parameter(market, key: 'market')) .body_param(new_parameter(body)) .body_serializer(proc do |param| param.to_json unless param.nil? end) .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_shows_user(ids, body: nil) ⇒ void
This method returns an undefined value.
Save one or more shows to current Spotify user’s library.
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/spotify_web_api/controllers/shows_controller.rb', line 161 def save_shows_user(ids, body: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::PUT, '/me/shows', Server::DEFAULT) .query_param(new_parameter(ids, key: 'ids')) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .body_serializer(proc do |param| param.to_json unless param.nil? end) .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 |