1use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum Delete13Error {
20 UnknownValue(serde_json::Value),
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize)]
25#[serde(untagged)]
26pub enum DeleteUploadError {
27 UnknownValue(serde_json::Value),
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum FindAll14Error {
34 UnknownValue(serde_json::Value),
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum FindByContractStatusError {
41 UnknownValue(serde_json::Value),
42}
43
44#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum Save7Error {
48 UnknownValue(serde_json::Value),
49}
50
51#[derive(Debug, Clone, Serialize, Deserialize)]
53#[serde(untagged)]
54pub enum Upload1Error {
55 UnknownValue(serde_json::Value),
56}
57
58pub async fn delete13(
59 configuration: &configuration::Configuration,
60 id: &str,
61) -> Result<(), Error<Delete13Error>> {
62 let p_query_id = id;
64
65 let uri_str = format!("{}/api/billable-client", configuration.base_path);
66 let mut req_builder = configuration
67 .client
68 .request(reqwest::Method::DELETE, &uri_str);
69
70 req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
71 if let Some(ref user_agent) = configuration.user_agent {
72 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
73 }
74 if let Some(ref token) = configuration.bearer_access_token {
75 req_builder = req_builder.bearer_auth(token.to_owned());
76 };
77
78 let req = req_builder.build()?;
79 let resp = configuration.client.execute(req).await?;
80
81 let status = resp.status();
82
83 if !status.is_client_error() && !status.is_server_error() {
84 Ok(())
85 } else {
86 let content = resp.text().await?;
87 let entity: Option<Delete13Error> = serde_json::from_str(&content).ok();
88 Err(Error::ResponseError(ResponseContent {
89 status,
90 content,
91 entity,
92 }))
93 }
94}
95
96pub async fn delete_upload(
97 configuration: &configuration::Configuration,
98 id: &str,
99 upload_id: &str,
100) -> Result<(), Error<DeleteUploadError>> {
101 let p_query_id = id;
103 let p_query_upload_id = upload_id;
104
105 let uri_str = format!("{}/api/billable-client/upload", configuration.base_path);
106 let mut req_builder = configuration
107 .client
108 .request(reqwest::Method::DELETE, &uri_str);
109
110 req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
111 req_builder = req_builder.query(&[("uploadId", &p_query_upload_id.to_string())]);
112 if let Some(ref user_agent) = configuration.user_agent {
113 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
114 }
115 if let Some(ref token) = configuration.bearer_access_token {
116 req_builder = req_builder.bearer_auth(token.to_owned());
117 };
118
119 let req = req_builder.build()?;
120 let resp = configuration.client.execute(req).await?;
121
122 let status = resp.status();
123
124 if !status.is_client_error() && !status.is_server_error() {
125 Ok(())
126 } else {
127 let content = resp.text().await?;
128 let entity: Option<DeleteUploadError> = serde_json::from_str(&content).ok();
129 Err(Error::ResponseError(ResponseContent {
130 status,
131 content,
132 entity,
133 }))
134 }
135}
136
137pub async fn find_all14(
138 configuration: &configuration::Configuration,
139) -> Result<Vec<models::BillableClient>, Error<FindAll14Error>> {
140 let uri_str = format!("{}/api/billable-client/find-all", configuration.base_path);
141 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
142
143 if let Some(ref user_agent) = configuration.user_agent {
144 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
145 }
146 if let Some(ref token) = configuration.bearer_access_token {
147 req_builder = req_builder.bearer_auth(token.to_owned());
148 };
149
150 let req = req_builder.build()?;
151 let resp = configuration.client.execute(req).await?;
152
153 let status = resp.status();
154 let content_type = resp
155 .headers()
156 .get("content-type")
157 .and_then(|v| v.to_str().ok())
158 .unwrap_or("application/octet-stream");
159 let content_type = super::ContentType::from(content_type);
160
161 if !status.is_client_error() && !status.is_server_error() {
162 let content = resp.text().await?;
163 match content_type {
164 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
165 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::BillableClient>`"))),
166 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::BillableClient>`")))),
167 }
168 } else {
169 let content = resp.text().await?;
170 let entity: Option<FindAll14Error> = serde_json::from_str(&content).ok();
171 Err(Error::ResponseError(ResponseContent {
172 status,
173 content,
174 entity,
175 }))
176 }
177}
178
179pub async fn find_by_contract_status(
180 configuration: &configuration::Configuration,
181 contract_status: &str,
182) -> Result<Vec<models::BillableClient>, Error<FindByContractStatusError>> {
183 let p_query_contract_status = contract_status;
185
186 let uri_str = format!(
187 "{}/api/billable-client/find-by-contract-status",
188 configuration.base_path
189 );
190 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
191
192 req_builder = req_builder.query(&[("contractStatus", &p_query_contract_status.to_string())]);
193 if let Some(ref user_agent) = configuration.user_agent {
194 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
195 }
196 if let Some(ref token) = configuration.bearer_access_token {
197 req_builder = req_builder.bearer_auth(token.to_owned());
198 };
199
200 let req = req_builder.build()?;
201 let resp = configuration.client.execute(req).await?;
202
203 let status = resp.status();
204 let content_type = resp
205 .headers()
206 .get("content-type")
207 .and_then(|v| v.to_str().ok())
208 .unwrap_or("application/octet-stream");
209 let content_type = super::ContentType::from(content_type);
210
211 if !status.is_client_error() && !status.is_server_error() {
212 let content = resp.text().await?;
213 match content_type {
214 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
215 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::BillableClient>`"))),
216 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::BillableClient>`")))),
217 }
218 } else {
219 let content = resp.text().await?;
220 let entity: Option<FindByContractStatusError> = serde_json::from_str(&content).ok();
221 Err(Error::ResponseError(ResponseContent {
222 status,
223 content,
224 entity,
225 }))
226 }
227}
228
229pub async fn save7(
230 configuration: &configuration::Configuration,
231 billable_client: models::BillableClient,
232) -> Result<models::BillableClient, Error<Save7Error>> {
233 let p_body_billable_client = billable_client;
235
236 let uri_str = format!("{}/api/billable-client/save", configuration.base_path);
237 let mut req_builder = configuration
238 .client
239 .request(reqwest::Method::POST, &uri_str);
240
241 if let Some(ref user_agent) = configuration.user_agent {
242 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
243 }
244 if let Some(ref token) = configuration.bearer_access_token {
245 req_builder = req_builder.bearer_auth(token.to_owned());
246 };
247 req_builder = req_builder.json(&p_body_billable_client);
248
249 let req = req_builder.build()?;
250 let resp = configuration.client.execute(req).await?;
251
252 let status = resp.status();
253 let content_type = resp
254 .headers()
255 .get("content-type")
256 .and_then(|v| v.to_str().ok())
257 .unwrap_or("application/octet-stream");
258 let content_type = super::ContentType::from(content_type);
259
260 if !status.is_client_error() && !status.is_server_error() {
261 let content = resp.text().await?;
262 match content_type {
263 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
264 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BillableClient`"))),
265 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BillableClient`")))),
266 }
267 } else {
268 let content = resp.text().await?;
269 let entity: Option<Save7Error> = serde_json::from_str(&content).ok();
270 Err(Error::ResponseError(ResponseContent {
271 status,
272 content,
273 entity,
274 }))
275 }
276}
277
278pub async fn upload1(
279 configuration: &configuration::Configuration,
280 document: std::path::PathBuf,
281 id: Option<&str>,
282) -> Result<(), Error<Upload1Error>> {
283 let p_form_document = document;
285 let p_query_id = id;
286
287 let uri_str = format!("{}/api/billable-client/upload", configuration.base_path);
288 let mut req_builder = configuration
289 .client
290 .request(reqwest::Method::POST, &uri_str);
291
292 if let Some(ref param_value) = p_query_id {
293 req_builder = req_builder.query(&[("id", ¶m_value.to_string())]);
294 }
295 if let Some(ref user_agent) = configuration.user_agent {
296 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
297 }
298 if let Some(ref token) = configuration.bearer_access_token {
299 req_builder = req_builder.bearer_auth(token.to_owned());
300 };
301 let multipart_form = reqwest::multipart::Form::new();
302 req_builder = req_builder.multipart(multipart_form);
304
305 let req = req_builder.build()?;
306 let resp = configuration.client.execute(req).await?;
307
308 let status = resp.status();
309
310 if !status.is_client_error() && !status.is_server_error() {
311 Ok(())
312 } else {
313 let content = resp.text().await?;
314 let entity: Option<Upload1Error> = serde_json::from_str(&content).ok();
315 Err(Error::ResponseError(ResponseContent {
316 status,
317 content,
318 entity,
319 }))
320 }
321}