1use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetScheduleActualityError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetScheduleForDateError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetScheduleForGroupsError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetScheduleForTeachersError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetWeekError {
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetWorksScheduleError {
57 UnknownValue(serde_json::Value),
58}
59
60
61pub async fn get_schedule_actuality(configuration: &configuration::Configuration, last_interact: Option<String>) -> Result<models::BooleanServiceResponse, Error<GetScheduleActualityError>> {
62 let local_var_configuration = configuration;
63
64 let local_var_client = &local_var_configuration.client;
65
66 let local_var_uri_str = format!("{}/api/schedules/actuality", local_var_configuration.base_path);
67 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
68
69 if let Some(ref local_var_str) = last_interact {
70 local_var_req_builder = local_var_req_builder.query(&[("lastInteract", &local_var_str.to_string())]);
71 }
72 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
73 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
74 }
75
76 let local_var_req = local_var_req_builder.build()?;
77 let local_var_resp = local_var_client.execute(local_var_req).await?;
78
79 let local_var_status = local_var_resp.status();
80 let local_var_content = local_var_resp.text().await?;
81
82 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
83 serde_json::from_str(&local_var_content).map_err(Error::from)
84 } else {
85 let local_var_entity: Option<GetScheduleActualityError> = serde_json::from_str(&local_var_content).ok();
86 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
87 Err(Error::ResponseError(local_var_error))
88 }
89}
90
91pub async fn get_schedule_for_date(configuration: &configuration::Configuration, group_id: i32, dates: Option<Vec<String>>) -> Result<models::GetScheduleForOneGroupListServiceResponse, Error<GetScheduleForDateError>> {
92 let local_var_configuration = configuration;
93
94 let local_var_client = &local_var_configuration.client;
95
96 let local_var_uri_str = format!("{}/api/schedules/groups/{groupId}/date", local_var_configuration.base_path, groupId=group_id);
97 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
98
99 if let Some(ref local_var_str) = dates {
100 local_var_req_builder = match "multi" {
101 "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("dates".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
102 _ => local_var_req_builder.query(&[("dates", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
103 };
104 }
105 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
106 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
107 }
108
109 let local_var_req = local_var_req_builder.build()?;
110 let local_var_resp = local_var_client.execute(local_var_req).await?;
111
112 let local_var_status = local_var_resp.status();
113 let local_var_content = local_var_resp.text().await?;
114
115 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
116 serde_json::from_str(&local_var_content).map_err(Error::from)
117 } else {
118 let local_var_entity: Option<GetScheduleForDateError> = serde_json::from_str(&local_var_content).ok();
119 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
120 Err(Error::ResponseError(local_var_error))
121 }
122}
123
124pub async fn get_schedule_for_groups(configuration: &configuration::Configuration, groups_ids: Option<Vec<i32>>) -> Result<models::GetScheduleForListOfGroupsListServiceResponse, Error<GetScheduleForGroupsError>> {
125 let local_var_configuration = configuration;
126
127 let local_var_client = &local_var_configuration.client;
128
129 let local_var_uri_str = format!("{}/api/schedules/groups", local_var_configuration.base_path);
130 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
131
132 if let Some(ref local_var_str) = groups_ids {
133 local_var_req_builder = match "multi" {
134 "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("groupsIds".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
135 _ => local_var_req_builder.query(&[("groupsIds", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
136 };
137 }
138 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
139 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
140 }
141
142 let local_var_req = local_var_req_builder.build()?;
143 let local_var_resp = local_var_client.execute(local_var_req).await?;
144
145 let local_var_status = local_var_resp.status();
146 let local_var_content = local_var_resp.text().await?;
147
148 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
149 serde_json::from_str(&local_var_content).map_err(Error::from)
150 } else {
151 let local_var_entity: Option<GetScheduleForGroupsError> = serde_json::from_str(&local_var_content).ok();
152 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
153 Err(Error::ResponseError(local_var_error))
154 }
155}
156
157pub async fn get_schedule_for_teachers(configuration: &configuration::Configuration, teachers_ids: Option<Vec<i32>>) -> Result<models::GetScheduleForListOfGroupsListServiceResponse, Error<GetScheduleForTeachersError>> {
158 let local_var_configuration = configuration;
159
160 let local_var_client = &local_var_configuration.client;
161
162 let local_var_uri_str = format!("{}/api/schedules/teachers", local_var_configuration.base_path);
163 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
164
165 if let Some(ref local_var_str) = teachers_ids {
166 local_var_req_builder = match "multi" {
167 "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("teachersIds".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
168 _ => local_var_req_builder.query(&[("teachersIds", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
169 };
170 }
171 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
172 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
173 }
174
175 let local_var_req = local_var_req_builder.build()?;
176 let local_var_resp = local_var_client.execute(local_var_req).await?;
177
178 let local_var_status = local_var_resp.status();
179 let local_var_content = local_var_resp.text().await?;
180
181 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
182 serde_json::from_str(&local_var_content).map_err(Error::from)
183 } else {
184 let local_var_entity: Option<GetScheduleForTeachersError> = serde_json::from_str(&local_var_content).ok();
185 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
186 Err(Error::ResponseError(local_var_error))
187 }
188}
189
190pub async fn get_week(configuration: &configuration::Configuration, ) -> Result<models::Int32ServiceResponse, Error<GetWeekError>> {
191 let local_var_configuration = configuration;
192
193 let local_var_client = &local_var_configuration.client;
194
195 let local_var_uri_str = format!("{}/api/schedules/week", local_var_configuration.base_path);
196 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
197
198 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
199 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
200 }
201
202 let local_var_req = local_var_req_builder.build()?;
203 let local_var_resp = local_var_client.execute(local_var_req).await?;
204
205 let local_var_status = local_var_resp.status();
206 let local_var_content = local_var_resp.text().await?;
207
208 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
209 serde_json::from_str(&local_var_content).map_err(Error::from)
210 } else {
211 let local_var_entity: Option<GetWeekError> = serde_json::from_str(&local_var_content).ok();
212 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
213 Err(Error::ResponseError(local_var_error))
214 }
215}
216
217pub async fn get_works_schedule(configuration: &configuration::Configuration, teacher_id: Option<i32>, group_id: Option<i32>, lesson_id: Option<i32>) -> Result<models::GetWorksScheduleDtoListServiceResponse, Error<GetWorksScheduleError>> {
218 let local_var_configuration = configuration;
219
220 let local_var_client = &local_var_configuration.client;
221
222 let local_var_uri_str = format!("{}/api/schedules/works", local_var_configuration.base_path);
223 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
224
225 if let Some(ref local_var_str) = teacher_id {
226 local_var_req_builder = local_var_req_builder.query(&[("teacherId", &local_var_str.to_string())]);
227 }
228 if let Some(ref local_var_str) = group_id {
229 local_var_req_builder = local_var_req_builder.query(&[("groupId", &local_var_str.to_string())]);
230 }
231 if let Some(ref local_var_str) = lesson_id {
232 local_var_req_builder = local_var_req_builder.query(&[("lessonId", &local_var_str.to_string())]);
233 }
234 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
235 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
236 }
237
238 let local_var_req = local_var_req_builder.build()?;
239 let local_var_resp = local_var_client.execute(local_var_req).await?;
240
241 let local_var_status = local_var_resp.status();
242 let local_var_content = local_var_resp.text().await?;
243
244 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
245 serde_json::from_str(&local_var_content).map_err(Error::from)
246 } else {
247 let local_var_entity: Option<GetWorksScheduleError> = serde_json::from_str(&local_var_content).ok();
248 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
249 Err(Error::ResponseError(local_var_error))
250 }
251}
252