1use reqwest;
12use serde::{Deserialize, Serialize, de::Error as _};
13
14use super::{ContentType, Error, configuration};
15use crate::{apis::ResponseContent, models};
16
17#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum CreateDomainMailboxError {
21 Status400(models::GetFinances400Response),
22 Status401(models::GetFinances401Response),
23 Status403(models::GetAccountStatus403Response),
24 Status404(models::GetImage404Response),
25 Status429(models::GetFinances429Response),
26 Status500(models::GetFinances500Response),
27 UnknownValue(serde_json::Value)
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum CreateDomainMailboxV2Error {
34 Status400(models::GetFinances400Response),
35 Status401(models::GetFinances401Response),
36 Status403(models::GetAccountStatus403Response),
37 Status404(models::GetImage404Response),
38 Status409(models::CreateDatabaseBackup409Response),
39 Status429(models::GetFinances429Response),
40 Status500(models::GetFinances500Response),
41 UnknownValue(serde_json::Value)
42}
43
44#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum CreateMultipleDomainMailboxesError {
48 Status400(models::GetFinances400Response),
49 Status401(models::GetFinances401Response),
50 Status403(models::GetAccountStatus403Response),
51 Status404(models::GetImage404Response),
52 Status429(models::GetFinances429Response),
53 Status500(models::GetFinances500Response),
54 UnknownValue(serde_json::Value)
55}
56
57#[derive(Debug, Clone, Serialize, Deserialize)]
59#[serde(untagged)]
60pub enum CreateMultipleDomainMailboxesV2Error {
61 Status400(models::GetFinances400Response),
62 Status401(models::GetFinances401Response),
63 Status403(models::GetAccountStatus403Response),
64 Status404(models::GetImage404Response),
65 Status429(models::GetFinances429Response),
66 Status500(models::GetFinances500Response),
67 UnknownValue(serde_json::Value)
68}
69
70#[derive(Debug, Clone, Serialize, Deserialize)]
72#[serde(untagged)]
73pub enum DeleteMailboxError {
74 Status400(models::GetFinances400Response),
75 Status401(models::GetFinances401Response),
76 Status403(models::GetAccountStatus403Response),
77 Status404(models::GetImage404Response),
78 Status429(models::GetFinances429Response),
79 Status500(models::GetFinances500Response),
80 UnknownValue(serde_json::Value)
81}
82
83#[derive(Debug, Clone, Serialize, Deserialize)]
85#[serde(untagged)]
86pub enum GetAllMailboxesV2Error {
87 Status400(models::GetFinances400Response),
88 Status401(models::GetFinances401Response),
89 Status403(models::GetAccountStatus403Response),
90 Status429(models::GetFinances429Response),
91 Status500(models::GetFinances500Response),
92 UnknownValue(serde_json::Value)
93}
94
95#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum GetDomainMailInfoError {
99 Status400(models::GetFinances400Response),
100 Status401(models::GetFinances401Response),
101 Status403(models::GetAccountStatus403Response),
102 Status404(models::GetImage404Response),
103 Status429(models::GetFinances429Response),
104 Status500(models::GetFinances500Response),
105 UnknownValue(serde_json::Value)
106}
107
108#[derive(Debug, Clone, Serialize, Deserialize)]
110#[serde(untagged)]
111pub enum GetDomainMailboxesError {
112 Status400(models::GetFinances400Response),
113 Status401(models::GetFinances401Response),
114 Status403(models::GetAccountStatus403Response),
115 Status404(models::GetImage404Response),
116 Status429(models::GetFinances429Response),
117 Status500(models::GetFinances500Response),
118 UnknownValue(serde_json::Value)
119}
120
121#[derive(Debug, Clone, Serialize, Deserialize)]
123#[serde(untagged)]
124pub enum GetMailboxError {
125 Status400(models::GetFinances400Response),
126 Status401(models::GetFinances401Response),
127 Status403(models::GetAccountStatus403Response),
128 Status404(models::GetImage404Response),
129 Status429(models::GetFinances429Response),
130 Status500(models::GetFinances500Response),
131 UnknownValue(serde_json::Value)
132}
133
134#[derive(Debug, Clone, Serialize, Deserialize)]
136#[serde(untagged)]
137pub enum GetMailboxV2Error {
138 Status400(models::GetFinances400Response),
139 Status401(models::GetFinances401Response),
140 Status403(models::GetAccountStatus403Response),
141 Status404(models::GetImage404Response),
142 Status429(models::GetFinances429Response),
143 Status500(models::GetFinances500Response),
144 UnknownValue(serde_json::Value)
145}
146
147#[derive(Debug, Clone, Serialize, Deserialize)]
149#[serde(untagged)]
150pub enum GetMailboxesError {
151 Status400(models::GetFinances400Response),
152 Status401(models::GetFinances401Response),
153 Status403(models::GetAccountStatus403Response),
154 Status429(models::GetFinances429Response),
155 Status500(models::GetFinances500Response),
156 UnknownValue(serde_json::Value)
157}
158
159#[derive(Debug, Clone, Serialize, Deserialize)]
161#[serde(untagged)]
162pub enum UpdateDomainMailInfoError {
163 Status400(models::GetFinances400Response),
164 Status401(models::GetFinances401Response),
165 Status403(models::GetAccountStatus403Response),
166 Status404(models::GetImage404Response),
167 Status429(models::GetFinances429Response),
168 Status500(models::GetFinances500Response),
169 UnknownValue(serde_json::Value)
170}
171
172#[derive(Debug, Clone, Serialize, Deserialize)]
174#[serde(untagged)]
175pub enum UpdateMailboxError {
176 Status400(models::GetFinances400Response),
177 Status401(models::GetFinances401Response),
178 Status403(models::GetAccountStatus403Response),
179 Status404(models::GetImage404Response),
180 Status429(models::GetFinances429Response),
181 Status500(models::GetFinances500Response),
182 UnknownValue(serde_json::Value)
183}
184
185#[derive(Debug, Clone, Serialize, Deserialize)]
187#[serde(untagged)]
188pub enum UpdateMailboxV2Error {
189 Status400(models::GetFinances400Response),
190 Status401(models::GetFinances401Response),
191 Status404(models::GetImage404Response),
192 Status409(models::CreateDatabaseBackup409Response),
193 Status429(models::GetFinances429Response),
194 Status500(models::GetFinances500Response),
195 UnknownValue(serde_json::Value)
196}
197
198#[deprecated]
201pub async fn create_domain_mailbox(
202 configuration: &configuration::Configuration,
203 domain: &str,
204 create_domain_mailbox_request: models::CreateDomainMailboxRequest
205) -> Result<models::CreateDomainMailbox201Response, Error<CreateDomainMailboxError>> {
206 let p_path_domain = domain;
208 let p_body_create_domain_mailbox_request = create_domain_mailbox_request;
209
210 let uri_str = format!(
211 "{}/api/v1/mail/domains/{domain}",
212 configuration.base_path,
213 domain = crate::apis::urlencode(p_path_domain)
214 );
215 let mut req_builder = configuration
216 .client
217 .request(reqwest::Method::POST, &uri_str);
218
219 if let Some(ref user_agent) = configuration.user_agent {
220 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
221 }
222 if let Some(ref token) = configuration.bearer_access_token {
223 req_builder = req_builder.bearer_auth(token.to_owned());
224 };
225 req_builder = req_builder.json(&p_body_create_domain_mailbox_request);
226
227 let req = req_builder.build()?;
228 let resp = configuration.client.execute(req).await?;
229
230 let status = resp.status();
231 let content_type = resp
232 .headers()
233 .get("content-type")
234 .and_then(|v| v.to_str().ok())
235 .unwrap_or("application/octet-stream");
236 let content_type = super::ContentType::from(content_type);
237
238 if !status.is_client_error() && !status.is_server_error() {
239 let content = resp.text().await?;
240 match content_type {
241 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
242 ContentType::Text => {
243 return Err(Error::from(serde_json::Error::custom(
244 "Received `text/plain` content type response that cannot be converted to `models::CreateDomainMailbox201Response`"
245 )));
246 }
247 ContentType::Unsupported(unknown_type) => {
248 return Err(Error::from(serde_json::Error::custom(format!(
249 "Received `{unknown_type}` content type response that cannot be converted to `models::CreateDomainMailbox201Response`"
250 ))));
251 }
252 }
253 } else {
254 let content = resp.text().await?;
255 let entity: Option<CreateDomainMailboxError> = serde_json::from_str(&content).ok();
256 Err(Error::ResponseError(ResponseContent {
257 status,
258 content,
259 entity
260 }))
261 }
262}
263
264pub async fn create_domain_mailbox_v2(
267 configuration: &configuration::Configuration,
268 domain: &str,
269 create_domain_mailbox_v2_request: models::CreateDomainMailboxV2Request
270) -> Result<models::CreateDomainMailboxV2201Response, Error<CreateDomainMailboxV2Error>> {
271 let p_path_domain = domain;
273 let p_body_create_domain_mailbox_v2_request = create_domain_mailbox_v2_request;
274
275 let uri_str = format!(
276 "{}/api/v2/mail/domains/{domain}",
277 configuration.base_path,
278 domain = crate::apis::urlencode(p_path_domain)
279 );
280 let mut req_builder = configuration
281 .client
282 .request(reqwest::Method::POST, &uri_str);
283
284 if let Some(ref user_agent) = configuration.user_agent {
285 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
286 }
287 if let Some(ref token) = configuration.bearer_access_token {
288 req_builder = req_builder.bearer_auth(token.to_owned());
289 };
290 req_builder = req_builder.json(&p_body_create_domain_mailbox_v2_request);
291
292 let req = req_builder.build()?;
293 let resp = configuration.client.execute(req).await?;
294
295 let status = resp.status();
296 let content_type = resp
297 .headers()
298 .get("content-type")
299 .and_then(|v| v.to_str().ok())
300 .unwrap_or("application/octet-stream");
301 let content_type = super::ContentType::from(content_type);
302
303 if !status.is_client_error() && !status.is_server_error() {
304 let content = resp.text().await?;
305 match content_type {
306 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
307 ContentType::Text => {
308 return Err(Error::from(serde_json::Error::custom(
309 "Received `text/plain` content type response that cannot be converted to `models::CreateDomainMailboxV2201Response`"
310 )));
311 }
312 ContentType::Unsupported(unknown_type) => {
313 return Err(Error::from(serde_json::Error::custom(format!(
314 "Received `{unknown_type}` content type response that cannot be converted to `models::CreateDomainMailboxV2201Response`"
315 ))));
316 }
317 }
318 } else {
319 let content = resp.text().await?;
320 let entity: Option<CreateDomainMailboxV2Error> = serde_json::from_str(&content).ok();
321 Err(Error::ResponseError(ResponseContent {
322 status,
323 content,
324 entity
325 }))
326 }
327}
328
329#[deprecated]
332pub async fn create_multiple_domain_mailboxes(
333 configuration: &configuration::Configuration,
334 domain: &str,
335 create_multiple_domain_mailboxes_request: models::CreateMultipleDomainMailboxesRequest
336) -> Result<
337 models::CreateMultipleDomainMailboxes201Response,
338 Error<CreateMultipleDomainMailboxesError>
339> {
340 let p_path_domain = domain;
342 let p_body_create_multiple_domain_mailboxes_request = create_multiple_domain_mailboxes_request;
343
344 let uri_str = format!(
345 "{}/api/v1/mail/domains/{domain}/batch",
346 configuration.base_path,
347 domain = crate::apis::urlencode(p_path_domain)
348 );
349 let mut req_builder = configuration
350 .client
351 .request(reqwest::Method::POST, &uri_str);
352
353 if let Some(ref user_agent) = configuration.user_agent {
354 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
355 }
356 if let Some(ref token) = configuration.bearer_access_token {
357 req_builder = req_builder.bearer_auth(token.to_owned());
358 };
359 req_builder = req_builder.json(&p_body_create_multiple_domain_mailboxes_request);
360
361 let req = req_builder.build()?;
362 let resp = configuration.client.execute(req).await?;
363
364 let status = resp.status();
365 let content_type = resp
366 .headers()
367 .get("content-type")
368 .and_then(|v| v.to_str().ok())
369 .unwrap_or("application/octet-stream");
370 let content_type = super::ContentType::from(content_type);
371
372 if !status.is_client_error() && !status.is_server_error() {
373 let content = resp.text().await?;
374 match content_type {
375 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
376 ContentType::Text => {
377 return Err(Error::from(serde_json::Error::custom(
378 "Received `text/plain` content type response that cannot be converted to `models::CreateMultipleDomainMailboxes201Response`"
379 )));
380 }
381 ContentType::Unsupported(unknown_type) => {
382 return Err(Error::from(serde_json::Error::custom(format!(
383 "Received `{unknown_type}` content type response that cannot be converted to `models::CreateMultipleDomainMailboxes201Response`"
384 ))));
385 }
386 }
387 } else {
388 let content = resp.text().await?;
389 let entity: Option<CreateMultipleDomainMailboxesError> =
390 serde_json::from_str(&content).ok();
391 Err(Error::ResponseError(ResponseContent {
392 status,
393 content,
394 entity
395 }))
396 }
397}
398
399pub async fn create_multiple_domain_mailboxes_v2(
402 configuration: &configuration::Configuration,
403 domain: &str,
404 create_multiple_domain_mailboxes_v2_request_inner: Vec<
405 models::CreateMultipleDomainMailboxesV2RequestInner
406 >
407) -> Result<
408 models::CreateMultipleDomainMailboxesV2201Response,
409 Error<CreateMultipleDomainMailboxesV2Error>
410> {
411 let p_path_domain = domain;
413 let p_body_create_multiple_domain_mailboxes_v2_request_inner =
414 create_multiple_domain_mailboxes_v2_request_inner;
415
416 let uri_str = format!(
417 "{}/api/v2/mail/domains/{domain}/batch",
418 configuration.base_path,
419 domain = crate::apis::urlencode(p_path_domain)
420 );
421 let mut req_builder = configuration
422 .client
423 .request(reqwest::Method::POST, &uri_str);
424
425 if let Some(ref user_agent) = configuration.user_agent {
426 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
427 }
428 if let Some(ref token) = configuration.bearer_access_token {
429 req_builder = req_builder.bearer_auth(token.to_owned());
430 };
431 req_builder = req_builder.json(&p_body_create_multiple_domain_mailboxes_v2_request_inner);
432
433 let req = req_builder.build()?;
434 let resp = configuration.client.execute(req).await?;
435
436 let status = resp.status();
437 let content_type = resp
438 .headers()
439 .get("content-type")
440 .and_then(|v| v.to_str().ok())
441 .unwrap_or("application/octet-stream");
442 let content_type = super::ContentType::from(content_type);
443
444 if !status.is_client_error() && !status.is_server_error() {
445 let content = resp.text().await?;
446 match content_type {
447 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
448 ContentType::Text => {
449 return Err(Error::from(serde_json::Error::custom(
450 "Received `text/plain` content type response that cannot be converted to `models::CreateMultipleDomainMailboxesV2201Response`"
451 )));
452 }
453 ContentType::Unsupported(unknown_type) => {
454 return Err(Error::from(serde_json::Error::custom(format!(
455 "Received `{unknown_type}` content type response that cannot be converted to `models::CreateMultipleDomainMailboxesV2201Response`"
456 ))));
457 }
458 }
459 } else {
460 let content = resp.text().await?;
461 let entity: Option<CreateMultipleDomainMailboxesV2Error> =
462 serde_json::from_str(&content).ok();
463 Err(Error::ResponseError(ResponseContent {
464 status,
465 content,
466 entity
467 }))
468 }
469}
470
471pub async fn delete_mailbox(
474 configuration: &configuration::Configuration,
475 domain: &str,
476 mailbox: &str
477) -> Result<(), Error<DeleteMailboxError>> {
478 let p_path_domain = domain;
480 let p_path_mailbox = mailbox;
481
482 let uri_str = format!(
483 "{}/api/v1/mail/domains/{domain}/mailboxes/{mailbox}",
484 configuration.base_path,
485 domain = crate::apis::urlencode(p_path_domain),
486 mailbox = crate::apis::urlencode(p_path_mailbox)
487 );
488 let mut req_builder = configuration
489 .client
490 .request(reqwest::Method::DELETE, &uri_str);
491
492 if let Some(ref user_agent) = configuration.user_agent {
493 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
494 }
495 if let Some(ref token) = configuration.bearer_access_token {
496 req_builder = req_builder.bearer_auth(token.to_owned());
497 };
498
499 let req = req_builder.build()?;
500 let resp = configuration.client.execute(req).await?;
501
502 let status = resp.status();
503
504 if !status.is_client_error() && !status.is_server_error() {
505 Ok(())
506 } else {
507 let content = resp.text().await?;
508 let entity: Option<DeleteMailboxError> = serde_json::from_str(&content).ok();
509 Err(Error::ResponseError(ResponseContent {
510 status,
511 content,
512 entity
513 }))
514 }
515}
516
517pub async fn get_all_mailboxes_v2(
520 configuration: &configuration::Configuration,
521 limit: Option<i32>,
522 offset: Option<i32>,
523 search: Option<&str>
524) -> Result<models::GetAllMailboxesV2200Response, Error<GetAllMailboxesV2Error>> {
525 let p_query_limit = limit;
527 let p_query_offset = offset;
528 let p_query_search = search;
529
530 let uri_str = format!("{}/api/v2/mail", configuration.base_path);
531 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
532
533 if let Some(ref param_value) = p_query_limit {
534 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
535 }
536 if let Some(ref param_value) = p_query_offset {
537 req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
538 }
539 if let Some(ref param_value) = p_query_search {
540 req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
541 }
542 if let Some(ref user_agent) = configuration.user_agent {
543 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
544 }
545 if let Some(ref token) = configuration.bearer_access_token {
546 req_builder = req_builder.bearer_auth(token.to_owned());
547 };
548
549 let req = req_builder.build()?;
550 let resp = configuration.client.execute(req).await?;
551
552 let status = resp.status();
553 let content_type = resp
554 .headers()
555 .get("content-type")
556 .and_then(|v| v.to_str().ok())
557 .unwrap_or("application/octet-stream");
558 let content_type = super::ContentType::from(content_type);
559
560 if !status.is_client_error() && !status.is_server_error() {
561 let content = resp.text().await?;
562 match content_type {
563 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
564 ContentType::Text => {
565 return Err(Error::from(serde_json::Error::custom(
566 "Received `text/plain` content type response that cannot be converted to `models::GetAllMailboxesV2200Response`"
567 )));
568 }
569 ContentType::Unsupported(unknown_type) => {
570 return Err(Error::from(serde_json::Error::custom(format!(
571 "Received `{unknown_type}` content type response that cannot be converted to `models::GetAllMailboxesV2200Response`"
572 ))));
573 }
574 }
575 } else {
576 let content = resp.text().await?;
577 let entity: Option<GetAllMailboxesV2Error> = serde_json::from_str(&content).ok();
578 Err(Error::ResponseError(ResponseContent {
579 status,
580 content,
581 entity
582 }))
583 }
584}
585
586#[deprecated]
589pub async fn get_domain_mail_info(
590 configuration: &configuration::Configuration,
591 domain: &str
592) -> Result<models::GetDomainMailInfo200Response, Error<GetDomainMailInfoError>> {
593 let p_path_domain = domain;
595
596 let uri_str = format!(
597 "{}/api/v1/mail/domains/{domain}/info",
598 configuration.base_path,
599 domain = crate::apis::urlencode(p_path_domain)
600 );
601 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
602
603 if let Some(ref user_agent) = configuration.user_agent {
604 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
605 }
606 if let Some(ref token) = configuration.bearer_access_token {
607 req_builder = req_builder.bearer_auth(token.to_owned());
608 };
609
610 let req = req_builder.build()?;
611 let resp = configuration.client.execute(req).await?;
612
613 let status = resp.status();
614 let content_type = resp
615 .headers()
616 .get("content-type")
617 .and_then(|v| v.to_str().ok())
618 .unwrap_or("application/octet-stream");
619 let content_type = super::ContentType::from(content_type);
620
621 if !status.is_client_error() && !status.is_server_error() {
622 let content = resp.text().await?;
623 match content_type {
624 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
625 ContentType::Text => {
626 return Err(Error::from(serde_json::Error::custom(
627 "Received `text/plain` content type response that cannot be converted to `models::GetDomainMailInfo200Response`"
628 )));
629 }
630 ContentType::Unsupported(unknown_type) => {
631 return Err(Error::from(serde_json::Error::custom(format!(
632 "Received `{unknown_type}` content type response that cannot be converted to `models::GetDomainMailInfo200Response`"
633 ))));
634 }
635 }
636 } else {
637 let content = resp.text().await?;
638 let entity: Option<GetDomainMailInfoError> = serde_json::from_str(&content).ok();
639 Err(Error::ResponseError(ResponseContent {
640 status,
641 content,
642 entity
643 }))
644 }
645}
646
647pub async fn get_domain_mailboxes(
650 configuration: &configuration::Configuration,
651 domain: &str,
652 limit: Option<i32>,
653 offset: Option<i32>,
654 search: Option<&str>
655) -> Result<models::GetMailboxes200Response, Error<GetDomainMailboxesError>> {
656 let p_path_domain = domain;
658 let p_query_limit = limit;
659 let p_query_offset = offset;
660 let p_query_search = search;
661
662 let uri_str = format!(
663 "{}/api/v1/mail/domains/{domain}",
664 configuration.base_path,
665 domain = crate::apis::urlencode(p_path_domain)
666 );
667 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
668
669 if let Some(ref param_value) = p_query_limit {
670 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
671 }
672 if let Some(ref param_value) = p_query_offset {
673 req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
674 }
675 if let Some(ref param_value) = p_query_search {
676 req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
677 }
678 if let Some(ref user_agent) = configuration.user_agent {
679 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
680 }
681 if let Some(ref token) = configuration.bearer_access_token {
682 req_builder = req_builder.bearer_auth(token.to_owned());
683 };
684
685 let req = req_builder.build()?;
686 let resp = configuration.client.execute(req).await?;
687
688 let status = resp.status();
689 let content_type = resp
690 .headers()
691 .get("content-type")
692 .and_then(|v| v.to_str().ok())
693 .unwrap_or("application/octet-stream");
694 let content_type = super::ContentType::from(content_type);
695
696 if !status.is_client_error() && !status.is_server_error() {
697 let content = resp.text().await?;
698 match content_type {
699 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
700 ContentType::Text => {
701 return Err(Error::from(serde_json::Error::custom(
702 "Received `text/plain` content type response that cannot be converted to `models::GetMailboxes200Response`"
703 )));
704 }
705 ContentType::Unsupported(unknown_type) => {
706 return Err(Error::from(serde_json::Error::custom(format!(
707 "Received `{unknown_type}` content type response that cannot be converted to `models::GetMailboxes200Response`"
708 ))));
709 }
710 }
711 } else {
712 let content = resp.text().await?;
713 let entity: Option<GetDomainMailboxesError> = serde_json::from_str(&content).ok();
714 Err(Error::ResponseError(ResponseContent {
715 status,
716 content,
717 entity
718 }))
719 }
720}
721
722#[deprecated]
725pub async fn get_mailbox(
726 configuration: &configuration::Configuration,
727 domain: &str,
728 mailbox: &str
729) -> Result<models::CreateDomainMailbox201Response, Error<GetMailboxError>> {
730 let p_path_domain = domain;
732 let p_path_mailbox = mailbox;
733
734 let uri_str = format!(
735 "{}/api/v1/mail/domains/{domain}/mailboxes/{mailbox}",
736 configuration.base_path,
737 domain = crate::apis::urlencode(p_path_domain),
738 mailbox = crate::apis::urlencode(p_path_mailbox)
739 );
740 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
741
742 if let Some(ref user_agent) = configuration.user_agent {
743 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
744 }
745 if let Some(ref token) = configuration.bearer_access_token {
746 req_builder = req_builder.bearer_auth(token.to_owned());
747 };
748
749 let req = req_builder.build()?;
750 let resp = configuration.client.execute(req).await?;
751
752 let status = resp.status();
753 let content_type = resp
754 .headers()
755 .get("content-type")
756 .and_then(|v| v.to_str().ok())
757 .unwrap_or("application/octet-stream");
758 let content_type = super::ContentType::from(content_type);
759
760 if !status.is_client_error() && !status.is_server_error() {
761 let content = resp.text().await?;
762 match content_type {
763 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
764 ContentType::Text => {
765 return Err(Error::from(serde_json::Error::custom(
766 "Received `text/plain` content type response that cannot be converted to `models::CreateDomainMailbox201Response`"
767 )));
768 }
769 ContentType::Unsupported(unknown_type) => {
770 return Err(Error::from(serde_json::Error::custom(format!(
771 "Received `{unknown_type}` content type response that cannot be converted to `models::CreateDomainMailbox201Response`"
772 ))));
773 }
774 }
775 } else {
776 let content = resp.text().await?;
777 let entity: Option<GetMailboxError> = serde_json::from_str(&content).ok();
778 Err(Error::ResponseError(ResponseContent {
779 status,
780 content,
781 entity
782 }))
783 }
784}
785
786pub async fn get_mailbox_v2(
789 configuration: &configuration::Configuration,
790 domain: &str,
791 mailbox: &str
792) -> Result<models::CreateDomainMailboxV2201Response, Error<GetMailboxV2Error>> {
793 let p_path_domain = domain;
795 let p_path_mailbox = mailbox;
796
797 let uri_str = format!(
798 "{}/api/v2/mail/domains/{domain}/mailboxes/{mailbox}",
799 configuration.base_path,
800 domain = crate::apis::urlencode(p_path_domain),
801 mailbox = crate::apis::urlencode(p_path_mailbox)
802 );
803 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
804
805 if let Some(ref user_agent) = configuration.user_agent {
806 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
807 }
808 if let Some(ref token) = configuration.bearer_access_token {
809 req_builder = req_builder.bearer_auth(token.to_owned());
810 };
811
812 let req = req_builder.build()?;
813 let resp = configuration.client.execute(req).await?;
814
815 let status = resp.status();
816 let content_type = resp
817 .headers()
818 .get("content-type")
819 .and_then(|v| v.to_str().ok())
820 .unwrap_or("application/octet-stream");
821 let content_type = super::ContentType::from(content_type);
822
823 if !status.is_client_error() && !status.is_server_error() {
824 let content = resp.text().await?;
825 match content_type {
826 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
827 ContentType::Text => {
828 return Err(Error::from(serde_json::Error::custom(
829 "Received `text/plain` content type response that cannot be converted to `models::CreateDomainMailboxV2201Response`"
830 )));
831 }
832 ContentType::Unsupported(unknown_type) => {
833 return Err(Error::from(serde_json::Error::custom(format!(
834 "Received `{unknown_type}` content type response that cannot be converted to `models::CreateDomainMailboxV2201Response`"
835 ))));
836 }
837 }
838 } else {
839 let content = resp.text().await?;
840 let entity: Option<GetMailboxV2Error> = serde_json::from_str(&content).ok();
841 Err(Error::ResponseError(ResponseContent {
842 status,
843 content,
844 entity
845 }))
846 }
847}
848
849#[deprecated]
852pub async fn get_mailboxes(
853 configuration: &configuration::Configuration,
854 limit: Option<i32>,
855 offset: Option<i32>,
856 search: Option<&str>
857) -> Result<models::GetMailboxes200Response, Error<GetMailboxesError>> {
858 let p_query_limit = limit;
860 let p_query_offset = offset;
861 let p_query_search = search;
862
863 let uri_str = format!("{}/api/v1/mail", configuration.base_path);
864 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
865
866 if let Some(ref param_value) = p_query_limit {
867 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
868 }
869 if let Some(ref param_value) = p_query_offset {
870 req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
871 }
872 if let Some(ref param_value) = p_query_search {
873 req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
874 }
875 if let Some(ref user_agent) = configuration.user_agent {
876 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
877 }
878 if let Some(ref token) = configuration.bearer_access_token {
879 req_builder = req_builder.bearer_auth(token.to_owned());
880 };
881
882 let req = req_builder.build()?;
883 let resp = configuration.client.execute(req).await?;
884
885 let status = resp.status();
886 let content_type = resp
887 .headers()
888 .get("content-type")
889 .and_then(|v| v.to_str().ok())
890 .unwrap_or("application/octet-stream");
891 let content_type = super::ContentType::from(content_type);
892
893 if !status.is_client_error() && !status.is_server_error() {
894 let content = resp.text().await?;
895 match content_type {
896 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
897 ContentType::Text => {
898 return Err(Error::from(serde_json::Error::custom(
899 "Received `text/plain` content type response that cannot be converted to `models::GetMailboxes200Response`"
900 )));
901 }
902 ContentType::Unsupported(unknown_type) => {
903 return Err(Error::from(serde_json::Error::custom(format!(
904 "Received `{unknown_type}` content type response that cannot be converted to `models::GetMailboxes200Response`"
905 ))));
906 }
907 }
908 } else {
909 let content = resp.text().await?;
910 let entity: Option<GetMailboxesError> = serde_json::from_str(&content).ok();
911 Err(Error::ResponseError(ResponseContent {
912 status,
913 content,
914 entity
915 }))
916 }
917}
918
919#[deprecated]
922pub async fn update_domain_mail_info(
923 configuration: &configuration::Configuration,
924 domain: &str,
925 update_domain_mail_info_request: models::UpdateDomainMailInfoRequest
926) -> Result<models::GetDomainMailInfo200Response, Error<UpdateDomainMailInfoError>> {
927 let p_path_domain = domain;
929 let p_body_update_domain_mail_info_request = update_domain_mail_info_request;
930
931 let uri_str = format!(
932 "{}/api/v1/mail/domains/{domain}/info",
933 configuration.base_path,
934 domain = crate::apis::urlencode(p_path_domain)
935 );
936 let mut req_builder = configuration
937 .client
938 .request(reqwest::Method::PATCH, &uri_str);
939
940 if let Some(ref user_agent) = configuration.user_agent {
941 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
942 }
943 if let Some(ref token) = configuration.bearer_access_token {
944 req_builder = req_builder.bearer_auth(token.to_owned());
945 };
946 req_builder = req_builder.json(&p_body_update_domain_mail_info_request);
947
948 let req = req_builder.build()?;
949 let resp = configuration.client.execute(req).await?;
950
951 let status = resp.status();
952 let content_type = resp
953 .headers()
954 .get("content-type")
955 .and_then(|v| v.to_str().ok())
956 .unwrap_or("application/octet-stream");
957 let content_type = super::ContentType::from(content_type);
958
959 if !status.is_client_error() && !status.is_server_error() {
960 let content = resp.text().await?;
961 match content_type {
962 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
963 ContentType::Text => {
964 return Err(Error::from(serde_json::Error::custom(
965 "Received `text/plain` content type response that cannot be converted to `models::GetDomainMailInfo200Response`"
966 )));
967 }
968 ContentType::Unsupported(unknown_type) => {
969 return Err(Error::from(serde_json::Error::custom(format!(
970 "Received `{unknown_type}` content type response that cannot be converted to `models::GetDomainMailInfo200Response`"
971 ))));
972 }
973 }
974 } else {
975 let content = resp.text().await?;
976 let entity: Option<UpdateDomainMailInfoError> = serde_json::from_str(&content).ok();
977 Err(Error::ResponseError(ResponseContent {
978 status,
979 content,
980 entity
981 }))
982 }
983}
984
985#[deprecated]
988pub async fn update_mailbox(
989 configuration: &configuration::Configuration,
990 domain: &str,
991 mailbox: &str,
992 update_mailbox: models::UpdateMailbox
993) -> Result<models::CreateDomainMailbox201Response, Error<UpdateMailboxError>> {
994 let p_path_domain = domain;
996 let p_path_mailbox = mailbox;
997 let p_body_update_mailbox = update_mailbox;
998
999 let uri_str = format!(
1000 "{}/api/v1/mail/domains/{domain}/mailboxes/{mailbox}",
1001 configuration.base_path,
1002 domain = crate::apis::urlencode(p_path_domain),
1003 mailbox = crate::apis::urlencode(p_path_mailbox)
1004 );
1005 let mut req_builder = configuration
1006 .client
1007 .request(reqwest::Method::PATCH, &uri_str);
1008
1009 if let Some(ref user_agent) = configuration.user_agent {
1010 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1011 }
1012 if let Some(ref token) = configuration.bearer_access_token {
1013 req_builder = req_builder.bearer_auth(token.to_owned());
1014 };
1015 req_builder = req_builder.json(&p_body_update_mailbox);
1016
1017 let req = req_builder.build()?;
1018 let resp = configuration.client.execute(req).await?;
1019
1020 let status = resp.status();
1021 let content_type = resp
1022 .headers()
1023 .get("content-type")
1024 .and_then(|v| v.to_str().ok())
1025 .unwrap_or("application/octet-stream");
1026 let content_type = super::ContentType::from(content_type);
1027
1028 if !status.is_client_error() && !status.is_server_error() {
1029 let content = resp.text().await?;
1030 match content_type {
1031 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1032 ContentType::Text => {
1033 return Err(Error::from(serde_json::Error::custom(
1034 "Received `text/plain` content type response that cannot be converted to `models::CreateDomainMailbox201Response`"
1035 )));
1036 }
1037 ContentType::Unsupported(unknown_type) => {
1038 return Err(Error::from(serde_json::Error::custom(format!(
1039 "Received `{unknown_type}` content type response that cannot be converted to `models::CreateDomainMailbox201Response`"
1040 ))));
1041 }
1042 }
1043 } else {
1044 let content = resp.text().await?;
1045 let entity: Option<UpdateMailboxError> = serde_json::from_str(&content).ok();
1046 Err(Error::ResponseError(ResponseContent {
1047 status,
1048 content,
1049 entity
1050 }))
1051 }
1052}
1053
1054pub async fn update_mailbox_v2(
1057 configuration: &configuration::Configuration,
1058 domain: &str,
1059 mailbox: &str,
1060 update_mailbox_v2: models::UpdateMailboxV2
1061) -> Result<models::UpdateMailboxV2200Response, Error<UpdateMailboxV2Error>> {
1062 let p_path_domain = domain;
1064 let p_path_mailbox = mailbox;
1065 let p_body_update_mailbox_v2 = update_mailbox_v2;
1066
1067 let uri_str = format!(
1068 "{}/api/v2/mail/domains/{domain}/mailboxes/{mailbox}",
1069 configuration.base_path,
1070 domain = crate::apis::urlencode(p_path_domain),
1071 mailbox = crate::apis::urlencode(p_path_mailbox)
1072 );
1073 let mut req_builder = configuration
1074 .client
1075 .request(reqwest::Method::PATCH, &uri_str);
1076
1077 if let Some(ref user_agent) = configuration.user_agent {
1078 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1079 }
1080 if let Some(ref token) = configuration.bearer_access_token {
1081 req_builder = req_builder.bearer_auth(token.to_owned());
1082 };
1083 req_builder = req_builder.json(&p_body_update_mailbox_v2);
1084
1085 let req = req_builder.build()?;
1086 let resp = configuration.client.execute(req).await?;
1087
1088 let status = resp.status();
1089 let content_type = resp
1090 .headers()
1091 .get("content-type")
1092 .and_then(|v| v.to_str().ok())
1093 .unwrap_or("application/octet-stream");
1094 let content_type = super::ContentType::from(content_type);
1095
1096 if !status.is_client_error() && !status.is_server_error() {
1097 let content = resp.text().await?;
1098 match content_type {
1099 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1100 ContentType::Text => {
1101 return Err(Error::from(serde_json::Error::custom(
1102 "Received `text/plain` content type response that cannot be converted to `models::UpdateMailboxV2200Response`"
1103 )));
1104 }
1105 ContentType::Unsupported(unknown_type) => {
1106 return Err(Error::from(serde_json::Error::custom(format!(
1107 "Received `{unknown_type}` content type response that cannot be converted to `models::UpdateMailboxV2200Response`"
1108 ))));
1109 }
1110 }
1111 } else {
1112 let content = resp.text().await?;
1113 let entity: Option<UpdateMailboxV2Error> = serde_json::from_str(&content).ok();
1114 Err(Error::ResponseError(ResponseContent {
1115 status,
1116 content,
1117 entity
1118 }))
1119 }
1120}