Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change type of position parameter for playlist_add_item #409

Merged
merged 5 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## 0.12(unreleased)
## 0.12 (unreleased )
**New features**
- ([#390](https://github.com/ramsayleung/rspotify/pull/390)) The `scopes!` macro supports to split the scope by whitespace.

**Breaking changes**
- ([#409](https://github.com/ramsayleung/rspotify/pull/409)) Change type of `position` parameter in `playlist_add_items` endpoint from `Opinion<Duration>` to `Opinion<u32>`

## 0.11.7 (2023.04.26)

- ([#399](https://github.com/ramsayleung/rspotify/pull/399)) Add a new variant `Collectionyourepisodes` for `Type` enum.
Expand Down
6 changes: 3 additions & 3 deletions src/clients/oauth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,19 +294,19 @@ pub trait OAuthClient: BaseClient {
/// Parameters:
/// - playlist_id - the id of the playlist
/// - track_ids - a list of track URIs, URLs or IDs
/// - position - the position to add the tracks
/// - position - the position to add the items, a zero-based index
///
/// [Reference](https://developer.spotify.com/documentation/web-api/reference/#/operations/add-tracks-to-playlist)
async fn playlist_add_items<'a>(
&self,
playlist_id: PlaylistId<'_>,
items: impl IntoIterator<Item = PlayableId<'a>> + Send + 'a,
position: Option<chrono::Duration>,
position: Option<u32>,
) -> ClientResult<PlaylistResult> {
let uris = items.into_iter().map(|id| id.uri()).collect::<Vec<_>>();
let params = JsonBuilder::new()
.required("uris", uris)
.optional("position", position.map(|p| p.num_milliseconds()))
.optional("position", position)
.build();

let url = format!("playlists/{}/tracks", playlist_id.id());
Expand Down