diff --git a/CHANGELOG.md b/CHANGELOG.md index 8beb84ea..7626b219 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.14.0 (unreleased) +**Breaking changes** +- ([#487](https://github.com/ramsayleung/rspotify/pull/487)) Change the type of `TrackLink.id` from `TrackId<'static>` to `Option>` + ## 0.13.2 (2024.06.03) - ([#480](https://github.com/ramsayleung/rspotify/pull/480)) Fix deserialize empty images from null. diff --git a/rspotify-model/src/track.rs b/rspotify-model/src/track.rs index 5ad435be..2ca78eac 100644 --- a/rspotify-model/src/track.rs +++ b/rspotify-model/src/track.rs @@ -8,6 +8,7 @@ use std::collections::HashMap; use crate::{ custom_serde::duration_ms, PlayableId, Restriction, SimplifiedAlbum, SimplifiedArtist, TrackId, + Type, }; /// Full track object @@ -40,11 +41,14 @@ pub struct FullTrack { } /// Track link object +/// [track-relinking](https://developer.spotify.com/documentation/web-api/concepts/track-relinking) #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] pub struct TrackLink { pub external_urls: HashMap, pub href: String, - pub id: TrackId<'static>, + pub id: Option>, + pub r#type: Type, + pub uri: String, } /// Intermediate full track wrapped by `Vec` diff --git a/tests/test_models.rs b/tests/test_models.rs index 3135b69c..0d0d91e1 100644 --- a/tests/test_models.rs +++ b/tests/test_models.rs @@ -1204,3 +1204,22 @@ fn test_collectionyourepisodes_type() { let context: Context = deserialize(json); assert_eq!(context._type, Type::Collectionyourepisodes); } + +#[test] +#[wasm_bindgen_test] +fn test_null_id_in_tracklink() { + let json = r#" +{ + "external_urls": { + "spotify": "https://open.spotify.com/track/0tSkMuKKrLXEfxc58cEhFX" + }, + "href": "https://api.spotify.com/v1/tracks/0tSkMuKKrLXEfxc58cEhFX", + "id": null, + "type": "track", + "uri": "spotify:track:0tSkMuKKrLXEfxc58cEhFX" + } +"#; + let linked_from: TrackLink = deserialize(json); + assert!(linked_from.id.is_none()); + assert_eq!(linked_from.r#type, Type::Track); +}