Implement StatsUserRecordings
This commit is contained in:
		
							parent
							
								
									9c40b2522b
								
							
						
					
					
						commit
						59491fc56f
					
				| 
						 | 
				
			
			@ -211,7 +211,30 @@ impl Client {
 | 
			
		|||
        request.call()?.into_json().map_err(Error::ResponseJson)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // /// Endpoint: `stats/user/{user_name}/recordings`
 | 
			
		||||
    /// Endpoint: `stats/user/{user_name}/recordings`
 | 
			
		||||
    pub fn stats_user_recordings(
 | 
			
		||||
        &mut self,
 | 
			
		||||
        user_name: &str,
 | 
			
		||||
        count: Option<u64>,
 | 
			
		||||
        offset: Option<u64>,
 | 
			
		||||
        range: Option<&str>,
 | 
			
		||||
    ) -> Result<StatsUserRecordingsResponse, Error> {
 | 
			
		||||
        let endpoint = format!("{}{}", API_ROOT_URL, Endpoint::StatsUserRecordings(user_name));
 | 
			
		||||
 | 
			
		||||
        let mut request = self.agent.get(&endpoint);
 | 
			
		||||
 | 
			
		||||
        if let Some(count) = count {
 | 
			
		||||
            request = request.query("count", &count.to_string());
 | 
			
		||||
        }
 | 
			
		||||
        if let Some(offset) = offset {
 | 
			
		||||
            request = request.query("offset", &offset.to_string());
 | 
			
		||||
        }
 | 
			
		||||
        if let Some(range) = range {
 | 
			
		||||
            request = request.query("range", range);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        request.call()?.into_json().map_err(Error::ResponseJson)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // /// Endpoint: `stats/user/{user_name}/artist-map`
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,7 +12,7 @@ pub enum Endpoint<'a> {
 | 
			
		|||
    StatsSitewideArtists,
 | 
			
		||||
    StatsUserListeningActivity(&'a str),
 | 
			
		||||
    StatsUserDailyActivity(&'a str),
 | 
			
		||||
    // StatsUserRecordings(&'a str),
 | 
			
		||||
    StatsUserRecordings(&'a str),
 | 
			
		||||
    // StatsUserArtistMap(&'a str),
 | 
			
		||||
    // StatsUserReleases(&'a str),
 | 
			
		||||
    // StatsUserArtists(&'a str),
 | 
			
		||||
| 
						 | 
				
			
			@ -36,7 +36,7 @@ impl<'a> fmt::Display for Endpoint<'a> {
 | 
			
		|||
            Self::StatsSitewideArtists => "stats/sitewide/artists",
 | 
			
		||||
            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::StatsUserRecordings(user) => return write!(f, "stats/user/{}/recordings", 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),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -256,6 +256,7 @@ pub struct StatsUserDailyActivityPayload {
 | 
			
		|||
    pub daily_activity: StatsUserDailyActivityDailyActivity,
 | 
			
		||||
    pub from_ts: i64,
 | 
			
		||||
    pub to_ts: i64,
 | 
			
		||||
    pub last_updated: i64,
 | 
			
		||||
    pub stats_range: String,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -272,6 +273,42 @@ pub struct StatsUserDailyActivityHour {
 | 
			
		|||
    pub listen_count: u64,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// --------- stats/user/{user_name}/recordings
 | 
			
		||||
 | 
			
		||||
/// Response type of [`Client::stats_user_recordings`](crate::Client::stats_user_recordings).
 | 
			
		||||
#[derive(Debug, Deserialize)]
 | 
			
		||||
pub struct StatsUserRecordingsResponse {
 | 
			
		||||
    pub payload: StatsUserRecordingsPayload,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Type of the [`StatsUserRecordingsResponse::payload`] field.
 | 
			
		||||
#[derive(Debug, Deserialize)]
 | 
			
		||||
pub struct StatsUserRecordingsPayload {
 | 
			
		||||
    pub recordings: Vec<StatsUserRecordingsRecording>,
 | 
			
		||||
    pub count: u64,
 | 
			
		||||
    pub total_recording_count: u64,
 | 
			
		||||
    pub user_id: String,
 | 
			
		||||
    pub from_ts: i64,
 | 
			
		||||
    pub to_ts: i64,
 | 
			
		||||
    pub last_updated: i64,
 | 
			
		||||
    pub range: String,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Type of the [`StatsUserRecordingsPayload::recordings`] field.
 | 
			
		||||
#[derive(Debug, Deserialize)]
 | 
			
		||||
pub struct StatsUserRecordingsRecording {
 | 
			
		||||
    pub artist_mbids: Option<Vec<String>>,
 | 
			
		||||
    pub artist_msid: Option<String>,
 | 
			
		||||
    pub artist_name: String,
 | 
			
		||||
    pub listen_count: u64,
 | 
			
		||||
    pub recording_mbid: Option<String>,
 | 
			
		||||
    pub recording_msid: Option<String>,
 | 
			
		||||
    pub release_mbid: Option<String>,
 | 
			
		||||
    pub release_msid: Option<String>,
 | 
			
		||||
    pub release_name: Option<String>,
 | 
			
		||||
    pub track_name: Option<String>,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// --------- status/get-dump-info
 | 
			
		||||
 | 
			
		||||
/// Response type for [`Client::status_get_dump_info`](crate::Client::status_get_dump_info).
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue