io_gmail/v1/rest/settings/send_as/
verify.rs1use alloc::{format, vec::Vec};
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 GmailSendAsVerify {
20 send: GmailSend<GmailNoResponse>,
21}
22
23impl GmailSendAsVerify {
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 verification");
31 trace!("send_as_email: {send_as_email:?}");
32
33 let url = Url::parse(GMAIL_API_BASE)?.join(&format!(
34 "users/{user_id}/settings/sendAs/{send_as_email}/verify"
35 ))?;
36 let send = GmailSend::with_method(auth, "POST", url, None, Vec::new());
37
38 Ok(Self { send })
39 }
40}
41
42impl GmailCoroutine for GmailSendAsVerify {
43 type Yield = GmailYield;
44 type Return = Result<GmailSendOutput<GmailNoResponse>, GmailSendError>;
45
46 fn resume(&mut self, arg: Option<&[u8]>) -> GmailCoroutineState<Self::Yield, Self::Return> {
47 let out = gmail_try!(&mut self.send, arg);
48 debug!("send-as alias verification requested");
49 trace!("out: {out:?}");
50 GmailCoroutineState::Complete(Ok(out))
51 }
52}