io_msgraph/v1/rest/users/contact_folders/
get.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::contact_folders::MsgraphContactFolder,
17 send::{
18 MSGRAPH_API_BASE, MsgraphSend, MsgraphSendError, MsgraphSendOutput, path_segment,
19 user_path,
20 },
21 },
22};
23
24pub struct MsgraphContactFolderGet {
26 send: MsgraphSend<MsgraphContactFolder>,
27}
28
29impl MsgraphContactFolderGet {
30 pub fn new(auth: &HttpAuthBearer, user_id: &str, id: &str) -> Result<Self, MsgraphSendError> {
32 debug!("prepare microsoft graph contact folder retrieval");
33 trace!("id: {id:?}");
34
35 let user = user_path(user_id)?;
36 let url = Url::parse(MSGRAPH_API_BASE)?
37 .join(&format!("{user}/contactFolders/{}", path_segment(id)?))?;
38 let send = MsgraphSend::get(auth, url);
39
40 Ok(Self { send })
41 }
42}
43
44impl MsgraphCoroutine for MsgraphContactFolderGet {
45 type Yield = MsgraphYield;
46 type Return = Result<MsgraphSendOutput<MsgraphContactFolder>, MsgraphSendError>;
47
48 fn resume(&mut self, arg: Option<&[u8]>) -> MsgraphCoroutineState<Self::Yield, Self::Return> {
49 let out = msgraph_try!(&mut self.send, arg);
50 debug!("contact folder retrieved");
51 trace!("out: {out:?}");
52 MsgraphCoroutineState::Complete(Ok(out))
53 }
54}