bsac_api_client/apis/
schedule_change_api.rs1use 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 GetScheduleAdditionsError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetScheduleMovesError {
29 UnknownValue(serde_json::Value),
30}
31
32
33pub async fn get_schedule_additions(configuration: &configuration::Configuration, group_id: i32) -> Result<models::ScheduleAddListServiceResponse, Error<GetScheduleAdditionsError>> {
34 let local_var_configuration = configuration;
35
36 let local_var_client = &local_var_configuration.client;
37
38 let local_var_uri_str = format!("{}/api/schedulechange/additions/{groupId}", local_var_configuration.base_path, groupId=group_id);
39 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
40
41 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
42 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
43 }
44
45 let local_var_req = local_var_req_builder.build()?;
46 let local_var_resp = local_var_client.execute(local_var_req).await?;
47
48 let local_var_status = local_var_resp.status();
49 let local_var_content = local_var_resp.text().await?;
50
51 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
52 serde_json::from_str(&local_var_content).map_err(Error::from)
53 } else {
54 let local_var_entity: Option<GetScheduleAdditionsError> = serde_json::from_str(&local_var_content).ok();
55 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
56 Err(Error::ResponseError(local_var_error))
57 }
58}
59
60pub async fn get_schedule_moves(configuration: &configuration::Configuration, group_id: i32) -> Result<models::ScheduleAddListServiceResponse, Error<GetScheduleMovesError>> {
61 let local_var_configuration = configuration;
62
63 let local_var_client = &local_var_configuration.client;
64
65 let local_var_uri_str = format!("{}/api/schedulechange/move/{groupId}", local_var_configuration.base_path, groupId=group_id);
66 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
67
68 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
69 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
70 }
71
72 let local_var_req = local_var_req_builder.build()?;
73 let local_var_resp = local_var_client.execute(local_var_req).await?;
74
75 let local_var_status = local_var_resp.status();
76 let local_var_content = local_var_resp.text().await?;
77
78 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
79 serde_json::from_str(&local_var_content).map_err(Error::from)
80 } else {
81 let local_var_entity: Option<GetScheduleMovesError> = serde_json::from_str(&local_var_content).ok();
82 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
83 Err(Error::ResponseError(local_var_error))
84 }
85}
86