1use serde::{Deserialize, Serialize};
2
3#[derive(Clone, Copy, Debug, PartialEq, Eq)]
6pub enum ListDirection {
7 Send,
9 Receive,
11 Reply,
13}
14
15impl ListDirection {
16 pub(crate) fn as_path(self) -> &'static str {
18 match self {
19 ListDirection::Send => "send",
20 ListDirection::Receive => "receive",
21 ListDirection::Reply => "reply",
22 }
23 }
24}
25
26#[derive(Clone, Copy, Debug, PartialEq, Eq)]
29pub enum ListKind {
30 Allow,
32 Block,
34}
35
36impl ListKind {
37 pub(crate) fn as_path(self) -> &'static str {
39 match self {
40 ListKind::Allow => "allow",
41 ListKind::Block => "block",
42 }
43 }
44}
45
46#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize)]
48#[serde(rename_all = "lowercase")]
49pub enum EntryType {
50 Email,
52 Domain,
54 #[serde(other)]
56 Unknown,
57}
58
59#[derive(Clone, Debug, Deserialize)]
61pub struct ListEntry {
62 pub entry: String,
64 #[serde(default)]
66 pub reason: Option<String>,
67 #[serde(default = "unknown_entry_type")]
69 pub entry_type: EntryType,
70 #[serde(default)]
72 pub organization_id: Option<String>,
73 #[serde(default)]
75 pub read_only: bool,
76 #[serde(default)]
78 pub created_at: Option<String>,
79}
80
81fn unknown_entry_type() -> EntryType {
82 EntryType::Unknown
83}
84
85#[derive(Clone, Debug, Default, Serialize)]
87pub struct CreateListEntry {
88 pub entry: String,
90 #[serde(skip_serializing_if = "Option::is_none")]
92 pub reason: Option<String>,
93}
94
95#[derive(Clone, Debug, Deserialize)]
97pub struct ListEntries {
98 pub count: u64,
100 #[serde(default)]
102 pub entries: Vec<ListEntry>,
103 #[serde(default)]
105 pub next_page_token: Option<String>,
106}