1use 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 DeleteDeleteCustomerError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum DeleteDeleteCustomerRateError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetGetCustomerError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetGetCustomerRatesError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetGetCustomersError {
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum PatchAppApiCustomerMetaError {
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum PatchPatchCustomerError {
64 UnknownValue(serde_json::Value),
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum PostPostCustomerError {
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum PostPostCustomerRateError {
78 UnknownValue(serde_json::Value),
79}
80
81
82pub async fn delete_delete_customer(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DeleteDeleteCustomerError>> {
84 let p_id = id;
86
87 let uri_str = format!("{}/api/customers/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
88 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
89
90 if let Some(ref user_agent) = configuration.user_agent {
91 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
92 }
93 if let Some(ref token) = configuration.bearer_access_token {
94 req_builder = req_builder.bearer_auth(token.to_owned());
95 };
96
97 let req = req_builder.build()?;
98 let resp = configuration.client.execute(req).await?;
99
100 let status = resp.status();
101
102 if !status.is_client_error() && !status.is_server_error() {
103 Ok(())
104 } else {
105 let content = resp.text().await?;
106 let entity: Option<DeleteDeleteCustomerError> = serde_json::from_str(&content).ok();
107 Err(Error::ResponseError(ResponseContent { status, content, entity }))
108 }
109}
110
111pub async fn delete_delete_customer_rate(configuration: &configuration::Configuration, id: &str, rate_id: &str) -> Result<(), Error<DeleteDeleteCustomerRateError>> {
112 let p_id = id;
114 let p_rate_id = rate_id;
115
116 let uri_str = format!("{}/api/customers/{id}/rates/{rateId}", configuration.base_path, id=crate::apis::urlencode(p_id), rateId=crate::apis::urlencode(p_rate_id));
117 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
118
119 if let Some(ref user_agent) = configuration.user_agent {
120 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
121 }
122 if let Some(ref token) = configuration.bearer_access_token {
123 req_builder = req_builder.bearer_auth(token.to_owned());
124 };
125
126 let req = req_builder.build()?;
127 let resp = configuration.client.execute(req).await?;
128
129 let status = resp.status();
130
131 if !status.is_client_error() && !status.is_server_error() {
132 Ok(())
133 } else {
134 let content = resp.text().await?;
135 let entity: Option<DeleteDeleteCustomerRateError> = serde_json::from_str(&content).ok();
136 Err(Error::ResponseError(ResponseContent { status, content, entity }))
137 }
138}
139
140pub async fn get_get_customer(configuration: &configuration::Configuration, id: &str) -> Result<models::CustomerEntity, Error<GetGetCustomerError>> {
141 let p_id = id;
143
144 let uri_str = format!("{}/api/customers/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
145 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
146
147 if let Some(ref user_agent) = configuration.user_agent {
148 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
149 }
150 if let Some(ref token) = configuration.bearer_access_token {
151 req_builder = req_builder.bearer_auth(token.to_owned());
152 };
153
154 let req = req_builder.build()?;
155 let resp = configuration.client.execute(req).await?;
156
157 let status = resp.status();
158 let content_type = resp
159 .headers()
160 .get("content-type")
161 .and_then(|v| v.to_str().ok())
162 .unwrap_or("application/octet-stream");
163 let content_type = super::ContentType::from(content_type);
164
165 if !status.is_client_error() && !status.is_server_error() {
166 let content = resp.text().await?;
167 match content_type {
168 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
169 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CustomerEntity`"))),
170 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::CustomerEntity`")))),
171 }
172 } else {
173 let content = resp.text().await?;
174 let entity: Option<GetGetCustomerError> = serde_json::from_str(&content).ok();
175 Err(Error::ResponseError(ResponseContent { status, content, entity }))
176 }
177}
178
179pub async fn get_get_customer_rates(configuration: &configuration::Configuration, id: &str) -> Result<Vec<models::CustomerRate>, Error<GetGetCustomerRatesError>> {
180 let p_id = id;
182
183 let uri_str = format!("{}/api/customers/{id}/rates", configuration.base_path, id=crate::apis::urlencode(p_id));
184 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
185
186 if let Some(ref user_agent) = configuration.user_agent {
187 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
188 }
189 if let Some(ref token) = configuration.bearer_access_token {
190 req_builder = req_builder.bearer_auth(token.to_owned());
191 };
192
193 let req = req_builder.build()?;
194 let resp = configuration.client.execute(req).await?;
195
196 let status = resp.status();
197 let content_type = resp
198 .headers()
199 .get("content-type")
200 .and_then(|v| v.to_str().ok())
201 .unwrap_or("application/octet-stream");
202 let content_type = super::ContentType::from(content_type);
203
204 if !status.is_client_error() && !status.is_server_error() {
205 let content = resp.text().await?;
206 match content_type {
207 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
208 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::CustomerRate>`"))),
209 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::CustomerRate>`")))),
210 }
211 } else {
212 let content = resp.text().await?;
213 let entity: Option<GetGetCustomerRatesError> = serde_json::from_str(&content).ok();
214 Err(Error::ResponseError(ResponseContent { status, content, entity }))
215 }
216}
217
218pub async fn get_get_customers(configuration: &configuration::Configuration, visible: Option<&str>, order: Option<&str>, order_by: Option<&str>, term: Option<&str>) -> Result<Vec<models::CustomerCollection>, Error<GetGetCustomersError>> {
219 let p_visible = visible;
221 let p_order = order;
222 let p_order_by = order_by;
223 let p_term = term;
224
225 let uri_str = format!("{}/api/customers", configuration.base_path);
226 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
227
228 if let Some(ref param_value) = p_visible {
229 req_builder = req_builder.query(&[("visible", ¶m_value.to_string())]);
230 }
231 if let Some(ref param_value) = p_order {
232 req_builder = req_builder.query(&[("order", ¶m_value.to_string())]);
233 }
234 if let Some(ref param_value) = p_order_by {
235 req_builder = req_builder.query(&[("orderBy", ¶m_value.to_string())]);
236 }
237 if let Some(ref param_value) = p_term {
238 req_builder = req_builder.query(&[("term", ¶m_value.to_string())]);
239 }
240 if let Some(ref user_agent) = configuration.user_agent {
241 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
242 }
243 if let Some(ref token) = configuration.bearer_access_token {
244 req_builder = req_builder.bearer_auth(token.to_owned());
245 };
246
247 let req = req_builder.build()?;
248 let resp = configuration.client.execute(req).await?;
249
250 let status = resp.status();
251 let content_type = resp
252 .headers()
253 .get("content-type")
254 .and_then(|v| v.to_str().ok())
255 .unwrap_or("application/octet-stream");
256 let content_type = super::ContentType::from(content_type);
257
258 if !status.is_client_error() && !status.is_server_error() {
259 let content = resp.text().await?;
260 match content_type {
261 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
262 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::CustomerCollection>`"))),
263 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::CustomerCollection>`")))),
264 }
265 } else {
266 let content = resp.text().await?;
267 let entity: Option<GetGetCustomersError> = serde_json::from_str(&content).ok();
268 Err(Error::ResponseError(ResponseContent { status, content, entity }))
269 }
270}
271
272pub async fn patch_app_api_customer_meta(configuration: &configuration::Configuration, id: &str, patch_kimaiplugin_expenses_api_expense_meta_request: Option<models::PatchKimaipluginExpensesApiExpenseMetaRequest>) -> Result<models::CustomerEntity, Error<PatchAppApiCustomerMetaError>> {
273 let p_id = id;
275 let p_patch_kimaiplugin_expenses_api_expense_meta_request = patch_kimaiplugin_expenses_api_expense_meta_request;
276
277 let uri_str = format!("{}/api/customers/{id}/meta", configuration.base_path, id=crate::apis::urlencode(p_id));
278 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
279
280 if let Some(ref user_agent) = configuration.user_agent {
281 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
282 }
283 if let Some(ref token) = configuration.bearer_access_token {
284 req_builder = req_builder.bearer_auth(token.to_owned());
285 };
286 req_builder = req_builder.json(&p_patch_kimaiplugin_expenses_api_expense_meta_request);
287
288 let req = req_builder.build()?;
289 let resp = configuration.client.execute(req).await?;
290
291 let status = resp.status();
292 let content_type = resp
293 .headers()
294 .get("content-type")
295 .and_then(|v| v.to_str().ok())
296 .unwrap_or("application/octet-stream");
297 let content_type = super::ContentType::from(content_type);
298
299 if !status.is_client_error() && !status.is_server_error() {
300 let content = resp.text().await?;
301 match content_type {
302 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
303 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CustomerEntity`"))),
304 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::CustomerEntity`")))),
305 }
306 } else {
307 let content = resp.text().await?;
308 let entity: Option<PatchAppApiCustomerMetaError> = serde_json::from_str(&content).ok();
309 Err(Error::ResponseError(ResponseContent { status, content, entity }))
310 }
311}
312
313pub async fn patch_patch_customer(configuration: &configuration::Configuration, id: &str, customer_edit_form: models::CustomerEditForm) -> Result<models::CustomerEntity, Error<PatchPatchCustomerError>> {
315 let p_id = id;
317 let p_customer_edit_form = customer_edit_form;
318
319 let uri_str = format!("{}/api/customers/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
320 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
321
322 if let Some(ref user_agent) = configuration.user_agent {
323 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
324 }
325 if let Some(ref token) = configuration.bearer_access_token {
326 req_builder = req_builder.bearer_auth(token.to_owned());
327 };
328 req_builder = req_builder.json(&p_customer_edit_form);
329
330 let req = req_builder.build()?;
331 let resp = configuration.client.execute(req).await?;
332
333 let status = resp.status();
334 let content_type = resp
335 .headers()
336 .get("content-type")
337 .and_then(|v| v.to_str().ok())
338 .unwrap_or("application/octet-stream");
339 let content_type = super::ContentType::from(content_type);
340
341 if !status.is_client_error() && !status.is_server_error() {
342 let content = resp.text().await?;
343 match content_type {
344 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
345 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CustomerEntity`"))),
346 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::CustomerEntity`")))),
347 }
348 } else {
349 let content = resp.text().await?;
350 let entity: Option<PatchPatchCustomerError> = serde_json::from_str(&content).ok();
351 Err(Error::ResponseError(ResponseContent { status, content, entity }))
352 }
353}
354
355pub async fn post_post_customer(configuration: &configuration::Configuration, customer_edit_form: models::CustomerEditForm) -> Result<models::CustomerEntity, Error<PostPostCustomerError>> {
357 let p_customer_edit_form = customer_edit_form;
359
360 let uri_str = format!("{}/api/customers", configuration.base_path);
361 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
362
363 if let Some(ref user_agent) = configuration.user_agent {
364 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
365 }
366 if let Some(ref token) = configuration.bearer_access_token {
367 req_builder = req_builder.bearer_auth(token.to_owned());
368 };
369 req_builder = req_builder.json(&p_customer_edit_form);
370
371 let req = req_builder.build()?;
372 let resp = configuration.client.execute(req).await?;
373
374 let status = resp.status();
375 let content_type = resp
376 .headers()
377 .get("content-type")
378 .and_then(|v| v.to_str().ok())
379 .unwrap_or("application/octet-stream");
380 let content_type = super::ContentType::from(content_type);
381
382 if !status.is_client_error() && !status.is_server_error() {
383 let content = resp.text().await?;
384 match content_type {
385 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
386 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CustomerEntity`"))),
387 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::CustomerEntity`")))),
388 }
389 } else {
390 let content = resp.text().await?;
391 let entity: Option<PostPostCustomerError> = serde_json::from_str(&content).ok();
392 Err(Error::ResponseError(ResponseContent { status, content, entity }))
393 }
394}
395
396pub async fn post_post_customer_rate(configuration: &configuration::Configuration, id: &str, customer_rate_form: models::CustomerRateForm) -> Result<models::CustomerRate, Error<PostPostCustomerRateError>> {
397 let p_id = id;
399 let p_customer_rate_form = customer_rate_form;
400
401 let uri_str = format!("{}/api/customers/{id}/rates", configuration.base_path, id=crate::apis::urlencode(p_id));
402 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
403
404 if let Some(ref user_agent) = configuration.user_agent {
405 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
406 }
407 if let Some(ref token) = configuration.bearer_access_token {
408 req_builder = req_builder.bearer_auth(token.to_owned());
409 };
410 req_builder = req_builder.json(&p_customer_rate_form);
411
412 let req = req_builder.build()?;
413 let resp = configuration.client.execute(req).await?;
414
415 let status = resp.status();
416 let content_type = resp
417 .headers()
418 .get("content-type")
419 .and_then(|v| v.to_str().ok())
420 .unwrap_or("application/octet-stream");
421 let content_type = super::ContentType::from(content_type);
422
423 if !status.is_client_error() && !status.is_server_error() {
424 let content = resp.text().await?;
425 match content_type {
426 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
427 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CustomerRate`"))),
428 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::CustomerRate`")))),
429 }
430 } else {
431 let content = resp.text().await?;
432 let entity: Option<PostPostCustomerRateError> = serde_json::from_str(&content).ok();
433 Err(Error::ResponseError(ResponseContent { status, content, entity }))
434 }
435}
436