listenbrainz-rs/src/models/request.rs

56 lines
1.3 KiB
Rust
Raw Normal View History

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-10 19:48:54 +00:00
/// Request type for [`Client::submit_listens`](crate::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,
pub payload: Vec<Payload<'a>>,
}
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)]
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> {
pub listened_at: i64,
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,
pub release_name: Option<&'a str>,
pub additional_info: Option<HashMap<&'a str, &'a str>>,
}
// --------- delete-listen
2021-01-10 19:48:54 +00:00
/// Request type for [`Client::delete_listen`](crate::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,
}
// --------- latest-import (POST)
2021-01-10 19:48:54 +00:00
/// Request type for [`Client::update_latest_import`](crate::Client::update_latest_import).
#[derive(Debug, Serialize)]
pub struct UpdateLatestImport {
pub ts: i64,
}