Implement StatsUserArtistMap
This commit is contained in:
parent
59491fc56f
commit
bd263af244
|
@ -236,7 +236,26 @@ impl Client {
|
|||
request.call()?.into_json().map_err(Error::ResponseJson)
|
||||
}
|
||||
|
||||
// /// Endpoint: `stats/user/{user_name}/artist-map`
|
||||
/// Endpoint: `stats/user/{user_name}/artist-map`
|
||||
pub fn stats_user_artist_map(
|
||||
&mut self,
|
||||
user_name: &str,
|
||||
range: Option<&str>,
|
||||
force_recalculate: Option<bool>,
|
||||
) -> Result<StatsUserArtistMapResponse, Error> {
|
||||
let endpoint = format!("{}{}", API_ROOT_URL, Endpoint::StatsUserArtistMap(user_name));
|
||||
|
||||
let mut request = self.agent.get(&endpoint);
|
||||
|
||||
if let Some(range) = range {
|
||||
request = request.query("range", range);
|
||||
}
|
||||
if let Some(force_recalculate) = force_recalculate {
|
||||
request = request.query("force_recalculate", &force_recalculate.to_string());
|
||||
}
|
||||
|
||||
request.call()?.into_json().map_err(Error::ResponseJson)
|
||||
}
|
||||
|
||||
// /// Endpoint: `stats/user/{user_name}/releases`
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ pub enum Endpoint<'a> {
|
|||
StatsUserListeningActivity(&'a str),
|
||||
StatsUserDailyActivity(&'a str),
|
||||
StatsUserRecordings(&'a str),
|
||||
// StatsUserArtistMap(&'a str),
|
||||
StatsUserArtistMap(&'a str),
|
||||
// StatsUserReleases(&'a str),
|
||||
// StatsUserArtists(&'a str),
|
||||
StatusGetDumpInfo,
|
||||
|
@ -37,7 +37,7 @@ impl<'a> fmt::Display for Endpoint<'a> {
|
|||
Self::StatsUserListeningActivity(user) => return write!(f, "stats/user/{}/listening-activity", user),
|
||||
Self::StatsUserDailyActivity(user) => return write!(f, "stats/user/{}/daily-activity", user),
|
||||
Self::StatsUserRecordings(user) => return write!(f, "stats/user/{}/recordings", user),
|
||||
// Self::StatsUserArtistMap(user) => return write!(f, "stats/user/{}/artist-map", user),
|
||||
Self::StatsUserArtistMap(user) => return write!(f, "stats/user/{}/artist-map", user),
|
||||
// Self::StatsUserReleases(user) => return write!(f, "stats/user/{}/releases", user),
|
||||
// Self::StatsUserArtists(user) => return write!(f, "stats/user/{}/artists", user),
|
||||
Self::StatusGetDumpInfo => "status/get-dump-info",
|
||||
|
|
|
@ -309,6 +309,32 @@ pub struct StatsUserRecordingsRecording {
|
|||
pub track_name: Option<String>,
|
||||
}
|
||||
|
||||
// --------- stats/user/{user_name}/artist-map
|
||||
|
||||
/// Response type of [`Client::stats_user_artist_map`](crate::Client::stats_user_artist_map).
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct StatsUserArtistMapResponse {
|
||||
pub payload: StatsUserArtistMapPayload,
|
||||
}
|
||||
|
||||
/// Type of the [`StatsUserArtistMapResponse::payload`] field.
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct StatsUserArtistMapPayload {
|
||||
pub artist_map: Vec<StatsUserArtistMapCountry>,
|
||||
pub user_id: String,
|
||||
pub from_ts: i64,
|
||||
pub to_ts: i64,
|
||||
pub last_updated: i64,
|
||||
pub range: String,
|
||||
}
|
||||
|
||||
/// Type of the [`StatsUserArtistMapPayload::artist_map`] field.
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct StatsUserArtistMapCountry {
|
||||
pub country: String,
|
||||
pub artist_count: u64,
|
||||
}
|
||||
|
||||
// --------- status/get-dump-info
|
||||
|
||||
/// Response type for [`Client::status_get_dump_info`](crate::Client::status_get_dump_info).
|
||||
|
|
Loading…
Reference in New Issue