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