spotify_cli/endpoints/playlists/
get_current_user_playlists.rs

1/// Get a list of the current user's playlists.
2///
3/// See: https://developer.spotify.com/documentation/web-api/reference/get-a-list-of-current-users-playlists
4use crate::http::api::SpotifyApi;
5use crate::http::client::HttpError;
6use crate::http::endpoints::Endpoint;
7use serde_json::Value;
8
9pub async fn get_current_user_playlists(
10    client: &SpotifyApi,
11    limit: Option<u8>,
12    offset: Option<u32>,
13) -> Result<Option<Value>, HttpError> {
14    let limit = limit.unwrap_or(20).min(50);
15    let offset = offset.unwrap_or(0);
16
17    client
18        .get(&Endpoint::CurrentUserPlaylists { limit, offset }.path())
19        .await
20}