io_msgraph/v1/rest/users/mail_folders/
update.rs1use alloc::format;
7
8use io_http::rfc6750::bearer::HttpAuthBearer;
9use log::{debug, trace};
10use url::Url;
11
12use crate::{
13 coroutine::*,
14 msgraph_try,
15 v1::{
16 rest::users::mail_folders::MsgraphMailFolder,
17 send::{MSGRAPH_API_BASE, MsgraphSend, MsgraphSendError, MsgraphSendOutput, user_path},
18 },
19};
20
21pub struct MsgraphMailFolderUpdate {
23 send: MsgraphSend<MsgraphMailFolder>,
24}
25
26impl MsgraphMailFolderUpdate {
27 pub fn new(
29 auth: &HttpAuthBearer,
30 user_id: &str,
31 id: &str,
32 folder: &MsgraphMailFolder,
33 ) -> Result<Self, MsgraphSendError> {
34 debug!("prepare microsoft graph mail folder update");
35 trace!("id: {id:?}");
36 trace!("folder: {folder:?}");
37
38 let user = user_path(user_id);
39 let url = Url::parse(MSGRAPH_API_BASE)?.join(&format!("{user}/mailFolders/{id}"))?;
40 let send = MsgraphSend::patch_json(auth, url, folder)?;
41
42 Ok(Self { send })
43 }
44}
45
46impl MsgraphCoroutine for MsgraphMailFolderUpdate {
47 type Yield = MsgraphYield;
48 type Return = Result<MsgraphSendOutput<MsgraphMailFolder>, MsgraphSendError>;
49
50 fn resume(&mut self, arg: Option<&[u8]>) -> MsgraphCoroutineState<Self::Yield, Self::Return> {
51 let out = msgraph_try!(&mut self.send, arg);
52 debug!("mail folder updated");
53 trace!("out: {out:?}");
54 MsgraphCoroutineState::Complete(Ok(out))
55 }
56}