io_msgraph/v1/rest/users/todo/lists/
delta.rs1use alloc::{format, string::String, vec::Vec};
12
13use io_http::rfc6750::bearer::HttpAuthBearer;
14use log::{debug, trace};
15use serde::{Deserialize, Serialize};
16use url::Url;
17
18use crate::{
19 coroutine::*,
20 msgraph_try,
21 v1::{
22 rest::users::{contacts::delta::MsgraphRemoved, todo::lists::MsgraphTodoList},
23 send::{MSGRAPH_API_BASE, MsgraphSend, MsgraphSendError, MsgraphSendOutput, user_path},
24 },
25};
26
27#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
32pub struct MsgraphTodoListsDeltaResponse {
33 #[serde(default)]
35 pub value: Vec<MsgraphTodoListDelta>,
36 #[serde(default, rename = "@odata.nextLink")]
38 pub next_link: Option<String>,
39 #[serde(default, rename = "@odata.deltaLink")]
41 pub delta_link: Option<String>,
42}
43
44#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
47pub struct MsgraphTodoListDelta {
48 #[serde(flatten)]
50 pub list: MsgraphTodoList,
51 #[serde(default, rename = "@removed", skip_serializing_if = "Option::is_none")]
53 pub removed: Option<MsgraphRemoved>,
54}
55
56pub struct MsgraphTodoListsDelta {
60 send: MsgraphSend<MsgraphTodoListsDeltaResponse>,
61}
62
63impl MsgraphTodoListsDelta {
64 pub fn new(auth: &HttpAuthBearer, user_id: &str) -> Result<Self, MsgraphSendError> {
66 debug!("prepare microsoft graph to do lists delta");
67
68 let user = user_path(user_id);
69 let url = Url::parse(MSGRAPH_API_BASE)?.join(&format!("{user}/todo/lists/delta"))?;
70 let send = MsgraphSend::get(auth, url);
71
72 Ok(Self { send })
73 }
74
75 pub fn from_link(auth: &HttpAuthBearer, link: &str) -> Result<Self, MsgraphSendError> {
78 debug!("prepare microsoft graph to do lists delta from link");
79 trace!("link: {link}");
80
81 let url = Url::parse(link)?;
82 let send = MsgraphSend::get(auth, url);
83
84 Ok(Self { send })
85 }
86
87 pub fn max_page_size(mut self, size: u32) -> Self {
93 self.send = self.send.max_page_size(size);
94 self
95 }
96}
97
98impl MsgraphCoroutine for MsgraphTodoListsDelta {
99 type Yield = MsgraphYield;
100 type Return = Result<MsgraphSendOutput<MsgraphTodoListsDeltaResponse>, MsgraphSendError>;
101
102 fn resume(&mut self, arg: Option<&[u8]>) -> MsgraphCoroutineState<Self::Yield, Self::Return> {
103 let out = msgraph_try!(&mut self.send, arg);
104 debug!("to do lists delta page received");
105 trace!("out: {out:?}");
106 MsgraphCoroutineState::Complete(Ok(out))
107 }
108}