1use std::sync::Arc;
12
13use async_trait::async_trait;
14#[cfg(feature = "mockall")]
15use mockall::automock;
16use reqwest;
17use serde::{Deserialize, Serialize, de::Error as _};
18
19use super::{Error, configuration};
20use crate::{
21 apis::{ContentType, ResponseContent},
22 models,
23};
24
25#[cfg_attr(feature = "mockall", automock)]
26#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
27#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
28pub trait SendsApi: Send + Sync {
29 async fn access<'a>(
31 &self,
32 id: &'a str,
33 send_access_request_model: Option<models::SendAccessRequestModel>,
34 ) -> Result<(), Error<AccessError>>;
35
36 async fn azure_validate_file(&self) -> Result<(), Error<AzureValidateFileError>>;
38
39 async fn delete<'a>(&self, id: &'a str) -> Result<(), Error<DeleteError>>;
41
42 async fn get<'a>(&self, id: &'a str) -> Result<models::SendResponseModel, Error<GetError>>;
44
45 async fn get_all(
47 &self,
48 ) -> Result<models::SendResponseModelListResponseModel, Error<GetAllError>>;
49
50 async fn get_send_file_download_data<'a>(
52 &self,
53 encoded_send_id: &'a str,
54 file_id: &'a str,
55 send_access_request_model: Option<models::SendAccessRequestModel>,
56 ) -> Result<(), Error<GetSendFileDownloadDataError>>;
57
58 async fn post<'a>(
60 &self,
61 send_request_model: Option<models::SendRequestModel>,
62 ) -> Result<models::SendResponseModel, Error<PostError>>;
63
64 async fn post_file<'a>(
66 &self,
67 send_request_model: Option<models::SendRequestModel>,
68 ) -> Result<models::SendFileUploadDataResponseModel, Error<PostFileError>>;
69
70 async fn post_file_for_existing_send<'a>(
72 &self,
73 id: &'a str,
74 file_id: &'a str,
75 ) -> Result<(), Error<PostFileForExistingSendError>>;
76
77 async fn put<'a>(
79 &self,
80 id: &'a str,
81 send_request_model: Option<models::SendRequestModel>,
82 ) -> Result<models::SendResponseModel, Error<PutError>>;
83
84 async fn put_remove_password<'a>(
86 &self,
87 id: &'a str,
88 ) -> Result<models::SendResponseModel, Error<PutRemovePasswordError>>;
89
90 async fn renew_file_upload<'a>(
92 &self,
93 id: &'a str,
94 file_id: &'a str,
95 ) -> Result<models::SendFileUploadDataResponseModel, Error<RenewFileUploadError>>;
96}
97
98pub struct SendsApiClient {
99 configuration: Arc<configuration::Configuration>,
100}
101
102impl SendsApiClient {
103 pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
104 Self { configuration }
105 }
106}
107
108#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
109#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
110impl SendsApi for SendsApiClient {
111 async fn access<'a>(
112 &self,
113 id: &'a str,
114 send_access_request_model: Option<models::SendAccessRequestModel>,
115 ) -> Result<(), Error<AccessError>> {
116 let local_var_configuration = &self.configuration;
117
118 let local_var_client = &local_var_configuration.client;
119
120 let local_var_uri_str = format!(
121 "{}/sends/access/{id}",
122 local_var_configuration.base_path,
123 id = crate::apis::urlencode(id)
124 );
125 let mut local_var_req_builder =
126 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
127
128 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
129 local_var_req_builder = local_var_req_builder
130 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
131 }
132 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
133 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
134 };
135 local_var_req_builder = local_var_req_builder.json(&send_access_request_model);
136
137 let local_var_req = local_var_req_builder.build()?;
138 let local_var_resp = local_var_client.execute(local_var_req).await?;
139
140 let local_var_status = local_var_resp.status();
141 let local_var_content = local_var_resp.text().await?;
142
143 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
144 Ok(())
145 } else {
146 let local_var_entity: Option<AccessError> =
147 serde_json::from_str(&local_var_content).ok();
148 let local_var_error = ResponseContent {
149 status: local_var_status,
150 content: local_var_content,
151 entity: local_var_entity,
152 };
153 Err(Error::ResponseError(local_var_error))
154 }
155 }
156
157 async fn azure_validate_file(&self) -> Result<(), Error<AzureValidateFileError>> {
158 let local_var_configuration = &self.configuration;
159
160 let local_var_client = &local_var_configuration.client;
161
162 let local_var_uri_str = format!(
163 "{}/sends/file/validate/azure",
164 local_var_configuration.base_path
165 );
166 let mut local_var_req_builder =
167 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
168
169 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
170 local_var_req_builder = local_var_req_builder
171 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
172 }
173 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
174 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
175 };
176
177 let local_var_req = local_var_req_builder.build()?;
178 let local_var_resp = local_var_client.execute(local_var_req).await?;
179
180 let local_var_status = local_var_resp.status();
181 let local_var_content = local_var_resp.text().await?;
182
183 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
184 Ok(())
185 } else {
186 let local_var_entity: Option<AzureValidateFileError> =
187 serde_json::from_str(&local_var_content).ok();
188 let local_var_error = ResponseContent {
189 status: local_var_status,
190 content: local_var_content,
191 entity: local_var_entity,
192 };
193 Err(Error::ResponseError(local_var_error))
194 }
195 }
196
197 async fn delete<'a>(&self, id: &'a str) -> Result<(), Error<DeleteError>> {
198 let local_var_configuration = &self.configuration;
199
200 let local_var_client = &local_var_configuration.client;
201
202 let local_var_uri_str = format!(
203 "{}/sends/{id}",
204 local_var_configuration.base_path,
205 id = crate::apis::urlencode(id)
206 );
207 let mut local_var_req_builder =
208 local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
209
210 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
211 local_var_req_builder = local_var_req_builder
212 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
213 }
214 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
215 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
216 };
217
218 let local_var_req = local_var_req_builder.build()?;
219 let local_var_resp = local_var_client.execute(local_var_req).await?;
220
221 let local_var_status = local_var_resp.status();
222 let local_var_content = local_var_resp.text().await?;
223
224 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
225 Ok(())
226 } else {
227 let local_var_entity: Option<DeleteError> =
228 serde_json::from_str(&local_var_content).ok();
229 let local_var_error = ResponseContent {
230 status: local_var_status,
231 content: local_var_content,
232 entity: local_var_entity,
233 };
234 Err(Error::ResponseError(local_var_error))
235 }
236 }
237
238 async fn get<'a>(&self, id: &'a str) -> Result<models::SendResponseModel, Error<GetError>> {
239 let local_var_configuration = &self.configuration;
240
241 let local_var_client = &local_var_configuration.client;
242
243 let local_var_uri_str = format!(
244 "{}/sends/{id}",
245 local_var_configuration.base_path,
246 id = crate::apis::urlencode(id)
247 );
248 let mut local_var_req_builder =
249 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
250
251 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
252 local_var_req_builder = local_var_req_builder
253 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
254 }
255 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
256 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
257 };
258
259 let local_var_req = local_var_req_builder.build()?;
260 let local_var_resp = local_var_client.execute(local_var_req).await?;
261
262 let local_var_status = local_var_resp.status();
263 let local_var_content_type = local_var_resp
264 .headers()
265 .get("content-type")
266 .and_then(|v| v.to_str().ok())
267 .unwrap_or("application/octet-stream");
268 let local_var_content_type = super::ContentType::from(local_var_content_type);
269 let local_var_content = local_var_resp.text().await?;
270
271 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
272 match local_var_content_type {
273 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
274 ContentType::Text => {
275 return Err(Error::from(serde_json::Error::custom(
276 "Received `text/plain` content type response that cannot be converted to `models::SendResponseModel`",
277 )));
278 }
279 ContentType::Unsupported(local_var_unknown_type) => {
280 return Err(Error::from(serde_json::Error::custom(format!(
281 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SendResponseModel`"
282 ))));
283 }
284 }
285 } else {
286 let local_var_entity: Option<GetError> = serde_json::from_str(&local_var_content).ok();
287 let local_var_error = ResponseContent {
288 status: local_var_status,
289 content: local_var_content,
290 entity: local_var_entity,
291 };
292 Err(Error::ResponseError(local_var_error))
293 }
294 }
295
296 async fn get_all(
297 &self,
298 ) -> Result<models::SendResponseModelListResponseModel, Error<GetAllError>> {
299 let local_var_configuration = &self.configuration;
300
301 let local_var_client = &local_var_configuration.client;
302
303 let local_var_uri_str = format!("{}/sends", local_var_configuration.base_path);
304 let mut local_var_req_builder =
305 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
306
307 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
308 local_var_req_builder = local_var_req_builder
309 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
310 }
311 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
312 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
313 };
314
315 let local_var_req = local_var_req_builder.build()?;
316 let local_var_resp = local_var_client.execute(local_var_req).await?;
317
318 let local_var_status = local_var_resp.status();
319 let local_var_content_type = local_var_resp
320 .headers()
321 .get("content-type")
322 .and_then(|v| v.to_str().ok())
323 .unwrap_or("application/octet-stream");
324 let local_var_content_type = super::ContentType::from(local_var_content_type);
325 let local_var_content = local_var_resp.text().await?;
326
327 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
328 match local_var_content_type {
329 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
330 ContentType::Text => {
331 return Err(Error::from(serde_json::Error::custom(
332 "Received `text/plain` content type response that cannot be converted to `models::SendResponseModelListResponseModel`",
333 )));
334 }
335 ContentType::Unsupported(local_var_unknown_type) => {
336 return Err(Error::from(serde_json::Error::custom(format!(
337 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SendResponseModelListResponseModel`"
338 ))));
339 }
340 }
341 } else {
342 let local_var_entity: Option<GetAllError> =
343 serde_json::from_str(&local_var_content).ok();
344 let local_var_error = ResponseContent {
345 status: local_var_status,
346 content: local_var_content,
347 entity: local_var_entity,
348 };
349 Err(Error::ResponseError(local_var_error))
350 }
351 }
352
353 async fn get_send_file_download_data<'a>(
354 &self,
355 encoded_send_id: &'a str,
356 file_id: &'a str,
357 send_access_request_model: Option<models::SendAccessRequestModel>,
358 ) -> Result<(), Error<GetSendFileDownloadDataError>> {
359 let local_var_configuration = &self.configuration;
360
361 let local_var_client = &local_var_configuration.client;
362
363 let local_var_uri_str = format!(
364 "{}/sends/{encodedSendId}/access/file/{fileId}",
365 local_var_configuration.base_path,
366 encodedSendId = crate::apis::urlencode(encoded_send_id),
367 fileId = crate::apis::urlencode(file_id)
368 );
369 let mut local_var_req_builder =
370 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
371
372 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
373 local_var_req_builder = local_var_req_builder
374 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
375 }
376 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
377 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
378 };
379 local_var_req_builder = local_var_req_builder.json(&send_access_request_model);
380
381 let local_var_req = local_var_req_builder.build()?;
382 let local_var_resp = local_var_client.execute(local_var_req).await?;
383
384 let local_var_status = local_var_resp.status();
385 let local_var_content = local_var_resp.text().await?;
386
387 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
388 Ok(())
389 } else {
390 let local_var_entity: Option<GetSendFileDownloadDataError> =
391 serde_json::from_str(&local_var_content).ok();
392 let local_var_error = ResponseContent {
393 status: local_var_status,
394 content: local_var_content,
395 entity: local_var_entity,
396 };
397 Err(Error::ResponseError(local_var_error))
398 }
399 }
400
401 async fn post<'a>(
402 &self,
403 send_request_model: Option<models::SendRequestModel>,
404 ) -> Result<models::SendResponseModel, Error<PostError>> {
405 let local_var_configuration = &self.configuration;
406
407 let local_var_client = &local_var_configuration.client;
408
409 let local_var_uri_str = format!("{}/sends", local_var_configuration.base_path);
410 let mut local_var_req_builder =
411 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
412
413 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
414 local_var_req_builder = local_var_req_builder
415 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
416 }
417 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
418 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
419 };
420 local_var_req_builder = local_var_req_builder.json(&send_request_model);
421
422 let local_var_req = local_var_req_builder.build()?;
423 let local_var_resp = local_var_client.execute(local_var_req).await?;
424
425 let local_var_status = local_var_resp.status();
426 let local_var_content_type = local_var_resp
427 .headers()
428 .get("content-type")
429 .and_then(|v| v.to_str().ok())
430 .unwrap_or("application/octet-stream");
431 let local_var_content_type = super::ContentType::from(local_var_content_type);
432 let local_var_content = local_var_resp.text().await?;
433
434 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
435 match local_var_content_type {
436 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
437 ContentType::Text => {
438 return Err(Error::from(serde_json::Error::custom(
439 "Received `text/plain` content type response that cannot be converted to `models::SendResponseModel`",
440 )));
441 }
442 ContentType::Unsupported(local_var_unknown_type) => {
443 return Err(Error::from(serde_json::Error::custom(format!(
444 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SendResponseModel`"
445 ))));
446 }
447 }
448 } else {
449 let local_var_entity: Option<PostError> = serde_json::from_str(&local_var_content).ok();
450 let local_var_error = ResponseContent {
451 status: local_var_status,
452 content: local_var_content,
453 entity: local_var_entity,
454 };
455 Err(Error::ResponseError(local_var_error))
456 }
457 }
458
459 async fn post_file<'a>(
460 &self,
461 send_request_model: Option<models::SendRequestModel>,
462 ) -> Result<models::SendFileUploadDataResponseModel, Error<PostFileError>> {
463 let local_var_configuration = &self.configuration;
464
465 let local_var_client = &local_var_configuration.client;
466
467 let local_var_uri_str = format!("{}/sends/file/v2", local_var_configuration.base_path);
468 let mut local_var_req_builder =
469 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
470
471 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
472 local_var_req_builder = local_var_req_builder
473 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
474 }
475 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
476 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
477 };
478 local_var_req_builder = local_var_req_builder.json(&send_request_model);
479
480 let local_var_req = local_var_req_builder.build()?;
481 let local_var_resp = local_var_client.execute(local_var_req).await?;
482
483 let local_var_status = local_var_resp.status();
484 let local_var_content_type = local_var_resp
485 .headers()
486 .get("content-type")
487 .and_then(|v| v.to_str().ok())
488 .unwrap_or("application/octet-stream");
489 let local_var_content_type = super::ContentType::from(local_var_content_type);
490 let local_var_content = local_var_resp.text().await?;
491
492 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
493 match local_var_content_type {
494 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
495 ContentType::Text => {
496 return Err(Error::from(serde_json::Error::custom(
497 "Received `text/plain` content type response that cannot be converted to `models::SendFileUploadDataResponseModel`",
498 )));
499 }
500 ContentType::Unsupported(local_var_unknown_type) => {
501 return Err(Error::from(serde_json::Error::custom(format!(
502 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SendFileUploadDataResponseModel`"
503 ))));
504 }
505 }
506 } else {
507 let local_var_entity: Option<PostFileError> =
508 serde_json::from_str(&local_var_content).ok();
509 let local_var_error = ResponseContent {
510 status: local_var_status,
511 content: local_var_content,
512 entity: local_var_entity,
513 };
514 Err(Error::ResponseError(local_var_error))
515 }
516 }
517
518 async fn post_file_for_existing_send<'a>(
519 &self,
520 id: &'a str,
521 file_id: &'a str,
522 ) -> Result<(), Error<PostFileForExistingSendError>> {
523 let local_var_configuration = &self.configuration;
524
525 let local_var_client = &local_var_configuration.client;
526
527 let local_var_uri_str = format!(
528 "{}/sends/{id}/file/{fileId}",
529 local_var_configuration.base_path,
530 id = crate::apis::urlencode(id),
531 fileId = crate::apis::urlencode(file_id)
532 );
533 let mut local_var_req_builder =
534 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
535
536 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
537 local_var_req_builder = local_var_req_builder
538 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
539 }
540 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
541 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
542 };
543
544 let local_var_req = local_var_req_builder.build()?;
545 let local_var_resp = local_var_client.execute(local_var_req).await?;
546
547 let local_var_status = local_var_resp.status();
548 let local_var_content = local_var_resp.text().await?;
549
550 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
551 Ok(())
552 } else {
553 let local_var_entity: Option<PostFileForExistingSendError> =
554 serde_json::from_str(&local_var_content).ok();
555 let local_var_error = ResponseContent {
556 status: local_var_status,
557 content: local_var_content,
558 entity: local_var_entity,
559 };
560 Err(Error::ResponseError(local_var_error))
561 }
562 }
563
564 async fn put<'a>(
565 &self,
566 id: &'a str,
567 send_request_model: Option<models::SendRequestModel>,
568 ) -> Result<models::SendResponseModel, Error<PutError>> {
569 let local_var_configuration = &self.configuration;
570
571 let local_var_client = &local_var_configuration.client;
572
573 let local_var_uri_str = format!(
574 "{}/sends/{id}",
575 local_var_configuration.base_path,
576 id = crate::apis::urlencode(id)
577 );
578 let mut local_var_req_builder =
579 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
580
581 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
582 local_var_req_builder = local_var_req_builder
583 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
584 }
585 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
586 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
587 };
588 local_var_req_builder = local_var_req_builder.json(&send_request_model);
589
590 let local_var_req = local_var_req_builder.build()?;
591 let local_var_resp = local_var_client.execute(local_var_req).await?;
592
593 let local_var_status = local_var_resp.status();
594 let local_var_content_type = local_var_resp
595 .headers()
596 .get("content-type")
597 .and_then(|v| v.to_str().ok())
598 .unwrap_or("application/octet-stream");
599 let local_var_content_type = super::ContentType::from(local_var_content_type);
600 let local_var_content = local_var_resp.text().await?;
601
602 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
603 match local_var_content_type {
604 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
605 ContentType::Text => {
606 return Err(Error::from(serde_json::Error::custom(
607 "Received `text/plain` content type response that cannot be converted to `models::SendResponseModel`",
608 )));
609 }
610 ContentType::Unsupported(local_var_unknown_type) => {
611 return Err(Error::from(serde_json::Error::custom(format!(
612 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SendResponseModel`"
613 ))));
614 }
615 }
616 } else {
617 let local_var_entity: Option<PutError> = serde_json::from_str(&local_var_content).ok();
618 let local_var_error = ResponseContent {
619 status: local_var_status,
620 content: local_var_content,
621 entity: local_var_entity,
622 };
623 Err(Error::ResponseError(local_var_error))
624 }
625 }
626
627 async fn put_remove_password<'a>(
628 &self,
629 id: &'a str,
630 ) -> Result<models::SendResponseModel, Error<PutRemovePasswordError>> {
631 let local_var_configuration = &self.configuration;
632
633 let local_var_client = &local_var_configuration.client;
634
635 let local_var_uri_str = format!(
636 "{}/sends/{id}/remove-password",
637 local_var_configuration.base_path,
638 id = crate::apis::urlencode(id)
639 );
640 let mut local_var_req_builder =
641 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
642
643 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
644 local_var_req_builder = local_var_req_builder
645 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
646 }
647 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
648 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
649 };
650
651 let local_var_req = local_var_req_builder.build()?;
652 let local_var_resp = local_var_client.execute(local_var_req).await?;
653
654 let local_var_status = local_var_resp.status();
655 let local_var_content_type = local_var_resp
656 .headers()
657 .get("content-type")
658 .and_then(|v| v.to_str().ok())
659 .unwrap_or("application/octet-stream");
660 let local_var_content_type = super::ContentType::from(local_var_content_type);
661 let local_var_content = local_var_resp.text().await?;
662
663 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
664 match local_var_content_type {
665 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
666 ContentType::Text => {
667 return Err(Error::from(serde_json::Error::custom(
668 "Received `text/plain` content type response that cannot be converted to `models::SendResponseModel`",
669 )));
670 }
671 ContentType::Unsupported(local_var_unknown_type) => {
672 return Err(Error::from(serde_json::Error::custom(format!(
673 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SendResponseModel`"
674 ))));
675 }
676 }
677 } else {
678 let local_var_entity: Option<PutRemovePasswordError> =
679 serde_json::from_str(&local_var_content).ok();
680 let local_var_error = ResponseContent {
681 status: local_var_status,
682 content: local_var_content,
683 entity: local_var_entity,
684 };
685 Err(Error::ResponseError(local_var_error))
686 }
687 }
688
689 async fn renew_file_upload<'a>(
690 &self,
691 id: &'a str,
692 file_id: &'a str,
693 ) -> Result<models::SendFileUploadDataResponseModel, Error<RenewFileUploadError>> {
694 let local_var_configuration = &self.configuration;
695
696 let local_var_client = &local_var_configuration.client;
697
698 let local_var_uri_str = format!(
699 "{}/sends/{id}/file/{fileId}",
700 local_var_configuration.base_path,
701 id = crate::apis::urlencode(id),
702 fileId = crate::apis::urlencode(file_id)
703 );
704 let mut local_var_req_builder =
705 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
706
707 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
708 local_var_req_builder = local_var_req_builder
709 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
710 }
711 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
712 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
713 };
714
715 let local_var_req = local_var_req_builder.build()?;
716 let local_var_resp = local_var_client.execute(local_var_req).await?;
717
718 let local_var_status = local_var_resp.status();
719 let local_var_content_type = local_var_resp
720 .headers()
721 .get("content-type")
722 .and_then(|v| v.to_str().ok())
723 .unwrap_or("application/octet-stream");
724 let local_var_content_type = super::ContentType::from(local_var_content_type);
725 let local_var_content = local_var_resp.text().await?;
726
727 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
728 match local_var_content_type {
729 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
730 ContentType::Text => {
731 return Err(Error::from(serde_json::Error::custom(
732 "Received `text/plain` content type response that cannot be converted to `models::SendFileUploadDataResponseModel`",
733 )));
734 }
735 ContentType::Unsupported(local_var_unknown_type) => {
736 return Err(Error::from(serde_json::Error::custom(format!(
737 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SendFileUploadDataResponseModel`"
738 ))));
739 }
740 }
741 } else {
742 let local_var_entity: Option<RenewFileUploadError> =
743 serde_json::from_str(&local_var_content).ok();
744 let local_var_error = ResponseContent {
745 status: local_var_status,
746 content: local_var_content,
747 entity: local_var_entity,
748 };
749 Err(Error::ResponseError(local_var_error))
750 }
751 }
752}
753
754#[derive(Debug, Clone, Serialize, Deserialize)]
756#[serde(untagged)]
757pub enum AccessError {
758 UnknownValue(serde_json::Value),
759}
760#[derive(Debug, Clone, Serialize, Deserialize)]
762#[serde(untagged)]
763pub enum AzureValidateFileError {
764 UnknownValue(serde_json::Value),
765}
766#[derive(Debug, Clone, Serialize, Deserialize)]
768#[serde(untagged)]
769pub enum DeleteError {
770 UnknownValue(serde_json::Value),
771}
772#[derive(Debug, Clone, Serialize, Deserialize)]
774#[serde(untagged)]
775pub enum GetError {
776 UnknownValue(serde_json::Value),
777}
778#[derive(Debug, Clone, Serialize, Deserialize)]
780#[serde(untagged)]
781pub enum GetAllError {
782 UnknownValue(serde_json::Value),
783}
784#[derive(Debug, Clone, Serialize, Deserialize)]
786#[serde(untagged)]
787pub enum GetSendFileDownloadDataError {
788 UnknownValue(serde_json::Value),
789}
790#[derive(Debug, Clone, Serialize, Deserialize)]
792#[serde(untagged)]
793pub enum PostError {
794 UnknownValue(serde_json::Value),
795}
796#[derive(Debug, Clone, Serialize, Deserialize)]
798#[serde(untagged)]
799pub enum PostFileError {
800 UnknownValue(serde_json::Value),
801}
802#[derive(Debug, Clone, Serialize, Deserialize)]
804#[serde(untagged)]
805pub enum PostFileForExistingSendError {
806 UnknownValue(serde_json::Value),
807}
808#[derive(Debug, Clone, Serialize, Deserialize)]
810#[serde(untagged)]
811pub enum PutError {
812 UnknownValue(serde_json::Value),
813}
814#[derive(Debug, Clone, Serialize, Deserialize)]
816#[serde(untagged)]
817pub enum PutRemovePasswordError {
818 UnknownValue(serde_json::Value),
819}
820#[derive(Debug, Clone, Serialize, Deserialize)]
822#[serde(untagged)]
823pub enum RenewFileUploadError {
824 UnknownValue(serde_json::Value),
825}