1use reqwest;
13
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateIssuedDocumentError {
22 Status401(),
23 UnknownValue(serde_json::Value),
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum DeleteIssuedDocumentError {
30 Status401(),
31 Status404(),
32 UnknownValue(serde_json::Value),
33}
34
35#[derive(Debug, Clone, Serialize, Deserialize)]
37#[serde(untagged)]
38pub enum DeleteIssuedDocumentAttachmentError {
39 Status401(),
40 Status404(),
41 UnknownValue(serde_json::Value),
42}
43
44#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum GetEmailDataError {
48 UnknownValue(serde_json::Value),
49}
50
51#[derive(Debug, Clone, Serialize, Deserialize)]
53#[serde(untagged)]
54pub enum GetExistingIssuedDocumentTotalsError {
55 Status401(),
56 Status404(),
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum GetIssuedDocumentError {
64 Status401(),
65 Status404(),
66 UnknownValue(serde_json::Value),
67}
68
69#[derive(Debug, Clone, Serialize, Deserialize)]
71#[serde(untagged)]
72pub enum GetIssuedDocumentPreCreateInfoError {
73 UnknownValue(serde_json::Value),
74}
75
76#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(untagged)]
79pub enum GetNewIssuedDocumentTotalsError {
80 Status401(),
81 UnknownValue(serde_json::Value),
82}
83
84#[derive(Debug, Clone, Serialize, Deserialize)]
86#[serde(untagged)]
87pub enum JoinIssuedDocumentsError {
88 UnknownValue(serde_json::Value),
89}
90
91#[derive(Debug, Clone, Serialize, Deserialize)]
93#[serde(untagged)]
94pub enum ListIssuedDocumentsError {
95 Status401(),
96 Status404(),
97 UnknownValue(serde_json::Value),
98}
99
100#[derive(Debug, Clone, Serialize, Deserialize)]
102#[serde(untagged)]
103pub enum ModifyIssuedDocumentError {
104 Status401(),
105 Status404(),
106 UnknownValue(serde_json::Value),
107}
108
109#[derive(Debug, Clone, Serialize, Deserialize)]
111#[serde(untagged)]
112pub enum ScheduleEmailError {
113 Status401(),
114 Status404(),
115 UnknownValue(serde_json::Value),
116}
117
118#[derive(Debug, Clone, Serialize, Deserialize)]
120#[serde(untagged)]
121pub enum TransformIssuedDocumentError {
122 UnknownValue(serde_json::Value),
123}
124
125#[derive(Debug, Clone, Serialize, Deserialize)]
127#[serde(untagged)]
128pub enum UploadIssuedDocumentAttachmentError {
129 Status401(),
130 UnknownValue(serde_json::Value),
131}
132
133
134pub async fn create_issued_document(configuration: &configuration::Configuration, company_id: i32, create_issued_document_request: Option<models::CreateIssuedDocumentRequest>) -> Result<models::CreateIssuedDocumentResponse, Error<CreateIssuedDocumentError>> {
136 let local_var_configuration = configuration;
137
138 let local_var_client = &local_var_configuration.client;
139
140 let local_var_uri_str = format!("{}/c/{company_id}/issued_documents", local_var_configuration.base_path, company_id=company_id);
141 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
142
143 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
144 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
145 }
146 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
147 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
148 };
149 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
150 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
151 };
152 local_var_req_builder = local_var_req_builder.json(&create_issued_document_request);
153
154 let local_var_req = local_var_req_builder.build()?;
155 let local_var_resp = local_var_client.execute(local_var_req).await?;
156
157 let local_var_status = local_var_resp.status();
158 let local_var_content = local_var_resp.text().await?;
159
160 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
161 serde_json::from_str(&local_var_content).map_err(Error::from)
162 } else {
163 let local_var_entity: Option<CreateIssuedDocumentError> = serde_json::from_str(&local_var_content).ok();
164 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
165 Err(Error::ResponseError(local_var_error))
166 }
167}
168
169pub async fn delete_issued_document(configuration: &configuration::Configuration, company_id: i32, document_id: i32) -> Result<(), Error<DeleteIssuedDocumentError>> {
171 let local_var_configuration = configuration;
172
173 let local_var_client = &local_var_configuration.client;
174
175 let local_var_uri_str = format!("{}/c/{company_id}/issued_documents/{document_id}", local_var_configuration.base_path, company_id=company_id, document_id=document_id);
176 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
177
178 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
179 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
180 }
181 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
182 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
183 };
184 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
185 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
186 };
187
188 let local_var_req = local_var_req_builder.build()?;
189 let local_var_resp = local_var_client.execute(local_var_req).await?;
190
191 let local_var_status = local_var_resp.status();
192 let local_var_content = local_var_resp.text().await?;
193
194 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
195 Ok(())
196 } else {
197 let local_var_entity: Option<DeleteIssuedDocumentError> = serde_json::from_str(&local_var_content).ok();
198 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
199 Err(Error::ResponseError(local_var_error))
200 }
201}
202
203pub async fn delete_issued_document_attachment(configuration: &configuration::Configuration, company_id: i32, document_id: i32) -> Result<(), Error<DeleteIssuedDocumentAttachmentError>> {
205 let local_var_configuration = configuration;
206
207 let local_var_client = &local_var_configuration.client;
208
209 let local_var_uri_str = format!("{}/c/{company_id}/issued_documents/{document_id}/attachment", local_var_configuration.base_path, company_id=company_id, document_id=document_id);
210 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
211
212 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
213 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
214 }
215 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
216 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
217 };
218 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
219 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
220 };
221
222 let local_var_req = local_var_req_builder.build()?;
223 let local_var_resp = local_var_client.execute(local_var_req).await?;
224
225 let local_var_status = local_var_resp.status();
226 let local_var_content = local_var_resp.text().await?;
227
228 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
229 Ok(())
230 } else {
231 let local_var_entity: Option<DeleteIssuedDocumentAttachmentError> = serde_json::from_str(&local_var_content).ok();
232 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
233 Err(Error::ResponseError(local_var_error))
234 }
235}
236
237pub async fn get_email_data(configuration: &configuration::Configuration, company_id: i32, document_id: i32) -> Result<models::GetEmailDataResponse, Error<GetEmailDataError>> {
239 let local_var_configuration = configuration;
240
241 let local_var_client = &local_var_configuration.client;
242
243 let local_var_uri_str = format!("{}/c/{company_id}/issued_documents/{document_id}/email", local_var_configuration.base_path, company_id=company_id, document_id=document_id);
244 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
245
246 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
247 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
248 }
249 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
250 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
251 };
252 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
253 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
254 };
255
256 let local_var_req = local_var_req_builder.build()?;
257 let local_var_resp = local_var_client.execute(local_var_req).await?;
258
259 let local_var_status = local_var_resp.status();
260 let local_var_content = local_var_resp.text().await?;
261
262 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
263 serde_json::from_str(&local_var_content).map_err(Error::from)
264 } else {
265 let local_var_entity: Option<GetEmailDataError> = serde_json::from_str(&local_var_content).ok();
266 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
267 Err(Error::ResponseError(local_var_error))
268 }
269}
270
271pub async fn get_existing_issued_document_totals(configuration: &configuration::Configuration, company_id: i32, document_id: i32, get_existing_issued_document_totals_request: Option<models::GetExistingIssuedDocumentTotalsRequest>) -> Result<models::GetExistingIssuedDocumentTotalsResponse, Error<GetExistingIssuedDocumentTotalsError>> {
273 let local_var_configuration = configuration;
274
275 let local_var_client = &local_var_configuration.client;
276
277 let local_var_uri_str = format!("{}/c/{company_id}/issued_documents/{document_id}/totals", local_var_configuration.base_path, company_id=company_id, document_id=document_id);
278 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
279
280 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
281 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
282 }
283 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
284 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
285 };
286 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
287 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
288 };
289 local_var_req_builder = local_var_req_builder.json(&get_existing_issued_document_totals_request);
290
291 let local_var_req = local_var_req_builder.build()?;
292 let local_var_resp = local_var_client.execute(local_var_req).await?;
293
294 let local_var_status = local_var_resp.status();
295 let local_var_content = local_var_resp.text().await?;
296
297 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
298 serde_json::from_str(&local_var_content).map_err(Error::from)
299 } else {
300 let local_var_entity: Option<GetExistingIssuedDocumentTotalsError> = serde_json::from_str(&local_var_content).ok();
301 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
302 Err(Error::ResponseError(local_var_error))
303 }
304}
305
306pub async fn get_issued_document(configuration: &configuration::Configuration, company_id: i32, document_id: i32, fields: Option<&str>, fieldset: Option<&str>) -> Result<models::GetIssuedDocumentResponse, Error<GetIssuedDocumentError>> {
308 let local_var_configuration = configuration;
309
310 let local_var_client = &local_var_configuration.client;
311
312 let local_var_uri_str = format!("{}/c/{company_id}/issued_documents/{document_id}", local_var_configuration.base_path, company_id=company_id, document_id=document_id);
313 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
314
315 if let Some(ref local_var_str) = fields {
316 local_var_req_builder = local_var_req_builder.query(&[("fields", &local_var_str.to_string())]);
317 }
318 if let Some(ref local_var_str) = fieldset {
319 local_var_req_builder = local_var_req_builder.query(&[("fieldset", &local_var_str.to_string())]);
320 }
321 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
322 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
323 }
324 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
325 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
326 };
327 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
328 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
329 };
330
331 let local_var_req = local_var_req_builder.build()?;
332 let local_var_resp = local_var_client.execute(local_var_req).await?;
333
334 let local_var_status = local_var_resp.status();
335 let local_var_content = local_var_resp.text().await?;
336
337 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
338 serde_json::from_str(&local_var_content).map_err(Error::from)
339 } else {
340 let local_var_entity: Option<GetIssuedDocumentError> = serde_json::from_str(&local_var_content).ok();
341 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
342 Err(Error::ResponseError(local_var_error))
343 }
344}
345
346pub async fn get_issued_document_pre_create_info(configuration: &configuration::Configuration, company_id: i32, r#type: &str) -> Result<models::GetIssuedDocumentPreCreateInfoResponse, Error<GetIssuedDocumentPreCreateInfoError>> {
348 let local_var_configuration = configuration;
349
350 let local_var_client = &local_var_configuration.client;
351
352 let local_var_uri_str = format!("{}/c/{company_id}/issued_documents/info", local_var_configuration.base_path, company_id=company_id);
353 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
354
355 local_var_req_builder = local_var_req_builder.query(&[("type", &r#type.to_string())]);
356 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
357 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
358 }
359 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
360 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
361 };
362 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
363 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
364 };
365
366 let local_var_req = local_var_req_builder.build()?;
367 let local_var_resp = local_var_client.execute(local_var_req).await?;
368
369 let local_var_status = local_var_resp.status();
370 let local_var_content = local_var_resp.text().await?;
371
372 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
373 serde_json::from_str(&local_var_content).map_err(Error::from)
374 } else {
375 let local_var_entity: Option<GetIssuedDocumentPreCreateInfoError> = serde_json::from_str(&local_var_content).ok();
376 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
377 Err(Error::ResponseError(local_var_error))
378 }
379}
380
381pub async fn get_new_issued_document_totals(configuration: &configuration::Configuration, company_id: i32, get_new_issued_document_totals_request: Option<models::GetNewIssuedDocumentTotalsRequest>) -> Result<models::GetNewIssuedDocumentTotalsResponse, Error<GetNewIssuedDocumentTotalsError>> {
383 let local_var_configuration = configuration;
384
385 let local_var_client = &local_var_configuration.client;
386
387 let local_var_uri_str = format!("{}/c/{company_id}/issued_documents/totals", local_var_configuration.base_path, company_id=company_id);
388 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
389
390 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
391 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
392 }
393 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
394 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
395 };
396 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
397 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
398 };
399 local_var_req_builder = local_var_req_builder.json(&get_new_issued_document_totals_request);
400
401 let local_var_req = local_var_req_builder.build()?;
402 let local_var_resp = local_var_client.execute(local_var_req).await?;
403
404 let local_var_status = local_var_resp.status();
405 let local_var_content = local_var_resp.text().await?;
406
407 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
408 serde_json::from_str(&local_var_content).map_err(Error::from)
409 } else {
410 let local_var_entity: Option<GetNewIssuedDocumentTotalsError> = serde_json::from_str(&local_var_content).ok();
411 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
412 Err(Error::ResponseError(local_var_error))
413 }
414}
415
416pub async fn join_issued_documents(configuration: &configuration::Configuration, company_id: i32, ids: &str, group: Option<i32>, e_invoice: Option<i32>) -> Result<models::JoinIssuedDocumentsResponse, Error<JoinIssuedDocumentsError>> {
418 let local_var_configuration = configuration;
419
420 let local_var_client = &local_var_configuration.client;
421
422 let local_var_uri_str = format!("{}/c/{company_id}/issued_documents/join", local_var_configuration.base_path, company_id=company_id);
423 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
424
425 local_var_req_builder = local_var_req_builder.query(&[("ids", &ids.to_string())]);
426 if let Some(ref local_var_str) = group {
427 local_var_req_builder = local_var_req_builder.query(&[("group", &local_var_str.to_string())]);
428 }
429 if let Some(ref local_var_str) = e_invoice {
430 local_var_req_builder = local_var_req_builder.query(&[("e_invoice", &local_var_str.to_string())]);
431 }
432 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
433 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
434 }
435 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
436 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
437 };
438 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
439 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
440 };
441
442 let local_var_req = local_var_req_builder.build()?;
443 let local_var_resp = local_var_client.execute(local_var_req).await?;
444
445 let local_var_status = local_var_resp.status();
446 let local_var_content = local_var_resp.text().await?;
447
448 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
449 serde_json::from_str(&local_var_content).map_err(Error::from)
450 } else {
451 let local_var_entity: Option<JoinIssuedDocumentsError> = serde_json::from_str(&local_var_content).ok();
452 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
453 Err(Error::ResponseError(local_var_error))
454 }
455}
456
457pub async fn list_issued_documents(configuration: &configuration::Configuration, company_id: i32, r#type: &str, fields: Option<&str>, fieldset: Option<&str>, sort: Option<&str>, page: Option<i32>, per_page: Option<u8>, q: Option<&str>, inclusive: Option<i32>) -> Result<models::ListIssuedDocumentsResponse, Error<ListIssuedDocumentsError>> {
459 let local_var_configuration = configuration;
460
461 let local_var_client = &local_var_configuration.client;
462
463 let local_var_uri_str = format!("{}/c/{company_id}/issued_documents", local_var_configuration.base_path, company_id=company_id);
464 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
465
466 local_var_req_builder = local_var_req_builder.query(&[("type", &r#type.to_string())]);
467 if let Some(ref local_var_str) = fields {
468 local_var_req_builder = local_var_req_builder.query(&[("fields", &local_var_str.to_string())]);
469 }
470 if let Some(ref local_var_str) = fieldset {
471 local_var_req_builder = local_var_req_builder.query(&[("fieldset", &local_var_str.to_string())]);
472 }
473 if let Some(ref local_var_str) = sort {
474 local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
475 }
476 if let Some(ref local_var_str) = page {
477 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
478 }
479 if let Some(ref local_var_str) = per_page {
480 local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
481 }
482 if let Some(ref local_var_str) = q {
483 local_var_req_builder = local_var_req_builder.query(&[("q", &local_var_str.to_string())]);
484 }
485 if let Some(ref local_var_str) = inclusive {
486 local_var_req_builder = local_var_req_builder.query(&[("inclusive", &local_var_str.to_string())]);
487 }
488 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
489 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
490 }
491 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
492 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
493 };
494 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
495 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
496 };
497
498 let local_var_req = local_var_req_builder.build()?;
499 let local_var_resp = local_var_client.execute(local_var_req).await?;
500
501 let local_var_status = local_var_resp.status();
502 let local_var_content = local_var_resp.text().await?;
503
504 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
505 serde_json::from_str(&local_var_content).map_err(Error::from)
506 } else {
507 let local_var_entity: Option<ListIssuedDocumentsError> = serde_json::from_str(&local_var_content).ok();
508 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
509 Err(Error::ResponseError(local_var_error))
510 }
511}
512
513pub async fn modify_issued_document(configuration: &configuration::Configuration, company_id: i32, document_id: i32, modify_issued_document_request: Option<models::ModifyIssuedDocumentRequest>) -> Result<models::ModifyIssuedDocumentResponse, Error<ModifyIssuedDocumentError>> {
515 let local_var_configuration = configuration;
516
517 let local_var_client = &local_var_configuration.client;
518
519 let local_var_uri_str = format!("{}/c/{company_id}/issued_documents/{document_id}", local_var_configuration.base_path, company_id=company_id, document_id=document_id);
520 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
521
522 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
523 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
524 }
525 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
526 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
527 };
528 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
529 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
530 };
531 local_var_req_builder = local_var_req_builder.json(&modify_issued_document_request);
532
533 let local_var_req = local_var_req_builder.build()?;
534 let local_var_resp = local_var_client.execute(local_var_req).await?;
535
536 let local_var_status = local_var_resp.status();
537 let local_var_content = local_var_resp.text().await?;
538
539 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
540 serde_json::from_str(&local_var_content).map_err(Error::from)
541 } else {
542 let local_var_entity: Option<ModifyIssuedDocumentError> = serde_json::from_str(&local_var_content).ok();
543 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
544 Err(Error::ResponseError(local_var_error))
545 }
546}
547
548pub async fn schedule_email(configuration: &configuration::Configuration, company_id: i32, document_id: i32, schedule_email_request: Option<models::ScheduleEmailRequest>) -> Result<(), Error<ScheduleEmailError>> {
550 let local_var_configuration = configuration;
551
552 let local_var_client = &local_var_configuration.client;
553
554 let local_var_uri_str = format!("{}/c/{company_id}/issued_documents/{document_id}/email", local_var_configuration.base_path, company_id=company_id, document_id=document_id);
555 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
556
557 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
558 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
559 }
560 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
561 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
562 };
563 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
564 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
565 };
566 local_var_req_builder = local_var_req_builder.json(&schedule_email_request);
567
568 let local_var_req = local_var_req_builder.build()?;
569 let local_var_resp = local_var_client.execute(local_var_req).await?;
570
571 let local_var_status = local_var_resp.status();
572 let local_var_content = local_var_resp.text().await?;
573
574 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
575 Ok(())
576 } else {
577 let local_var_entity: Option<ScheduleEmailError> = serde_json::from_str(&local_var_content).ok();
578 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
579 Err(Error::ResponseError(local_var_error))
580 }
581}
582
583pub async fn transform_issued_document(configuration: &configuration::Configuration, company_id: i32, original_document_id: i32, new_type: &str, e_invoice: Option<i32>, transform_keep_copy: Option<i32>) -> Result<models::TransformIssuedDocumentResponse, Error<TransformIssuedDocumentError>> {
585 let local_var_configuration = configuration;
586
587 let local_var_client = &local_var_configuration.client;
588
589 let local_var_uri_str = format!("{}/c/{company_id}/issued_documents/transform", local_var_configuration.base_path, company_id=company_id);
590 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
591
592 local_var_req_builder = local_var_req_builder.query(&[("original_document_id", &original_document_id.to_string())]);
593 local_var_req_builder = local_var_req_builder.query(&[("new_type", &new_type.to_string())]);
594 if let Some(ref local_var_str) = e_invoice {
595 local_var_req_builder = local_var_req_builder.query(&[("e_invoice", &local_var_str.to_string())]);
596 }
597 if let Some(ref local_var_str) = transform_keep_copy {
598 local_var_req_builder = local_var_req_builder.query(&[("transform_keep_copy", &local_var_str.to_string())]);
599 }
600 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
601 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
602 }
603 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
604 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
605 };
606 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
607 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
608 };
609
610 let local_var_req = local_var_req_builder.build()?;
611 let local_var_resp = local_var_client.execute(local_var_req).await?;
612
613 let local_var_status = local_var_resp.status();
614 let local_var_content = local_var_resp.text().await?;
615
616 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
617 serde_json::from_str(&local_var_content).map_err(Error::from)
618 } else {
619 let local_var_entity: Option<TransformIssuedDocumentError> = serde_json::from_str(&local_var_content).ok();
620 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
621 Err(Error::ResponseError(local_var_error))
622 }
623}
624
625pub async fn upload_issued_document_attachment(configuration: &configuration::Configuration, company_id: i32, filename: Option<&str>, attachment: Option<std::path::PathBuf>) -> Result<models::UploadIssuedDocumentAttachmentResponse, Error<UploadIssuedDocumentAttachmentError>> {
627 let local_var_configuration = configuration;
628
629 let local_var_client = &local_var_configuration.client;
630
631 let local_var_uri_str = format!("{}/c/{company_id}/issued_documents/attachment", local_var_configuration.base_path, company_id=company_id);
632 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
633
634 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
635 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
636 }
637 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
638 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
639 };
640 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
641 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
642 };
643 let mut local_var_form = reqwest::multipart::Form::new();
644 if let Some(local_var_param_value) = filename {
645 local_var_form = local_var_form.text("filename", local_var_param_value.to_string());
646 }
647 local_var_req_builder = local_var_req_builder.multipart(local_var_form);
649
650 let local_var_req = local_var_req_builder.build()?;
651 let local_var_resp = local_var_client.execute(local_var_req).await?;
652
653 let local_var_status = local_var_resp.status();
654 let local_var_content = local_var_resp.text().await?;
655
656 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
657 serde_json::from_str(&local_var_content).map_err(Error::from)
658 } else {
659 let local_var_entity: Option<UploadIssuedDocumentAttachmentError> = serde_json::from_str(&local_var_content).ok();
660 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
661 Err(Error::ResponseError(local_var_error))
662 }
663}
664