io_msgraph/v1/rest/users/contact_folders/
list.rs1use alloc::format;
7
8use io_http::rfc6750::bearer::HttpAuthBearer;
9use log::{debug, trace};
10use serde::Serialize;
11use url::Url;
12
13use crate::{
14 coroutine::*,
15 msgraph_try,
16 v1::{
17 query::to_query_pairs,
18 rest::users::contact_folders::MsgraphContactFoldersListResponse,
19 send::{MSGRAPH_API_BASE, MsgraphSend, MsgraphSendError, MsgraphSendOutput, user_path},
20 },
21};
22
23#[derive(Debug, Clone, Default, Serialize, Eq, PartialEq)]
25pub struct MsgraphContactFoldersListParams<'a> {
26 #[serde(rename = "$top")]
28 pub top: Option<u32>,
29 #[serde(rename = "$skip")]
31 pub skip: Option<u32>,
32 #[serde(rename = "$select")]
34 pub select: Option<&'a str>,
35}
36
37pub struct MsgraphContactFoldersList {
39 send: MsgraphSend<MsgraphContactFoldersListResponse>,
40}
41
42impl MsgraphContactFoldersList {
43 pub fn new(
46 auth: &HttpAuthBearer,
47 user_id: &str,
48 params: &MsgraphContactFoldersListParams,
49 ) -> Result<Self, MsgraphSendError> {
50 debug!("prepare microsoft graph contact folders listing");
51 trace!("params: {params:?}");
52
53 let user = user_path(user_id);
54 let mut url = Url::parse(MSGRAPH_API_BASE)?.join(&format!("{user}/contactFolders"))?;
55 url.query_pairs_mut().extend_pairs(to_query_pairs(params));
56
57 let send = MsgraphSend::get(auth, url);
58
59 Ok(Self { send })
60 }
61}
62
63impl MsgraphCoroutine for MsgraphContactFoldersList {
64 type Yield = MsgraphYield;
65 type Return = Result<MsgraphSendOutput<MsgraphContactFoldersListResponse>, MsgraphSendError>;
66
67 fn resume(&mut self, arg: Option<&[u8]>) -> MsgraphCoroutineState<Self::Yield, Self::Return> {
68 let out = msgraph_try!(&mut self.send, arg);
69 debug!("contact folders listed");
70 trace!("out: {out:?}");
71 MsgraphCoroutineState::Complete(Ok(out))
72 }
73}