zsgf_client/apis/
team_api.rs1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum TeamDeleteError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum TeamPostError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum TeamPutError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum TeamsError {
43 UnknownValue(serde_json::Value),
44}
45
46
47pub async fn team_delete(configuration: &configuration::Configuration, id: i64) -> Result<models::BooleanApiResponse, Error<TeamDeleteError>> {
49 let p_id = id;
51
52 let uri_str = format!("{}/Team/{id}", configuration.base_path, id=p_id);
53 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
54
55 if let Some(ref user_agent) = configuration.user_agent {
56 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
57 }
58 if let Some(ref token) = configuration.bearer_access_token {
59 req_builder = req_builder.bearer_auth(token.to_owned());
60 };
61
62 let req = req_builder.build()?;
63 let resp = configuration.client.execute(req).await?;
64
65 let status = resp.status();
66 let content_type = resp
67 .headers()
68 .get("content-type")
69 .and_then(|v| v.to_str().ok())
70 .unwrap_or("application/octet-stream");
71 let content_type = super::ContentType::from(content_type);
72
73 if !status.is_client_error() && !status.is_server_error() {
74 let content = resp.text().await?;
75 match content_type {
76 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
77 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BooleanApiResponse`"))),
78 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BooleanApiResponse`")))),
79 }
80 } else {
81 let content = resp.text().await?;
82 let entity: Option<TeamDeleteError> = serde_json::from_str(&content).ok();
83 Err(Error::ResponseError(ResponseContent { status, content, entity }))
84 }
85}
86
87pub async fn team_post(configuration: &configuration::Configuration, team: Option<models::Team>) -> Result<models::BooleanApiResponse, Error<TeamPostError>> {
89 let p_team = team;
91
92 let uri_str = format!("{}/Team", configuration.base_path);
93 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
94
95 if let Some(ref user_agent) = configuration.user_agent {
96 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
97 }
98 if let Some(ref token) = configuration.bearer_access_token {
99 req_builder = req_builder.bearer_auth(token.to_owned());
100 };
101 req_builder = req_builder.json(&p_team);
102
103 let req = req_builder.build()?;
104 let resp = configuration.client.execute(req).await?;
105
106 let status = resp.status();
107 let content_type = resp
108 .headers()
109 .get("content-type")
110 .and_then(|v| v.to_str().ok())
111 .unwrap_or("application/octet-stream");
112 let content_type = super::ContentType::from(content_type);
113
114 if !status.is_client_error() && !status.is_server_error() {
115 let content = resp.text().await?;
116 match content_type {
117 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
118 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BooleanApiResponse`"))),
119 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BooleanApiResponse`")))),
120 }
121 } else {
122 let content = resp.text().await?;
123 let entity: Option<TeamPostError> = serde_json::from_str(&content).ok();
124 Err(Error::ResponseError(ResponseContent { status, content, entity }))
125 }
126}
127
128pub async fn team_put(configuration: &configuration::Configuration, id: i64, team: Option<models::Team>) -> Result<models::BooleanApiResponse, Error<TeamPutError>> {
130 let p_id = id;
132 let p_team = team;
133
134 let uri_str = format!("{}/Team/{id}", configuration.base_path, id=p_id);
135 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
136
137 if let Some(ref user_agent) = configuration.user_agent {
138 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
139 }
140 if let Some(ref token) = configuration.bearer_access_token {
141 req_builder = req_builder.bearer_auth(token.to_owned());
142 };
143 req_builder = req_builder.json(&p_team);
144
145 let req = req_builder.build()?;
146 let resp = configuration.client.execute(req).await?;
147
148 let status = resp.status();
149 let content_type = resp
150 .headers()
151 .get("content-type")
152 .and_then(|v| v.to_str().ok())
153 .unwrap_or("application/octet-stream");
154 let content_type = super::ContentType::from(content_type);
155
156 if !status.is_client_error() && !status.is_server_error() {
157 let content = resp.text().await?;
158 match content_type {
159 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
160 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BooleanApiResponse`"))),
161 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BooleanApiResponse`")))),
162 }
163 } else {
164 let content = resp.text().await?;
165 let entity: Option<TeamPutError> = serde_json::from_str(&content).ok();
166 Err(Error::ResponseError(ResponseContent { status, content, entity }))
167 }
168}
169
170pub async fn teams(configuration: &configuration::Configuration, channel_code: Option<&str>, channel_app_id: Option<&str>) -> Result<models::ListResponseItemListApiResponse, Error<TeamsError>> {
172 let p_channel_code = channel_code;
174 let p_channel_app_id = channel_app_id;
175
176 let uri_str = format!("{}/Team", configuration.base_path);
177 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
178
179 if let Some(ref param_value) = p_channel_code {
180 req_builder = req_builder.query(&[("channelCode", ¶m_value.to_string())]);
181 }
182 if let Some(ref param_value) = p_channel_app_id {
183 req_builder = req_builder.query(&[("channelAppId", ¶m_value.to_string())]);
184 }
185 if let Some(ref user_agent) = configuration.user_agent {
186 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
187 }
188 if let Some(ref token) = configuration.bearer_access_token {
189 req_builder = req_builder.bearer_auth(token.to_owned());
190 };
191
192 let req = req_builder.build()?;
193 let resp = configuration.client.execute(req).await?;
194
195 let status = resp.status();
196 let content_type = resp
197 .headers()
198 .get("content-type")
199 .and_then(|v| v.to_str().ok())
200 .unwrap_or("application/octet-stream");
201 let content_type = super::ContentType::from(content_type);
202
203 if !status.is_client_error() && !status.is_server_error() {
204 let content = resp.text().await?;
205 match content_type {
206 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
207 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListResponseItemListApiResponse`"))),
208 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListResponseItemListApiResponse`")))),
209 }
210 } else {
211 let content = resp.text().await?;
212 let entity: Option<TeamsError> = serde_json::from_str(&content).ok();
213 Err(Error::ResponseError(ResponseContent { status, content, entity }))
214 }
215}
216