use crate::http::api::SpotifyApi;
use crate::http::client::HttpError;
use crate::http::endpoints::Endpoint;
use serde_json::Value;
pub async fn reorder_playlist_items(
client: &SpotifyApi,
playlist_id: &str,
range_start: u32,
insert_before: u32,
range_length: Option<u32>,
) -> Result<Option<Value>, HttpError> {
let mut body = serde_json::json!({
"range_start": range_start,
"insert_before": insert_before,
});
if let Some(len) = range_length {
body["range_length"] = serde_json::Value::Number(len.into());
}
client
.put_json(&Endpoint::PlaylistTracks { id: playlist_id }.path(), &body)
.await
}