Skip to main content

agentmail/types/
drafts.rs

1use super::{Attachment, SendAttachment};
2use serde::{Deserialize, Serialize};
3
4/// Request body for `create_draft`. At least one recipient or a
5/// reply/forward-of reference and one of `text`/`html` are required by the
6/// API.
7#[derive(Clone, Debug, Default, Serialize)]
8pub struct CreateDraft {
9    /// Primary recipients.
10    #[serde(skip_serializing_if = "Vec::is_empty")]
11    pub to: Vec<String>,
12    /// Carbon-copy recipients.
13    #[serde(skip_serializing_if = "Vec::is_empty")]
14    pub cc: Vec<String>,
15    /// Blind-carbon-copy recipients.
16    #[serde(skip_serializing_if = "Vec::is_empty")]
17    pub bcc: Vec<String>,
18    /// Subject line.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub subject: Option<String>,
21    /// Plain-text body.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub text: Option<String>,
24    /// HTML body.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub html: Option<String>,
27    /// Message id this draft is in reply to.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub in_reply_to: Option<String>,
30    /// Reply-To addresses to set on the sent message.
31    #[serde(skip_serializing_if = "Vec::is_empty")]
32    pub reply_to: Vec<String>,
33    /// When creating a reply draft, set true to reply to all recipients of
34    /// the referenced message.
35    #[serde(skip_serializing_if = "Option::is_none")]
36    pub reply_all: Option<bool>,
37    /// Message id this draft is a forward of.
38    #[serde(skip_serializing_if = "Option::is_none")]
39    pub forward_of: Option<String>,
40    /// Labels to attach to the draft.
41    #[serde(skip_serializing_if = "Vec::is_empty")]
42    pub labels: Vec<String>,
43    /// Schedule send at this RFC 3339 timestamp.
44    #[serde(skip_serializing_if = "Option::is_none")]
45    pub send_at: Option<String>,
46    /// Your own idempotency/reference id for this draft.
47    #[serde(skip_serializing_if = "Option::is_none")]
48    pub client_id: Option<String>,
49}
50/// Request body for `update_draft`. Every field is optional;
51/// omitted fields are left unchanged on the server. Pass `Some(vec![])`
52/// to clear a recipient field; pass `None` to leave it alone.
53#[derive(Clone, Debug, Default, Serialize)]
54pub struct UpdateDraft {
55    /// Primary recipients.
56    #[serde(skip_serializing_if = "Option::is_none")]
57    pub to: Option<Vec<String>>,
58    /// Carbon-copy recipients.
59    #[serde(skip_serializing_if = "Option::is_none")]
60    pub cc: Option<Vec<String>>,
61    /// Blind-carbon-copy recipients.
62    #[serde(skip_serializing_if = "Option::is_none")]
63    pub bcc: Option<Vec<String>>,
64    /// Subject line.
65    #[serde(skip_serializing_if = "Option::is_none")]
66    pub subject: Option<String>,
67    /// Plain-text body.
68    #[serde(skip_serializing_if = "Option::is_none")]
69    pub text: Option<String>,
70    /// HTML body.
71    #[serde(skip_serializing_if = "Option::is_none")]
72    pub html: Option<String>,
73    /// Labels to add.
74    #[serde(skip_serializing_if = "Option::is_none")]
75    pub add_labels: Option<Vec<String>>,
76    /// Labels to remove.
77    #[serde(skip_serializing_if = "Option::is_none")]
78    pub remove_labels: Option<Vec<String>>,
79    /// Reply-To addresses to replace; `Some(vec![])` clears them.
80    #[serde(skip_serializing_if = "Option::is_none")]
81    pub reply_to: Option<Vec<String>>,
82    /// Attachments to add to the draft.
83    #[serde(skip_serializing_if = "Vec::is_empty")]
84    pub add_attachments: Vec<SendAttachment>,
85    /// Attachment ids to remove from the draft.
86    #[serde(skip_serializing_if = "Vec::is_empty")]
87    pub remove_attachments: Vec<String>,
88    /// Schedule send at this RFC 3339 timestamp.
89    #[serde(skip_serializing_if = "Option::is_none")]
90    pub send_at: Option<String>,
91}
92/// A draft message, as the API returns it. List items are a subset of the
93/// full get-draft shape; every optional field defaults so both parse.
94#[derive(Clone, Debug, Deserialize)]
95pub struct Draft {
96    /// Unique draft id.
97    pub draft_id: String,
98    /// Inbox the draft belongs to.
99    #[serde(default)]
100    pub inbox_id: Option<String>,
101    /// Your reference id from creation, when set.
102    #[serde(default)]
103    pub client_id: Option<String>,
104    /// Primary recipients.
105    #[serde(default)]
106    pub to: Vec<String>,
107    /// Carbon-copy recipients.
108    #[serde(default)]
109    pub cc: Vec<String>,
110    /// Blind-carbon-copy recipients.
111    #[serde(default)]
112    pub bcc: Vec<String>,
113    /// Reply-To addresses, when set.
114    #[serde(default)]
115    pub reply_to: Vec<String>,
116    /// Subject line.
117    #[serde(default)]
118    pub subject: Option<String>,
119    /// Short plain-text excerpt (list responses).
120    #[serde(default)]
121    pub preview: Option<String>,
122    /// Plain-text body.
123    #[serde(default)]
124    pub text: Option<String>,
125    /// HTML body.
126    #[serde(default)]
127    pub html: Option<String>,
128    /// Labels on the draft.
129    #[serde(default)]
130    pub labels: Vec<String>,
131    /// Message id this draft is replying to.
132    #[serde(default)]
133    pub in_reply_to: Option<String>,
134    /// Message id this draft is forwarding.
135    #[serde(default)]
136    pub forward_of: Option<String>,
137    /// `References` chain this draft continues, when replying.
138    #[serde(default)]
139    pub references: Vec<String>,
140    /// Send state once the draft is queued: `scheduled`, `sending`, or `failed`.
141    #[serde(default)]
142    pub send_status: Option<String>,
143    /// Scheduled send time (RFC 3339).
144    #[serde(default)]
145    pub send_at: Option<String>,
146    /// Timestamp the draft was created (RFC 3339).
147    #[serde(default)]
148    pub created_at: Option<String>,
149    /// Timestamp the draft was last updated (RFC 3339).
150    #[serde(default)]
151    pub updated_at: Option<String>,
152    /// Attachments on the draft.
153    #[serde(default)]
154    pub attachments: Vec<Attachment>,
155}
156/// One page of drafts from `list_drafts_page`.
157#[derive(Clone, Debug, Deserialize)]
158pub struct DraftList {
159    /// Total drafts in the inbox (not just this page).
160    pub count: u64,
161    /// This page of drafts.
162    #[serde(default)]
163    pub drafts: Vec<Draft>,
164    /// Cursor for the next page; `None` on the last page.
165    #[serde(default)]
166    pub next_page_token: Option<String>,
167}