use serde::Serialize;
use crate::AnkiRequest;
use crate::entities::CardId;
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize)]
pub struct SetDueDateRequest {
pub cards: Vec<CardId>,
pub days: String,
}
impl AnkiRequest for SetDueDateRequest {
type Response = bool;
const ACTION: &'static str = "setDueDate";
const VERSION: u8 = 6;
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_serialize() {
let request = SetDueDateRequest {
cards: vec![1498938915662, 1502098034048],
days: "3-7".to_string(),
};
let json = serde_json::to_string_pretty(&request).unwrap();
assert_eq!(
json,
r#"{
"cards": [
1498938915662,
1502098034048
],
"days": "3-7"
}"#
);
}
#[test]
fn test_deserialize() {
let json = "true";
let response: <SetDueDateRequest as AnkiRequest>::Response =
serde_json::from_str(json).unwrap();
assert!(response);
}
}