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        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
144            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
145        };
146        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
147        local_var_req_builder = local_var_req_builder.json(&send_access_request_model);
148
149        let local_var_req = local_var_req_builder.build()?;
150        let local_var_resp = local_var_client.execute(local_var_req).await?;
151
152        let local_var_status = local_var_resp.status();
153        let local_var_content = local_var_resp.text().await?;
154
155        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
156            Ok(())
157        } else {
158            let local_var_entity: Option<AccessError> =
159                serde_json::from_str(&local_var_content).ok();
160            let local_var_error = ResponseContent {
161                status: local_var_status,
162                content: local_var_content,
163                entity: local_var_entity,
164            };
165            Err(Error::ResponseError(local_var_error))
166        }
167    }
168
169    async fn access_using_auth(&self) -> Result<(), Error<AccessUsingAuthError>> {
170        let local_var_configuration = &self.configuration;
171
172        let local_var_client = &local_var_configuration.client;
173
174        let local_var_uri_str = format!("{}/sends/access", local_var_configuration.base_path);
175        let mut local_var_req_builder =
176            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
177
178        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
179            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
180        };
181        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
182
183        let local_var_req = local_var_req_builder.build()?;
184        let local_var_resp = local_var_client.execute(local_var_req).await?;
185
186        let local_var_status = local_var_resp.status();
187        let local_var_content = local_var_resp.text().await?;
188
189        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
190            Ok(())
191        } else {
192            let local_var_entity: Option<AccessUsingAuthError> =
193                serde_json::from_str(&local_var_content).ok();
194            let local_var_error = ResponseContent {
195                status: local_var_status,
196                content: local_var_content,
197                entity: local_var_entity,
198            };
199            Err(Error::ResponseError(local_var_error))
200        }
201    }
202
203    async fn azure_validate_file(&self) -> Result<(), Error<AzureValidateFileError>> {
204        let local_var_configuration = &self.configuration;
205
206        let local_var_client = &local_var_configuration.client;
207
208        let local_var_uri_str = format!(
209            "{}/sends/file/validate/azure",
210            local_var_configuration.base_path
211        );
212        let mut local_var_req_builder =
213            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
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        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
219
220        let local_var_req = local_var_req_builder.build()?;
221        let local_var_resp = local_var_client.execute(local_var_req).await?;
222
223        let local_var_status = local_var_resp.status();
224        let local_var_content = local_var_resp.text().await?;
225
226        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
227            Ok(())
228        } else {
229            let local_var_entity: Option<AzureValidateFileError> =
230                serde_json::from_str(&local_var_content).ok();
231            let local_var_error = ResponseContent {
232                status: local_var_status,
233                content: local_var_content,
234                entity: local_var_entity,
235            };
236            Err(Error::ResponseError(local_var_error))
237        }
238    }
239
240    async fn delete<'a>(&self, id: &'a str) -> Result<(), Error<DeleteError>> {
241        let local_var_configuration = &self.configuration;
242
243        let local_var_client = &local_var_configuration.client;
244
245        let local_var_uri_str = format!(
246            "{}/sends/{id}",
247            local_var_configuration.base_path,
248            id = crate::apis::urlencode(id)
249        );
250        let mut local_var_req_builder =
251            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
252
253        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
254            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
255        };
256        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
257
258        let local_var_req = local_var_req_builder.build()?;
259        let local_var_resp = local_var_client.execute(local_var_req).await?;
260
261        let local_var_status = local_var_resp.status();
262        let local_var_content = local_var_resp.text().await?;
263
264        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
265            Ok(())
266        } else {
267            let local_var_entity: Option<DeleteError> =
268                serde_json::from_str(&local_var_content).ok();
269            let local_var_error = ResponseContent {
270                status: local_var_status,
271                content: local_var_content,
272                entity: local_var_entity,
273            };
274            Err(Error::ResponseError(local_var_error))
275        }
276    }
277
278    async fn get<'a>(&self, id: &'a str) -> Result<models::SendResponseModel, Error<GetError>> {
279        let local_var_configuration = &self.configuration;
280
281        let local_var_client = &local_var_configuration.client;
282
283        let local_var_uri_str = format!(
284            "{}/sends/{id}",
285            local_var_configuration.base_path,
286            id = crate::apis::urlencode(id)
287        );
288        let mut local_var_req_builder =
289            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
290
291        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
292            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
293        };
294        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
295
296        let local_var_req = local_var_req_builder.build()?;
297        let local_var_resp = local_var_client.execute(local_var_req).await?;
298
299        let local_var_status = local_var_resp.status();
300        let local_var_content_type = local_var_resp
301            .headers()
302            .get("content-type")
303            .and_then(|v| v.to_str().ok())
304            .unwrap_or("application/octet-stream");
305        let local_var_content_type = super::ContentType::from(local_var_content_type);
306        let local_var_content = local_var_resp.text().await?;
307
308        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
309            match local_var_content_type {
310                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
311                ContentType::Text => {
312                    return Err(Error::from(serde_json::Error::custom(
313                        "Received `text/plain` content type response that cannot be converted to `models::SendResponseModel`",
314                    )));
315                }
316                ContentType::Unsupported(local_var_unknown_type) => {
317                    return Err(Error::from(serde_json::Error::custom(format!(
318                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SendResponseModel`"
319                    ))));
320                }
321            }
322        } else {
323            let local_var_entity: Option<GetError> = serde_json::from_str(&local_var_content).ok();
324            let local_var_error = ResponseContent {
325                status: local_var_status,
326                content: local_var_content,
327                entity: local_var_entity,
328            };
329            Err(Error::ResponseError(local_var_error))
330        }
331    }
332
333    async fn get_all(
334        &self,
335    ) -> Result<models::SendResponseModelListResponseModel, Error<GetAllError>> {
336        let local_var_configuration = &self.configuration;
337
338        let local_var_client = &local_var_configuration.client;
339
340        let local_var_uri_str = format!("{}/sends", local_var_configuration.base_path);
341        let mut local_var_req_builder =
342            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
343
344        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
345            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
346        };
347        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
348
349        let local_var_req = local_var_req_builder.build()?;
350        let local_var_resp = local_var_client.execute(local_var_req).await?;
351
352        let local_var_status = local_var_resp.status();
353        let local_var_content_type = local_var_resp
354            .headers()
355            .get("content-type")
356            .and_then(|v| v.to_str().ok())
357            .unwrap_or("application/octet-stream");
358        let local_var_content_type = super::ContentType::from(local_var_content_type);
359        let local_var_content = local_var_resp.text().await?;
360
361        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
362            match local_var_content_type {
363                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
364                ContentType::Text => {
365                    return Err(Error::from(serde_json::Error::custom(
366                        "Received `text/plain` content type response that cannot be converted to `models::SendResponseModelListResponseModel`",
367                    )));
368                }
369                ContentType::Unsupported(local_var_unknown_type) => {
370                    return Err(Error::from(serde_json::Error::custom(format!(
371                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SendResponseModelListResponseModel`"
372                    ))));
373                }
374            }
375        } else {
376            let local_var_entity: Option<GetAllError> =
377                serde_json::from_str(&local_var_content).ok();
378            let local_var_error = ResponseContent {
379                status: local_var_status,
380                content: local_var_content,
381                entity: local_var_entity,
382            };
383            Err(Error::ResponseError(local_var_error))
384        }
385    }
386
387    async fn get_send_file_download_data<'a>(
388        &self,
389        encoded_send_id: &'a str,
390        file_id: &'a str,
391        send_access_request_model: Option<models::SendAccessRequestModel>,
392    ) -> Result<(), Error<GetSendFileDownloadDataError>> {
393        let local_var_configuration = &self.configuration;
394
395        let local_var_client = &local_var_configuration.client;
396
397        let local_var_uri_str = format!(
398            "{}/sends/{encodedSendId}/access/file/{fileId}",
399            local_var_configuration.base_path,
400            encodedSendId = crate::apis::urlencode(encoded_send_id),
401            fileId = crate::apis::urlencode(file_id)
402        );
403        let mut local_var_req_builder =
404            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
405
406        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
407            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
408        };
409        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
410        local_var_req_builder = local_var_req_builder.json(&send_access_request_model);
411
412        let local_var_req = local_var_req_builder.build()?;
413        let local_var_resp = local_var_client.execute(local_var_req).await?;
414
415        let local_var_status = local_var_resp.status();
416        let local_var_content = local_var_resp.text().await?;
417
418        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
419            Ok(())
420        } else {
421            let local_var_entity: Option<GetSendFileDownloadDataError> =
422                serde_json::from_str(&local_var_content).ok();
423            let local_var_error = ResponseContent {
424                status: local_var_status,
425                content: local_var_content,
426                entity: local_var_entity,
427            };
428            Err(Error::ResponseError(local_var_error))
429        }
430    }
431
432    async fn get_send_file_download_data_using_auth<'a>(
433        &self,
434        file_id: &'a str,
435    ) -> Result<(), Error<GetSendFileDownloadDataUsingAuthError>> {
436        let local_var_configuration = &self.configuration;
437
438        let local_var_client = &local_var_configuration.client;
439
440        let local_var_uri_str = format!(
441            "{}/sends/access/file/{fileId}",
442            local_var_configuration.base_path,
443            fileId = crate::apis::urlencode(file_id)
444        );
445        let mut local_var_req_builder =
446            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
447
448        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
449            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
450        };
451        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
452
453        let local_var_req = local_var_req_builder.build()?;
454        let local_var_resp = local_var_client.execute(local_var_req).await?;
455
456        let local_var_status = local_var_resp.status();
457        let local_var_content = local_var_resp.text().await?;
458
459        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
460            Ok(())
461        } else {
462            let local_var_entity: Option<GetSendFileDownloadDataUsingAuthError> =
463                serde_json::from_str(&local_var_content).ok();
464            let local_var_error = ResponseContent {
465                status: local_var_status,
466                content: local_var_content,
467                entity: local_var_entity,
468            };
469            Err(Error::ResponseError(local_var_error))
470        }
471    }
472
473    async fn post<'a>(
474        &self,
475        send_request_model: Option<models::SendRequestModel>,
476    ) -> Result<models::SendResponseModel, Error<PostError>> {
477        let local_var_configuration = &self.configuration;
478
479        let local_var_client = &local_var_configuration.client;
480
481        let local_var_uri_str = format!("{}/sends", local_var_configuration.base_path);
482        let mut local_var_req_builder =
483            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
484
485        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
486            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
487        };
488        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
489        local_var_req_builder = local_var_req_builder.json(&send_request_model);
490
491        let local_var_req = local_var_req_builder.build()?;
492        let local_var_resp = local_var_client.execute(local_var_req).await?;
493
494        let local_var_status = local_var_resp.status();
495        let local_var_content_type = local_var_resp
496            .headers()
497            .get("content-type")
498            .and_then(|v| v.to_str().ok())
499            .unwrap_or("application/octet-stream");
500        let local_var_content_type = super::ContentType::from(local_var_content_type);
501        let local_var_content = local_var_resp.text().await?;
502
503        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
504            match local_var_content_type {
505                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
506                ContentType::Text => {
507                    return Err(Error::from(serde_json::Error::custom(
508                        "Received `text/plain` content type response that cannot be converted to `models::SendResponseModel`",
509                    )));
510                }
511                ContentType::Unsupported(local_var_unknown_type) => {
512                    return Err(Error::from(serde_json::Error::custom(format!(
513                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SendResponseModel`"
514                    ))));
515                }
516            }
517        } else {
518            let local_var_entity: Option<PostError> = serde_json::from_str(&local_var_content).ok();
519            let local_var_error = ResponseContent {
520                status: local_var_status,
521                content: local_var_content,
522                entity: local_var_entity,
523            };
524            Err(Error::ResponseError(local_var_error))
525        }
526    }
527
528    async fn post_file<'a>(
529        &self,
530        send_request_model: Option<models::SendRequestModel>,
531    ) -> Result<models::SendFileUploadDataResponseModel, Error<PostFileError>> {
532        let local_var_configuration = &self.configuration;
533
534        let local_var_client = &local_var_configuration.client;
535
536        let local_var_uri_str = format!("{}/sends/file/v2", local_var_configuration.base_path);
537        let mut local_var_req_builder =
538            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
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        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
544        local_var_req_builder = local_var_req_builder.json(&send_request_model);
545
546        let local_var_req = local_var_req_builder.build()?;
547        let local_var_resp = local_var_client.execute(local_var_req).await?;
548
549        let local_var_status = local_var_resp.status();
550        let local_var_content_type = local_var_resp
551            .headers()
552            .get("content-type")
553            .and_then(|v| v.to_str().ok())
554            .unwrap_or("application/octet-stream");
555        let local_var_content_type = super::ContentType::from(local_var_content_type);
556        let local_var_content = local_var_resp.text().await?;
557
558        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
559            match local_var_content_type {
560                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
561                ContentType::Text => {
562                    return Err(Error::from(serde_json::Error::custom(
563                        "Received `text/plain` content type response that cannot be converted to `models::SendFileUploadDataResponseModel`",
564                    )));
565                }
566                ContentType::Unsupported(local_var_unknown_type) => {
567                    return Err(Error::from(serde_json::Error::custom(format!(
568                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SendFileUploadDataResponseModel`"
569                    ))));
570                }
571            }
572        } else {
573            let local_var_entity: Option<PostFileError> =
574                serde_json::from_str(&local_var_content).ok();
575            let local_var_error = ResponseContent {
576                status: local_var_status,
577                content: local_var_content,
578                entity: local_var_entity,
579            };
580            Err(Error::ResponseError(local_var_error))
581        }
582    }
583
584    async fn post_file_for_existing_send<'a>(
585        &self,
586        id: &'a str,
587        file_id: &'a str,
588    ) -> Result<(), Error<PostFileForExistingSendError>> {
589        let local_var_configuration = &self.configuration;
590
591        let local_var_client = &local_var_configuration.client;
592
593        let local_var_uri_str = format!(
594            "{}/sends/{id}/file/{fileId}",
595            local_var_configuration.base_path,
596            id = crate::apis::urlencode(id),
597            fileId = crate::apis::urlencode(file_id)
598        );
599        let mut local_var_req_builder =
600            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
601
602        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
603            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
604        };
605        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
606
607        let local_var_req = local_var_req_builder.build()?;
608        let local_var_resp = local_var_client.execute(local_var_req).await?;
609
610        let local_var_status = local_var_resp.status();
611        let local_var_content = local_var_resp.text().await?;
612
613        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
614            Ok(())
615        } else {
616            let local_var_entity: Option<PostFileForExistingSendError> =
617                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<'a>(
628        &self,
629        id: &'a str,
630        send_request_model: Option<models::SendRequestModel>,
631    ) -> Result<models::SendResponseModel, Error<PutError>> {
632        let local_var_configuration = &self.configuration;
633
634        let local_var_client = &local_var_configuration.client;
635
636        let local_var_uri_str = format!(
637            "{}/sends/{id}",
638            local_var_configuration.base_path,
639            id = crate::apis::urlencode(id)
640        );
641        let mut local_var_req_builder =
642            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
643
644        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
645            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
646        };
647        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
648        local_var_req_builder = local_var_req_builder.json(&send_request_model);
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_type = local_var_resp
655            .headers()
656            .get("content-type")
657            .and_then(|v| v.to_str().ok())
658            .unwrap_or("application/octet-stream");
659        let local_var_content_type = super::ContentType::from(local_var_content_type);
660        let local_var_content = local_var_resp.text().await?;
661
662        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
663            match local_var_content_type {
664                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
665                ContentType::Text => {
666                    return Err(Error::from(serde_json::Error::custom(
667                        "Received `text/plain` content type response that cannot be converted to `models::SendResponseModel`",
668                    )));
669                }
670                ContentType::Unsupported(local_var_unknown_type) => {
671                    return Err(Error::from(serde_json::Error::custom(format!(
672                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SendResponseModel`"
673                    ))));
674                }
675            }
676        } else {
677            let local_var_entity: Option<PutError> = serde_json::from_str(&local_var_content).ok();
678            let local_var_error = ResponseContent {
679                status: local_var_status,
680                content: local_var_content,
681                entity: local_var_entity,
682            };
683            Err(Error::ResponseError(local_var_error))
684        }
685    }
686
687    async fn put_remove_auth<'a>(
688        &self,
689        id: &'a str,
690    ) -> Result<models::SendResponseModel, Error<PutRemoveAuthError>> {
691        let local_var_configuration = &self.configuration;
692
693        let local_var_client = &local_var_configuration.client;
694
695        let local_var_uri_str = format!(
696            "{}/sends/{id}/remove-auth",
697            local_var_configuration.base_path,
698            id = crate::apis::urlencode(id)
699        );
700        let mut local_var_req_builder =
701            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
702
703        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
704            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
705        };
706        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
707
708        let local_var_req = local_var_req_builder.build()?;
709        let local_var_resp = local_var_client.execute(local_var_req).await?;
710
711        let local_var_status = local_var_resp.status();
712        let local_var_content_type = local_var_resp
713            .headers()
714            .get("content-type")
715            .and_then(|v| v.to_str().ok())
716            .unwrap_or("application/octet-stream");
717        let local_var_content_type = super::ContentType::from(local_var_content_type);
718        let local_var_content = local_var_resp.text().await?;
719
720        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
721            match local_var_content_type {
722                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
723                ContentType::Text => {
724                    return Err(Error::from(serde_json::Error::custom(
725                        "Received `text/plain` content type response that cannot be converted to `models::SendResponseModel`",
726                    )));
727                }
728                ContentType::Unsupported(local_var_unknown_type) => {
729                    return Err(Error::from(serde_json::Error::custom(format!(
730                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SendResponseModel`"
731                    ))));
732                }
733            }
734        } else {
735            let local_var_entity: Option<PutRemoveAuthError> =
736                serde_json::from_str(&local_var_content).ok();
737            let local_var_error = ResponseContent {
738                status: local_var_status,
739                content: local_var_content,
740                entity: local_var_entity,
741            };
742            Err(Error::ResponseError(local_var_error))
743        }
744    }
745
746    async fn put_remove_password<'a>(
747        &self,
748        id: &'a str,
749    ) -> Result<models::SendResponseModel, Error<PutRemovePasswordError>> {
750        let local_var_configuration = &self.configuration;
751
752        let local_var_client = &local_var_configuration.client;
753
754        let local_var_uri_str = format!(
755            "{}/sends/{id}/remove-password",
756            local_var_configuration.base_path,
757            id = crate::apis::urlencode(id)
758        );
759        let mut local_var_req_builder =
760            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
761
762        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
763            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
764        };
765        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
766
767        let local_var_req = local_var_req_builder.build()?;
768        let local_var_resp = local_var_client.execute(local_var_req).await?;
769
770        let local_var_status = local_var_resp.status();
771        let local_var_content_type = local_var_resp
772            .headers()
773            .get("content-type")
774            .and_then(|v| v.to_str().ok())
775            .unwrap_or("application/octet-stream");
776        let local_var_content_type = super::ContentType::from(local_var_content_type);
777        let local_var_content = local_var_resp.text().await?;
778
779        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
780            match local_var_content_type {
781                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
782                ContentType::Text => {
783                    return Err(Error::from(serde_json::Error::custom(
784                        "Received `text/plain` content type response that cannot be converted to `models::SendResponseModel`",
785                    )));
786                }
787                ContentType::Unsupported(local_var_unknown_type) => {
788                    return Err(Error::from(serde_json::Error::custom(format!(
789                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SendResponseModel`"
790                    ))));
791                }
792            }
793        } else {
794            let local_var_entity: Option<PutRemovePasswordError> =
795                serde_json::from_str(&local_var_content).ok();
796            let local_var_error = ResponseContent {
797                status: local_var_status,
798                content: local_var_content,
799                entity: local_var_entity,
800            };
801            Err(Error::ResponseError(local_var_error))
802        }
803    }
804
805    async fn renew_file_upload<'a>(
806        &self,
807        id: &'a str,
808        file_id: &'a str,
809    ) -> Result<models::SendFileUploadDataResponseModel, Error<RenewFileUploadError>> {
810        let local_var_configuration = &self.configuration;
811
812        let local_var_client = &local_var_configuration.client;
813
814        let local_var_uri_str = format!(
815            "{}/sends/{id}/file/{fileId}",
816            local_var_configuration.base_path,
817            id = crate::apis::urlencode(id),
818            fileId = crate::apis::urlencode(file_id)
819        );
820        let mut local_var_req_builder =
821            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
822
823        if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
824            local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
825        };
826        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
827
828        let local_var_req = local_var_req_builder.build()?;
829        let local_var_resp = local_var_client.execute(local_var_req).await?;
830
831        let local_var_status = local_var_resp.status();
832        let local_var_content_type = local_var_resp
833            .headers()
834            .get("content-type")
835            .and_then(|v| v.to_str().ok())
836            .unwrap_or("application/octet-stream");
837        let local_var_content_type = super::ContentType::from(local_var_content_type);
838        let local_var_content = local_var_resp.text().await?;
839
840        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
841            match local_var_content_type {
842                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
843                ContentType::Text => {
844                    return Err(Error::from(serde_json::Error::custom(
845                        "Received `text/plain` content type response that cannot be converted to `models::SendFileUploadDataResponseModel`",
846                    )));
847                }
848                ContentType::Unsupported(local_var_unknown_type) => {
849                    return Err(Error::from(serde_json::Error::custom(format!(
850                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SendFileUploadDataResponseModel`"
851                    ))));
852                }
853            }
854        } else {
855            let local_var_entity: Option<RenewFileUploadError> =
856                serde_json::from_str(&local_var_content).ok();
857            let local_var_error = ResponseContent {
858                status: local_var_status,
859                content: local_var_content,
860                entity: local_var_entity,
861            };
862            Err(Error::ResponseError(local_var_error))
863        }
864    }
865}
866
867/// struct for typed errors of method [`SendsApi::access`]
868#[derive(Debug, Clone, Serialize, Deserialize)]
869#[serde(untagged)]
870pub enum AccessError {
871    UnknownValue(serde_json::Value),
872}
873/// struct for typed errors of method [`SendsApi::access_using_auth`]
874#[derive(Debug, Clone, Serialize, Deserialize)]
875#[serde(untagged)]
876pub enum AccessUsingAuthError {
877    UnknownValue(serde_json::Value),
878}
879/// struct for typed errors of method [`SendsApi::azure_validate_file`]
880#[derive(Debug, Clone, Serialize, Deserialize)]
881#[serde(untagged)]
882pub enum AzureValidateFileError {
883    UnknownValue(serde_json::Value),
884}
885/// struct for typed errors of method [`SendsApi::delete`]
886#[derive(Debug, Clone, Serialize, Deserialize)]
887#[serde(untagged)]
888pub enum DeleteError {
889    UnknownValue(serde_json::Value),
890}
891/// struct for typed errors of method [`SendsApi::get`]
892#[derive(Debug, Clone, Serialize, Deserialize)]
893#[serde(untagged)]
894pub enum GetError {
895    UnknownValue(serde_json::Value),
896}
897/// struct for typed errors of method [`SendsApi::get_all`]
898#[derive(Debug, Clone, Serialize, Deserialize)]
899#[serde(untagged)]
900pub enum GetAllError {
901    UnknownValue(serde_json::Value),
902}
903/// struct for typed errors of method [`SendsApi::get_send_file_download_data`]
904#[derive(Debug, Clone, Serialize, Deserialize)]
905#[serde(untagged)]
906pub enum GetSendFileDownloadDataError {
907    UnknownValue(serde_json::Value),
908}
909/// struct for typed errors of method [`SendsApi::get_send_file_download_data_using_auth`]
910#[derive(Debug, Clone, Serialize, Deserialize)]
911#[serde(untagged)]
912pub enum GetSendFileDownloadDataUsingAuthError {
913    UnknownValue(serde_json::Value),
914}
915/// struct for typed errors of method [`SendsApi::post`]
916#[derive(Debug, Clone, Serialize, Deserialize)]
917#[serde(untagged)]
918pub enum PostError {
919    UnknownValue(serde_json::Value),
920}
921/// struct for typed errors of method [`SendsApi::post_file`]
922#[derive(Debug, Clone, Serialize, Deserialize)]
923#[serde(untagged)]
924pub enum PostFileError {
925    UnknownValue(serde_json::Value),
926}
927/// struct for typed errors of method [`SendsApi::post_file_for_existing_send`]
928#[derive(Debug, Clone, Serialize, Deserialize)]
929#[serde(untagged)]
930pub enum PostFileForExistingSendError {
931    UnknownValue(serde_json::Value),
932}
933/// struct for typed errors of method [`SendsApi::put`]
934#[derive(Debug, Clone, Serialize, Deserialize)]
935#[serde(untagged)]
936pub enum PutError {
937    UnknownValue(serde_json::Value),
938}
939/// struct for typed errors of method [`SendsApi::put_remove_auth`]
940#[derive(Debug, Clone, Serialize, Deserialize)]
941#[serde(untagged)]
942pub enum PutRemoveAuthError {
943    UnknownValue(serde_json::Value),
944}
945/// struct for typed errors of method [`SendsApi::put_remove_password`]
946#[derive(Debug, Clone, Serialize, Deserialize)]
947#[serde(untagged)]
948pub enum PutRemovePasswordError {
949    UnknownValue(serde_json::Value),
950}
951/// struct for typed errors of method [`SendsApi::renew_file_upload`]
952#[derive(Debug, Clone, Serialize, Deserialize)]
953#[serde(untagged)]
954pub enum RenewFileUploadError {
955    UnknownValue(serde_json::Value),
956}