2021-01-10 19:48:54 +00:00
|
|
|
//! Low-level request data models.
|
|
|
|
|
2021-01-09 03:36:14 +00:00
|
|
|
use std::collections::HashMap;
|
|
|
|
|
|
|
|
use serde::Serialize;
|
|
|
|
|
|
|
|
// --------- submit-listens
|
|
|
|
|
2021-01-19 22:45:43 +00:00
|
|
|
/// Request type for [`Client::submit_listens`](super::Client::submit_listens).
|
2021-01-09 03:36:14 +00:00
|
|
|
#[derive(Debug, Serialize)]
|
2021-01-09 16:03:03 +00:00
|
|
|
pub struct SubmitListens<'a> {
|
2021-01-09 03:36:14 +00:00
|
|
|
pub listen_type: ListenType,
|
2021-01-14 02:29:21 +00:00
|
|
|
pub payload: &'a [Payload<'a>],
|
2021-01-09 03:36:14 +00:00
|
|
|
}
|
|
|
|
|
2021-01-10 19:48:54 +00:00
|
|
|
/// Type of the [`SubmitListens::listen_type`] field.
|
2021-01-09 03:36:14 +00:00
|
|
|
#[derive(Debug, Serialize)]
|
2021-01-14 01:44:45 +00:00
|
|
|
#[serde(rename_all = "snake_case")]
|
2021-01-09 03:36:14 +00:00
|
|
|
pub enum ListenType {
|
|
|
|
Single,
|
|
|
|
PlayingNow,
|
|
|
|
Import,
|
|
|
|
}
|
|
|
|
|
2021-01-10 19:48:54 +00:00
|
|
|
/// Type of the [`SubmitListens::payload`] field.
|
2021-01-09 03:36:14 +00:00
|
|
|
#[derive(Debug, Serialize)]
|
|
|
|
pub struct Payload<'a> {
|
2021-01-14 01:44:45 +00:00
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
|
|
pub listened_at: Option<i64>,
|
2021-01-10 16:59:15 +00:00
|
|
|
pub track_metadata: TrackMetadata<'a>,
|
2021-01-09 03:36:14 +00:00
|
|
|
}
|
|
|
|
|
2021-01-10 19:48:54 +00:00
|
|
|
/// Type of the [`Payload::track_metadata`] field.
|
2021-01-09 03:36:14 +00:00
|
|
|
#[derive(Debug, Serialize)]
|
|
|
|
pub struct TrackMetadata<'a> {
|
|
|
|
pub artist_name: &'a str,
|
|
|
|
pub track_name: &'a str,
|
2021-01-14 01:44:45 +00:00
|
|
|
|
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
2021-01-09 03:36:14 +00:00
|
|
|
pub release_name: Option<&'a str>,
|
2021-01-14 01:44:45 +00:00
|
|
|
|
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
|
|
pub additional_info: Option<HashMap<&'a str, serde_json::Value>>,
|
2021-01-09 03:36:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// --------- delete-listen
|
|
|
|
|
2021-01-19 22:45:43 +00:00
|
|
|
/// Request type for [`Client::delete_listen`](super::Client::delete_listen).
|
2021-01-09 03:36:14 +00:00
|
|
|
#[derive(Debug, Serialize)]
|
|
|
|
pub struct DeleteListen<'a> {
|
|
|
|
pub listened_at: i64,
|
|
|
|
pub recording_msid: &'a str,
|
|
|
|
}
|
2021-01-10 16:59:15 +00:00
|
|
|
|
|
|
|
// --------- latest-import (POST)
|
|
|
|
|
2021-01-19 22:45:43 +00:00
|
|
|
/// Request type for [`Client::update_latest_import`](super::Client::update_latest_import).
|
2021-01-10 16:59:15 +00:00
|
|
|
#[derive(Debug, Serialize)]
|
|
|
|
pub struct UpdateLatestImport {
|
|
|
|
pub ts: i64,
|
|
|
|
}
|