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