From 6eefbc96d9861299a20d6401e34105ce17316f76 Mon Sep 17 00:00:00 2001 From: Koen Bolhuis Date: Thu, 14 Jan 2021 02:44:45 +0100 Subject: [PATCH] Fix request models --- src/models/request.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/models/request.rs b/src/models/request.rs index 4b8f5df..fbb691d 100644 --- a/src/models/request.rs +++ b/src/models/request.rs @@ -10,11 +10,12 @@ use serde::Serialize; #[derive(Debug, Serialize)] pub struct SubmitListens<'a> { pub listen_type: ListenType, - pub payload: Vec>, + pub payload: &'a[Payload<'a>], } /// Type of the [`SubmitListens::listen_type`] field. #[derive(Debug, Serialize)] +#[serde(rename_all = "snake_case")] pub enum ListenType { Single, PlayingNow, @@ -24,7 +25,8 @@ pub enum ListenType { /// Type of the [`SubmitListens::payload`] field. #[derive(Debug, Serialize)] pub struct Payload<'a> { - pub listened_at: i64, + #[serde(skip_serializing_if = "Option::is_none")] + pub listened_at: Option, pub track_metadata: TrackMetadata<'a>, } @@ -33,8 +35,12 @@ pub struct Payload<'a> { pub struct TrackMetadata<'a> { pub artist_name: &'a str, pub track_name: &'a str, + + #[serde(skip_serializing_if = "Option::is_none")] pub release_name: Option<&'a str>, - pub additional_info: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + pub additional_info: Option>, } // --------- delete-listen