agentmail/client/
inboxes.rs1use crate::client::NoBody;
2use crate::{Client, Error, Page, types::*, util::urlish};
3
4impl Client {
5 pub async fn create_inbox(&self, inbox: CreateInbox) -> Result<Inbox, Error> {
8 self.request(reqwest::Method::POST, "/v0/inboxes", &[], Some(&inbox))
9 .await
10 }
11
12 pub async fn list_inboxes(&self) -> Result<InboxList, Error> {
14 self.list_inboxes_page(Page::default()).await
15 }
16
17 pub async fn list_inboxes_page(&self, page: Page) -> Result<InboxList, Error> {
20 self.request(
21 reqwest::Method::GET,
22 "/v0/inboxes",
23 &page.query(),
24 None::<&NoBody>,
25 )
26 .await
27 }
28
29 pub async fn get_inbox(&self, inbox_id: &str) -> Result<Inbox, Error> {
31 self.request(
32 reqwest::Method::GET,
33 &format!("/v0/inboxes/{}", urlish(inbox_id)),
34 &[],
35 None::<&NoBody>,
36 )
37 .await
38 }
39
40 pub async fn update_inbox(&self, inbox_id: &str, update: UpdateInbox) -> Result<Inbox, Error> {
42 self.request(
43 reqwest::Method::PATCH,
44 &format!("/v0/inboxes/{}", urlish(inbox_id)),
45 &[],
46 Some(&update),
47 )
48 .await
49 }
50
51 pub async fn delete_inbox(&self, inbox_id: &str) -> Result<(), Error> {
53 self.request(
54 reqwest::Method::DELETE,
55 &format!("/v0/inboxes/{}", urlish(inbox_id)),
56 &[],
57 None::<&NoBody>,
58 )
59 .await
60 }
61}