io_gmail/v1/rest/settings/send_as/
delete.rs1use alloc::format;
6
7use io_http::rfc6750::bearer::HttpAuthBearer;
8use log::{debug, trace};
9use url::Url;
10
11use crate::{
12 coroutine::*,
13 gmail_try,
14 v1::send::{GMAIL_API_BASE, GmailNoResponse, GmailSend, GmailSendError, GmailSendOutput},
15};
16
17pub struct GmailSendAsDelete {
20 send: GmailSend<GmailNoResponse>,
21}
22
23impl GmailSendAsDelete {
24 pub fn new(
26 auth: &HttpAuthBearer,
27 user_id: &str,
28 send_as_email: &str,
29 ) -> Result<Self, GmailSendError> {
30 debug!("prepare gmail send-as alias deletion");
31 trace!("send_as_email: {send_as_email:?}");
32
33 let url = Url::parse(GMAIL_API_BASE)?
34 .join(&format!("users/{user_id}/settings/sendAs/{send_as_email}"))?;
35 let send = GmailSend::delete(auth, url);
36
37 Ok(Self { send })
38 }
39}
40
41impl GmailCoroutine for GmailSendAsDelete {
42 type Yield = GmailYield;
43 type Return = Result<GmailSendOutput<GmailNoResponse>, GmailSendError>;
44
45 fn resume(&mut self, arg: Option<&[u8]>) -> GmailCoroutineState<Self::Yield, Self::Return> {
46 let out = gmail_try!(&mut self.send, arg);
47 debug!("send-as alias deleted");
48 trace!("out: {out:?}");
49 GmailCoroutineState::Complete(Ok(out))
50 }
51}