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::{
19 MSGRAPH_API_BASE, MsgraphSend, MsgraphSendError, MsgraphSendOutput, path_segment,
20 user_path,
21 },
22 },
23};
24
25pub struct MsgraphContactFolderUpdate {
27 send: MsgraphSend<MsgraphContactFolder>,
28}
29
30impl MsgraphContactFolderUpdate {
31 pub fn new(
34 auth: &HttpAuthBearer,
35 user_id: &str,
36 id: &str,
37 folder: &MsgraphContactFolder,
38 ) -> Result<Self, MsgraphSendError> {
39 debug!("prepare microsoft graph contact folder update");
40 trace!("id: {id:?}");
41 trace!("folder: {folder:?}");
42
43 let user = user_path(user_id)?;
44 let url = Url::parse(MSGRAPH_API_BASE)?
45 .join(&format!("{user}/contactFolders/{}", path_segment(id)?))?;
46 let send = MsgraphSend::patch_json(auth, url, folder)?;
47
48 Ok(Self { send })
49 }
50}
51
52impl MsgraphCoroutine for MsgraphContactFolderUpdate {
53 type Yield = MsgraphYield;
54 type Return = Result<MsgraphSendOutput<MsgraphContactFolder>, MsgraphSendError>;
55
56 fn resume(&mut self, arg: Option<&[u8]>) -> MsgraphCoroutineState<Self::Yield, Self::Return> {
57 let out = msgraph_try!(&mut self.send, arg);
58 debug!("contact folder updated");
59 trace!("out: {out:?}");
60 MsgraphCoroutineState::Complete(Ok(out))
61 }
62}