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