170 lines
3.7 KiB
Rust
170 lines
3.7 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum Section {
|
|
Morning,
|
|
Work,
|
|
Evening,
|
|
}
|
|
|
|
impl Section {
|
|
pub fn as_str(&self) -> &'static str {
|
|
match self {
|
|
Self::Morning => "morning",
|
|
Self::Work => "work",
|
|
Self::Evening => "evening",
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum Priority {
|
|
Must,
|
|
Should,
|
|
Optional,
|
|
}
|
|
|
|
impl Priority {
|
|
pub fn as_str(&self) -> &'static str {
|
|
match self {
|
|
Self::Must => "must",
|
|
Self::Should => "should",
|
|
Self::Optional => "optional",
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
|
#[serde(tag = "kind", rename_all = "snake_case")]
|
|
pub enum Schedule {
|
|
Daily,
|
|
Weekly {
|
|
/// ISO weekday numbers: Monday = 1, Sunday = 7.
|
|
weekdays: Vec<u32>,
|
|
},
|
|
Monthly {
|
|
days: Vec<u32>,
|
|
#[serde(default = "default_true")]
|
|
clamp_to_last_day: bool,
|
|
},
|
|
}
|
|
|
|
fn default_true() -> bool {
|
|
true
|
|
}
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
pub struct CreateTask {
|
|
pub public_title: String,
|
|
#[serde(default)]
|
|
pub encrypted_payload: Option<String>,
|
|
#[serde(default)]
|
|
pub encryption_version: Option<i16>,
|
|
#[serde(default)]
|
|
pub content_id: Option<String>,
|
|
pub section: Section,
|
|
pub priority: Priority,
|
|
pub scheduled_date: String,
|
|
#[serde(default)]
|
|
pub reminder_time: Option<String>,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
pub struct RescheduleTask {
|
|
pub scheduled_date: String,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize)]
|
|
pub struct Task {
|
|
pub id: i64,
|
|
pub routine_id: Option<i64>,
|
|
pub public_title: String,
|
|
pub encrypted_payload: Option<String>,
|
|
pub encryption_version: Option<i16>,
|
|
pub content_id: Option<String>,
|
|
pub section: String,
|
|
pub priority: String,
|
|
pub scheduled_date: String,
|
|
pub reminder_time: Option<String>,
|
|
pub status: String,
|
|
pub completed_at: Option<i64>,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
pub struct CreateRoutine {
|
|
pub public_title: String,
|
|
#[serde(default)]
|
|
pub encrypted_payload: Option<String>,
|
|
#[serde(default)]
|
|
pub encryption_version: Option<i16>,
|
|
#[serde(default)]
|
|
pub content_id: Option<String>,
|
|
pub section: Section,
|
|
pub priority: Priority,
|
|
pub schedule: Schedule,
|
|
#[serde(default)]
|
|
pub reminder_time: Option<String>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize)]
|
|
pub struct Routine {
|
|
pub id: i64,
|
|
pub public_title: String,
|
|
pub encrypted_payload: Option<String>,
|
|
pub encryption_version: Option<i16>,
|
|
pub content_id: Option<String>,
|
|
pub section: String,
|
|
pub priority: String,
|
|
pub schedule: Schedule,
|
|
pub reminder_time: Option<String>,
|
|
pub enabled: bool,
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct DueNotification {
|
|
pub task_id: i64,
|
|
pub public_title: String,
|
|
pub section: String,
|
|
pub priority: String,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
pub struct CreateEncryptionDevice {
|
|
pub name: String,
|
|
pub age_recipient: String,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize)]
|
|
pub struct EncryptionDevice {
|
|
pub id: i64,
|
|
pub name: String,
|
|
pub age_recipient: String,
|
|
pub status: String,
|
|
pub created_at: i64,
|
|
pub revoked_at: Option<i64>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize)]
|
|
pub struct EncryptionRecipient {
|
|
pub id: i64,
|
|
pub name: String,
|
|
pub age_recipient: String,
|
|
}
|
|
|
|
#[derive(Debug, Serialize)]
|
|
pub struct IdResponse {
|
|
pub id: i64,
|
|
}
|
|
|
|
#[derive(Debug, Serialize)]
|
|
pub struct StatusResponse {
|
|
pub status: &'static str,
|
|
}
|
|
|
|
#[derive(Debug, Serialize)]
|
|
pub struct ErrorResponse<'a> {
|
|
pub error: &'a str,
|
|
}
|