listenbrainz-rs/src/models/response.rs

178 lines
4.5 KiB
Rust
Raw Normal View History

2021-01-10 19:48:54 +00:00
//! Low-level response data models.
use std::collections::HashMap;
2021-01-09 03:36:14 +00:00
use serde::Deserialize;
#[derive(Debug, Deserialize)]
pub struct ApiResponse {
code: u16,
message: String,
}
// --------- submit-listens
2021-01-10 19:48:54 +00:00
/// Response type for [`Client::submit_listens`](crate::Client::submit_listens).
2021-01-09 03:36:14 +00:00
#[derive(Debug, Deserialize)]
pub struct SubmitListensResponse {
#[serde(flatten)]
pub api_response: ApiResponse,
}
// --------- validate-token
2021-01-10 19:48:54 +00:00
/// Response type for [`Client::validate_token`](crate::Client::validate_token).
2021-01-09 03:36:14 +00:00
#[derive(Debug, Deserialize)]
pub struct ValidateTokenResponse {
#[serde(flatten)]
pub api_response: ApiResponse,
pub valid: bool,
pub user_name: Option<String>,
}
// --------- delete-listen
2021-01-10 19:48:54 +00:00
/// Response type for [`Client::delete_listen`](crate::Client::delete_listen).
2021-01-09 03:36:14 +00:00
#[derive(Debug, Deserialize)]
pub struct DeleteListenResponse {
#[serde(flatten)]
pub api_response: ApiResponse,
}
// --------- users/{user_list}/recent-listens
2021-01-10 19:48:54 +00:00
/// Response type for [`Client::users_recent_listens`](crate::Client::users_recent_listens).
#[derive(Debug, Deserialize)]
pub struct UsersRecentListensResponse {
pub payload: UsersRecentListensPayload,
}
#[derive(Debug, Deserialize)]
pub struct UsersRecentListensPayload {
pub count: u64,
pub listens: Vec<UsersRecentListensListen>,
pub user_list: String,
}
#[derive(Debug, Deserialize)]
pub struct UsersRecentListensListen {
pub user_name: String,
pub inserted_at: String,
pub listened_at: i64,
pub recording_msid: String,
pub track_metadata: UsersRecentListensTrackMetadata,
}
#[derive(Debug, Deserialize)]
pub struct UsersRecentListensTrackMetadata {
pub artist_name: String,
pub track_name: String,
pub release_name: Option<String>,
pub additional_info: HashMap<String, serde_json::Value>,
}
2021-01-09 03:36:14 +00:00
// --------- user/{user_name}/listen-count
2021-01-10 19:48:54 +00:00
/// Response type for [`Client::user_listen_count`](crate::Client::user_listen_count).
2021-01-09 03:36:14 +00:00
#[derive(Debug, Deserialize)]
pub struct UserListenCountResponse {
#[serde(flatten)]
pub api_response: ApiResponse,
pub count: u64,
}
// -------- user/{user_name}/playing-now
2021-01-10 19:48:54 +00:00
/// Response type for [`Client::user_playing_now`](crate::Client::user_playing_now).
#[derive(Debug, Deserialize)]
pub struct UserPlayingNowResponse {
pub payload: UserPlayingNowPayload,
}
#[derive(Debug, Deserialize)]
pub struct UserPlayingNowPayload {
pub count: u8,
pub user_id: String,
2021-01-10 18:31:06 +00:00
pub listens: Vec<UserPlayingNowListen>,
}
#[derive(Debug, Deserialize)]
pub struct UserPlayingNowListen {
pub user_name: String,
pub inserted_at: String,
pub recording_msid: String,
pub track_metadata: UserPlayingNowTrackMetadata,
}
#[derive(Debug, Deserialize)]
pub struct UserPlayingNowTrackMetadata {
pub artist_name: String,
pub track_name: String,
pub release_name: Option<String>,
pub additional_info: HashMap<String, serde_json::Value>,
}
// -------- user/{user_name}/listens
2021-01-10 19:48:54 +00:00
/// Response type for [`Client::user_listens`](crate::Client::user_listens).
#[derive(Debug, Deserialize)]
pub struct UserListensResponse {
pub payload: UserListensPayload,
}
#[derive(Debug, Deserialize)]
pub struct UserListensPayload {
pub count: u64,
pub latest_listen_ts: i64,
pub user_id: String,
pub listens: Vec<UserListensListen>,
}
#[derive(Debug, Deserialize)]
pub struct UserListensListen {
pub user_name: String,
pub inserted_at: String,
pub listened_at: i64,
pub recording_msid: String,
pub track_metadata: UserListensTrackMetadata,
}
#[derive(Debug, Deserialize)]
pub struct UserListensTrackMetadata {
pub artist_name: String,
pub track_name: String,
pub release_name: Option<String>,
pub additional_info: HashMap<String, serde_json::Value>,
}
// --------- latest-import (GET)
2021-01-10 19:48:54 +00:00
/// Response type for [`Client::get_latest_import`](crate::Client::get_latest_import).
#[derive(Debug, Deserialize)]
pub struct GetLatestImportResponse {
pub latest_import: i64,
pub musicbrainz_id: String,
}
// --------- latest-import (POST)
2021-01-10 19:48:54 +00:00
/// Response type for [`Client::update_latest_import`](crate::Client::update_latest_import).
#[derive(Debug, Deserialize)]
pub struct UpdateLatestImportResponse {
pub status: String,
}
2021-01-09 03:36:14 +00:00
// --------- status/get-dump-info
2021-01-10 19:48:54 +00:00
/// Response type for [`Client::status_get_dump_info`](crate::Client::status_get_dump_info).
2021-01-09 03:36:14 +00:00
#[derive(Debug, Deserialize)]
pub struct StatusGetDumpInfoResponse {
#[serde(flatten)]
pub api_response: ApiResponse,
pub id: i64,
pub timestamp: String,
}