spotify_cli/endpoints/user/
get_users_top_items.rs

1use crate::http::api::SpotifyApi;
2use crate::http::client::HttpError;
3use crate::http::endpoints::Endpoint;
4use serde_json::Value;
5
6/// Get the current user's top artists or tracks
7/// item_type: "artists" or "tracks"
8/// time_range: "short_term" (4 weeks), "medium_term" (6 months), "long_term" (years)
9pub async fn get_users_top_items(
10    client: &SpotifyApi,
11    item_type: &str,
12    time_range: Option<&str>,
13    limit: Option<u8>,
14    offset: Option<u32>,
15) -> Result<Option<Value>, HttpError> {
16    let time_range = time_range.unwrap_or("medium_term");
17    let limit = limit.unwrap_or(20);
18    let offset = offset.unwrap_or(0);
19
20    client
21        .get(
22            &Endpoint::UserTopItems {
23                item_type,
24                time_range,
25                limit,
26                offset,
27            }
28            .path(),
29        )
30        .await
31}