Skip to main content

bitwarden_api_api/apis/
sends_api.rs

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