Class: Spotted::Resources::Playlists::Tracks
- Inherits:
-
Object
- Object
- Spotted::Resources::Playlists::Tracks
- Defined in:
- lib/spotted/resources/playlists/tracks.rb
Instance Method Summary collapse
-
#add(playlist_id, body_position: nil, body_uris: nil, request_options: {}) ⇒ Spotted::Models::Playlists::TrackAddResponse
Some parameter documentations has been truncated, see Models::Playlists::TrackAddParams for more details.
-
#initialize(client:) ⇒ Tracks
constructor
private
A new instance of Tracks.
-
#list(playlist_id, additional_types: nil, fields: nil, limit: nil, market: nil, offset: nil, request_options: {}) ⇒ Spotted::Internal::CursorURLPage<Spotted::Models::PlaylistTrackObject>
Some parameter documentations has been truncated, see Models::Playlists::TrackListParams for more details.
-
#remove(playlist_id, tracks: , snapshot_id: nil, request_options: {}) ⇒ Spotted::Models::Playlists::TrackRemoveResponse
Some parameter documentations has been truncated, see Models::Playlists::TrackRemoveParams for more details.
-
#update(playlist_id, body_uris: nil, insert_before: nil, range_length: nil, range_start: nil, snapshot_id: nil, request_options: {}) ⇒ Spotted::Models::Playlists::TrackUpdateResponse
Some parameter documentations has been truncated, see Models::Playlists::TrackUpdateParams for more details.
Constructor Details
#initialize(client:) ⇒ Tracks
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Tracks.
151 152 153 |
# File 'lib/spotted/resources/playlists/tracks.rb', line 151 def initialize(client:) @client = client end |
Instance Method Details
#add(playlist_id, body_position: nil, body_uris: nil, request_options: {}) ⇒ Spotted::Models::Playlists::TrackAddResponse
Some parameter documentations has been truncated, see Models::Playlists::TrackAddParams for more details.
Add one or more items to a user’s playlist.
106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/spotted/resources/playlists/tracks.rb', line 106 def add(playlist_id, params = {}) parsed, = Spotted::Playlists::TrackAddParams.dump_request(params) query_params = [:query_position, :query_uris] @client.request( method: :post, path: ["playlists/%1$s/tracks", playlist_id], query: parsed.slice(*query_params).transform_keys(query_position: "position", query_uris: "uris"), body: parsed.except(*query_params), model: Spotted::Models::Playlists::TrackAddResponse, options: ) end |
#list(playlist_id, additional_types: nil, fields: nil, limit: nil, market: nil, offset: nil, request_options: {}) ⇒ Spotted::Internal::CursorURLPage<Spotted::Models::PlaylistTrackObject>
Some parameter documentations has been truncated, see Models::Playlists::TrackListParams for more details.
Get full details of the items of a playlist owned by a Spotify user.
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/spotted/resources/playlists/tracks.rb', line 76 def list(playlist_id, params = {}) parsed, = Spotted::Playlists::TrackListParams.dump_request(params) @client.request( method: :get, path: ["playlists/%1$s/tracks", playlist_id], query: parsed, page: Spotted::Internal::CursorURLPage, model: Spotted::PlaylistTrackObject, options: ) end |
#remove(playlist_id, tracks: , snapshot_id: nil, request_options: {}) ⇒ Spotted::Models::Playlists::TrackRemoveResponse
Some parameter documentations has been truncated, see Models::Playlists::TrackRemoveParams for more details.
Remove one or more items from a user’s playlist.
137 138 139 140 141 142 143 144 145 146 |
# File 'lib/spotted/resources/playlists/tracks.rb', line 137 def remove(playlist_id, params) parsed, = Spotted::Playlists::TrackRemoveParams.dump_request(params) @client.request( method: :delete, path: ["playlists/%1$s/tracks", playlist_id], body: parsed, model: Spotted::Models::Playlists::TrackRemoveResponse, options: ) end |
#update(playlist_id, body_uris: nil, insert_before: nil, range_length: nil, range_start: nil, snapshot_id: nil, request_options: {}) ⇒ Spotted::Models::Playlists::TrackUpdateResponse
Some parameter documentations has been truncated, see Models::Playlists::TrackUpdateParams for more details.
Either reorder or replace items in a playlist depending on the request’s parameters. To reorder items, include ‘range_start`, `insert_before`, `range_length` and `snapshot_id` in the request’s body. To replace items, include ‘uris` as either a query parameter or in the request’s body. Replacing items in a playlist will overwrite its existing items. This operation can be used for replacing or clearing items in a playlist. <br/> Note: Replace and reorder are mutually exclusive operations which share the same endpoint, but have different parameters. These operations can’t be applied together in a single request.
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/spotted/resources/playlists/tracks.rb', line 39 def update(playlist_id, params = {}) parsed, = Spotted::Playlists::TrackUpdateParams.dump_request(params) query_params = [:query_uris] @client.request( method: :put, path: ["playlists/%1$s/tracks", playlist_id], query: parsed.slice(*query_params).transform_keys(query_uris: "uris"), body: parsed.except(*query_params), model: Spotted::Models::Playlists::TrackUpdateResponse, options: ) end |