spotify_cli/endpoints/playlists/
create_playlist.rs1use crate::http::api::SpotifyApi;
5use crate::http::client::HttpError;
6use crate::http::endpoints::Endpoint;
7use serde_json::Value;
8
9pub async fn create_playlist(
10 client: &SpotifyApi,
11 user_id: &str,
12 name: &str,
13 description: Option<&str>,
14 public: bool,
15) -> Result<Option<Value>, HttpError> {
16 let mut body = serde_json::json!({
17 "name": name,
18 "public": public
19 });
20
21 if let Some(desc) = description {
22 body["description"] = serde_json::Value::String(desc.to_string());
23 }
24
25 client
26 .post_json(&Endpoint::UserPlaylists { user_id }.path(), &body)
27 .await
28}