1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum BulkArchiveEmailsError {
22 Status400(models::ApiError),
23 Status401(models::ApiError),
24 UnknownValue(serde_json::Value),
25}
26
27#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(untagged)]
30pub enum BulkDeleteEmailsError {
31 Status400(models::ApiError),
32 Status401(models::ApiError),
33 UnknownValue(serde_json::Value),
34}
35
36#[derive(Debug, Clone, Serialize, Deserialize)]
38#[serde(untagged)]
39pub enum BulkMarkEmailsReadError {
40 Status400(models::ApiError),
41 Status401(models::ApiError),
42 UnknownValue(serde_json::Value),
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum CreateDraftError {
49 Status400(models::CreateNote400Response),
50 Status401(models::ApiError),
51 UnknownValue(serde_json::Value),
52}
53
54#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum CreateEmailLabelError {
58 Status400(models::CreateNote400Response),
59 Status401(models::ApiError),
60 UnknownValue(serde_json::Value),
61}
62
63#[derive(Debug, Clone, Serialize, Deserialize)]
65#[serde(untagged)]
66pub enum CreateMailTemplateError {
67 Status401(models::ApiError),
68 UnknownValue(serde_json::Value),
69}
70
71#[derive(Debug, Clone, Serialize, Deserialize)]
73#[serde(untagged)]
74pub enum DeleteDraftError {
75 Status401(models::ApiError),
76 Status404(models::ApiError),
77 UnknownValue(serde_json::Value),
78}
79
80#[derive(Debug, Clone, Serialize, Deserialize)]
82#[serde(untagged)]
83pub enum DeleteEmailError {
84 Status401(models::ApiError),
85 Status404(models::ApiError),
86 UnknownValue(serde_json::Value),
87}
88
89#[derive(Debug, Clone, Serialize, Deserialize)]
91#[serde(untagged)]
92pub enum DeleteEmailLabelError {
93 Status401(models::ApiError),
94 Status404(models::ApiError),
95 UnknownValue(serde_json::Value),
96}
97
98#[derive(Debug, Clone, Serialize, Deserialize)]
100#[serde(untagged)]
101pub enum DeleteMailTemplateError {
102 Status401(models::ApiError),
103 UnknownValue(serde_json::Value),
104}
105
106#[derive(Debug, Clone, Serialize, Deserialize)]
108#[serde(untagged)]
109pub enum GetEmailError {
110 Status400(models::CreateNote400Response),
111 Status401(models::ApiError),
112 Status404(models::ApiError),
113 UnknownValue(serde_json::Value),
114}
115
116#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum GetEmailAttachmentError {
120 Status400(models::CreateNote400Response),
121 Status401(models::ApiError),
122 Status404(models::ApiError),
123 UnknownValue(serde_json::Value),
124}
125
126#[derive(Debug, Clone, Serialize, Deserialize)]
128#[serde(untagged)]
129pub enum GetEmailThreadError {
130 Status400(models::CreateNote400Response),
131 Status401(models::ApiError),
132 Status404(models::ApiError),
133 UnknownValue(serde_json::Value),
134}
135
136#[derive(Debug, Clone, Serialize, Deserialize)]
138#[serde(untagged)]
139pub enum GetMailTemplateError {
140 Status401(models::ApiError),
141 UnknownValue(serde_json::Value),
142}
143
144#[derive(Debug, Clone, Serialize, Deserialize)]
146#[serde(untagged)]
147pub enum GetMailThreadTrackingError {
148 Status401(models::ApiError),
149 UnknownValue(serde_json::Value),
150}
151
152#[derive(Debug, Clone, Serialize, Deserialize)]
154#[serde(untagged)]
155pub enum InstantiateMailTemplateError {
156 Status401(models::ApiError),
157 UnknownValue(serde_json::Value),
158}
159
160#[derive(Debug, Clone, Serialize, Deserialize)]
162#[serde(untagged)]
163pub enum ListDraftsError {
164 Status401(models::ApiError),
165 UnknownValue(serde_json::Value),
166}
167
168#[derive(Debug, Clone, Serialize, Deserialize)]
170#[serde(untagged)]
171pub enum ListEmailLabelsError {
172 Status400(models::CreateNote400Response),
173 Status401(models::ApiError),
174 UnknownValue(serde_json::Value),
175}
176
177#[derive(Debug, Clone, Serialize, Deserialize)]
179#[serde(untagged)]
180pub enum ListEmailsError {
181 Status401(models::ApiError),
182 Status500(models::ApiError),
183 UnknownValue(serde_json::Value),
184}
185
186#[derive(Debug, Clone, Serialize, Deserialize)]
188#[serde(untagged)]
189pub enum ListMailTemplatesError {
190 Status401(models::ApiError),
191 UnknownValue(serde_json::Value),
192}
193
194#[derive(Debug, Clone, Serialize, Deserialize)]
196#[serde(untagged)]
197pub enum ReplyEmailError {
198 Status400(models::CreateNote400Response),
199 Status401(models::ApiError),
200 Status404(models::ApiError),
201 UnknownValue(serde_json::Value),
202}
203
204#[derive(Debug, Clone, Serialize, Deserialize)]
206#[serde(untagged)]
207pub enum SaveMailTemplateError {
208 Status401(models::ApiError),
209 UnknownValue(serde_json::Value),
210}
211
212#[derive(Debug, Clone, Serialize, Deserialize)]
214#[serde(untagged)]
215pub enum SearchEmailsError {
216 Status401(models::ApiError),
217 Status500(models::ApiError),
218 UnknownValue(serde_json::Value),
219}
220
221#[derive(Debug, Clone, Serialize, Deserialize)]
223#[serde(untagged)]
224pub enum SendDraftError {
225 Status400(models::ApiError),
226 Status401(models::ApiError),
227 Status404(models::ApiError),
228 UnknownValue(serde_json::Value),
229}
230
231#[derive(Debug, Clone, Serialize, Deserialize)]
233#[serde(untagged)]
234pub enum SendEmailError {
235 Status400(models::CreateNote400Response),
236 Status401(models::ApiError),
237 Status500(models::ApiError),
238 UnknownValue(serde_json::Value),
239}
240
241#[derive(Debug, Clone, Serialize, Deserialize)]
243#[serde(untagged)]
244pub enum UpdateDraftError {
245 Status400(models::ApiError),
246 Status401(models::ApiError),
247 Status404(models::ApiError),
248 UnknownValue(serde_json::Value),
249}
250
251#[derive(Debug, Clone, Serialize, Deserialize)]
253#[serde(untagged)]
254pub enum UpdateEmailError {
255 Status400(models::ApiError),
256 Status401(models::ApiError),
257 Status404(models::ApiError),
258 UnknownValue(serde_json::Value),
259}
260
261#[derive(Debug, Clone, Serialize, Deserialize)]
263#[serde(untagged)]
264pub enum UpdateMailTemplateError {
265 Status401(models::ApiError),
266 UnknownValue(serde_json::Value),
267}
268
269#[derive(Debug, Clone, Serialize, Deserialize)]
271#[serde(untagged)]
272pub enum WorkspaceAddMailMessageLabelsError {
273 Status401(models::ApiError),
274 Status403(models::ApiError),
275 UnknownValue(serde_json::Value),
276}
277
278#[derive(Debug, Clone, Serialize, Deserialize)]
280#[serde(untagged)]
281pub enum WorkspaceCreateMailDraftError {
282 Status401(models::ApiError),
283 Status403(models::ApiError),
284 UnknownValue(serde_json::Value),
285}
286
287#[derive(Debug, Clone, Serialize, Deserialize)]
289#[serde(untagged)]
290pub enum WorkspaceCreateMailLabelError {
291 Status401(models::ApiError),
292 Status403(models::ApiError),
293 UnknownValue(serde_json::Value),
294}
295
296#[derive(Debug, Clone, Serialize, Deserialize)]
298#[serde(untagged)]
299pub enum WorkspaceDeleteMailError {
300 Status401(models::ApiError),
301 Status403(models::ApiError),
302 UnknownValue(serde_json::Value),
303}
304
305#[derive(Debug, Clone, Serialize, Deserialize)]
307#[serde(untagged)]
308pub enum WorkspaceDeleteMailDraftError {
309 Status401(models::ApiError),
310 Status403(models::ApiError),
311 UnknownValue(serde_json::Value),
312}
313
314#[derive(Debug, Clone, Serialize, Deserialize)]
316#[serde(untagged)]
317pub enum WorkspaceDeleteMailLabelError {
318 Status401(models::ApiError),
319 Status403(models::ApiError),
320 UnknownValue(serde_json::Value),
321}
322
323#[derive(Debug, Clone, Serialize, Deserialize)]
325#[serde(untagged)]
326pub enum WorkspaceGetMailError {
327 Status401(models::ApiError),
328 Status403(models::ApiError),
329 Status404(models::ApiError),
330 UnknownValue(serde_json::Value),
331}
332
333#[derive(Debug, Clone, Serialize, Deserialize)]
335#[serde(untagged)]
336pub enum WorkspaceGetMailAttachmentError {
337 Status401(models::ApiError),
338 Status403(models::ApiError),
339 UnknownValue(serde_json::Value),
340}
341
342#[derive(Debug, Clone, Serialize, Deserialize)]
344#[serde(untagged)]
345pub enum WorkspaceGetMailByIdError {
346 Status401(models::ApiError),
347 Status403(models::ApiError),
348 UnknownValue(serde_json::Value),
349}
350
351#[derive(Debug, Clone, Serialize, Deserialize)]
353#[serde(untagged)]
354pub enum WorkspaceGetMailDraftError {
355 Status401(models::ApiError),
356 Status403(models::ApiError),
357 UnknownValue(serde_json::Value),
358}
359
360#[derive(Debug, Clone, Serialize, Deserialize)]
362#[serde(untagged)]
363pub enum WorkspaceGetMailThreadError {
364 Status401(models::ApiError),
365 Status403(models::ApiError),
366 UnknownValue(serde_json::Value),
367}
368
369#[derive(Debug, Clone, Serialize, Deserialize)]
371#[serde(untagged)]
372pub enum WorkspaceListMailError {
373 Status401(models::ApiError),
374 Status403(models::ApiError),
375 UnknownValue(serde_json::Value),
376}
377
378#[derive(Debug, Clone, Serialize, Deserialize)]
380#[serde(untagged)]
381pub enum WorkspaceListMailDraftsError {
382 Status401(models::ApiError),
383 Status403(models::ApiError),
384 UnknownValue(serde_json::Value),
385}
386
387#[derive(Debug, Clone, Serialize, Deserialize)]
389#[serde(untagged)]
390pub enum WorkspaceListMailLabelsError {
391 Status401(models::ApiError),
392 Status403(models::ApiError),
393 UnknownValue(serde_json::Value),
394}
395
396#[derive(Debug, Clone, Serialize, Deserialize)]
398#[serde(untagged)]
399pub enum WorkspacePatchMailError {
400 Status401(models::ApiError),
401 Status403(models::ApiError),
402 UnknownValue(serde_json::Value),
403}
404
405#[derive(Debug, Clone, Serialize, Deserialize)]
407#[serde(untagged)]
408pub enum WorkspaceRemoveMailMessageLabelError {
409 Status401(models::ApiError),
410 Status403(models::ApiError),
411 UnknownValue(serde_json::Value),
412}
413
414#[derive(Debug, Clone, Serialize, Deserialize)]
416#[serde(untagged)]
417pub enum WorkspaceReplyMailError {
418 Status401(models::ApiError),
419 Status403(models::ApiError),
420 UnknownValue(serde_json::Value),
421}
422
423#[derive(Debug, Clone, Serialize, Deserialize)]
425#[serde(untagged)]
426pub enum WorkspaceSearchMailError {
427 Status401(models::ApiError),
428 Status403(models::ApiError),
429 UnknownValue(serde_json::Value),
430}
431
432#[derive(Debug, Clone, Serialize, Deserialize)]
434#[serde(untagged)]
435pub enum WorkspaceSendMailError {
436 Status401(models::ApiError),
437 Status403(models::ApiError),
438 UnknownValue(serde_json::Value),
439}
440
441#[derive(Debug, Clone, Serialize, Deserialize)]
443#[serde(untagged)]
444pub enum WorkspaceSendMailDraftError {
445 Status401(models::ApiError),
446 Status403(models::ApiError),
447 UnknownValue(serde_json::Value),
448}
449
450#[derive(Debug, Clone, Serialize, Deserialize)]
452#[serde(untagged)]
453pub enum WorkspaceSendMailEmailAliasError {
454 Status401(models::ApiError),
455 Status403(models::ApiError),
456 UnknownValue(serde_json::Value),
457}
458
459#[derive(Debug, Clone, Serialize, Deserialize)]
461#[serde(untagged)]
462pub enum WorkspaceUpdateMailError {
463 Status401(models::ApiError),
464 Status403(models::ApiError),
465 UnknownValue(serde_json::Value),
466}
467
468#[derive(Debug, Clone, Serialize, Deserialize)]
470#[serde(untagged)]
471pub enum WorkspaceUpdateMailDraftError {
472 Status401(models::ApiError),
473 Status403(models::ApiError),
474 UnknownValue(serde_json::Value),
475}
476
477#[derive(Debug, Clone, Serialize, Deserialize)]
479#[serde(untagged)]
480pub enum WorkspaceUpdateMailLabelError {
481 Status401(models::ApiError),
482 Status403(models::ApiError),
483 UnknownValue(serde_json::Value),
484}
485
486
487pub async fn bulk_archive_emails(configuration: &configuration::Configuration, bulk_archive_request: models::BulkArchiveRequest) -> Result<models::BulkArchiveResponse, Error<BulkArchiveEmailsError>> {
488 let p_body_bulk_archive_request = bulk_archive_request;
490
491 let uri_str = format!("{}/v1/mail/archive", configuration.base_path);
492 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
493
494 if let Some(ref user_agent) = configuration.user_agent {
495 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
496 }
497 if let Some(ref token) = configuration.bearer_access_token {
498 req_builder = req_builder.bearer_auth(token.to_owned());
499 };
500 req_builder = req_builder.json(&p_body_bulk_archive_request);
501
502 let req = req_builder.build()?;
503 let resp = configuration.client.execute(req).await?;
504
505 let status = resp.status();
506 let content_type = resp
507 .headers()
508 .get("content-type")
509 .and_then(|v| v.to_str().ok())
510 .unwrap_or("application/octet-stream");
511 let content_type = super::ContentType::from(content_type);
512
513 if !status.is_client_error() && !status.is_server_error() {
514 let content = resp.text().await?;
515 match content_type {
516 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
517 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BulkArchiveResponse`"))),
518 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BulkArchiveResponse`")))),
519 }
520 } else {
521 let content = resp.text().await?;
522 let entity: Option<BulkArchiveEmailsError> = serde_json::from_str(&content).ok();
523 Err(Error::ResponseError(ResponseContent { status, content, entity }))
524 }
525}
526
527pub async fn bulk_delete_emails(configuration: &configuration::Configuration, bulk_delete_emails_request: models::BulkDeleteEmailsRequest) -> Result<models::BulkDeleteEmailsResponse, Error<BulkDeleteEmailsError>> {
529 let p_body_bulk_delete_emails_request = bulk_delete_emails_request;
531
532 let uri_str = format!("{}/v1/mail/delete", configuration.base_path);
533 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
534
535 if let Some(ref user_agent) = configuration.user_agent {
536 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
537 }
538 if let Some(ref token) = configuration.bearer_access_token {
539 req_builder = req_builder.bearer_auth(token.to_owned());
540 };
541 req_builder = req_builder.json(&p_body_bulk_delete_emails_request);
542
543 let req = req_builder.build()?;
544 let resp = configuration.client.execute(req).await?;
545
546 let status = resp.status();
547 let content_type = resp
548 .headers()
549 .get("content-type")
550 .and_then(|v| v.to_str().ok())
551 .unwrap_or("application/octet-stream");
552 let content_type = super::ContentType::from(content_type);
553
554 if !status.is_client_error() && !status.is_server_error() {
555 let content = resp.text().await?;
556 match content_type {
557 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
558 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BulkDeleteEmailsResponse`"))),
559 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BulkDeleteEmailsResponse`")))),
560 }
561 } else {
562 let content = resp.text().await?;
563 let entity: Option<BulkDeleteEmailsError> = serde_json::from_str(&content).ok();
564 Err(Error::ResponseError(ResponseContent { status, content, entity }))
565 }
566}
567
568pub async fn bulk_mark_emails_read(configuration: &configuration::Configuration, bulk_mark_read_request: models::BulkMarkReadRequest) -> Result<models::BulkMarkReadResponse, Error<BulkMarkEmailsReadError>> {
569 let p_body_bulk_mark_read_request = bulk_mark_read_request;
571
572 let uri_str = format!("{}/v1/mail/mark-read", configuration.base_path);
573 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
574
575 if let Some(ref user_agent) = configuration.user_agent {
576 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
577 }
578 if let Some(ref token) = configuration.bearer_access_token {
579 req_builder = req_builder.bearer_auth(token.to_owned());
580 };
581 req_builder = req_builder.json(&p_body_bulk_mark_read_request);
582
583 let req = req_builder.build()?;
584 let resp = configuration.client.execute(req).await?;
585
586 let status = resp.status();
587 let content_type = resp
588 .headers()
589 .get("content-type")
590 .and_then(|v| v.to_str().ok())
591 .unwrap_or("application/octet-stream");
592 let content_type = super::ContentType::from(content_type);
593
594 if !status.is_client_error() && !status.is_server_error() {
595 let content = resp.text().await?;
596 match content_type {
597 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
598 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BulkMarkReadResponse`"))),
599 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BulkMarkReadResponse`")))),
600 }
601 } else {
602 let content = resp.text().await?;
603 let entity: Option<BulkMarkEmailsReadError> = serde_json::from_str(&content).ok();
604 Err(Error::ResponseError(ResponseContent { status, content, entity }))
605 }
606}
607
608pub async fn create_draft(configuration: &configuration::Configuration, create_draft_request: models::CreateDraftRequest, x_workspace_id: Option<&str>) -> Result<models::DraftResponse, Error<CreateDraftError>> {
609 let p_body_create_draft_request = create_draft_request;
611 let p_header_x_workspace_id = x_workspace_id;
612
613 let uri_str = format!("{}/v1/mail/drafts", configuration.base_path);
614 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
615
616 if let Some(ref user_agent) = configuration.user_agent {
617 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
618 }
619 if let Some(param_value) = p_header_x_workspace_id {
620 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
621 }
622 if let Some(ref token) = configuration.bearer_access_token {
623 req_builder = req_builder.bearer_auth(token.to_owned());
624 };
625 req_builder = req_builder.json(&p_body_create_draft_request);
626
627 let req = req_builder.build()?;
628 let resp = configuration.client.execute(req).await?;
629
630 let status = resp.status();
631 let content_type = resp
632 .headers()
633 .get("content-type")
634 .and_then(|v| v.to_str().ok())
635 .unwrap_or("application/octet-stream");
636 let content_type = super::ContentType::from(content_type);
637
638 if !status.is_client_error() && !status.is_server_error() {
639 let content = resp.text().await?;
640 match content_type {
641 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
642 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DraftResponse`"))),
643 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DraftResponse`")))),
644 }
645 } else {
646 let content = resp.text().await?;
647 let entity: Option<CreateDraftError> = serde_json::from_str(&content).ok();
648 Err(Error::ResponseError(ResponseContent { status, content, entity }))
649 }
650}
651
652pub async fn create_email_label(configuration: &configuration::Configuration, create_label_request: models::CreateLabelRequest, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::CreateLabelResponse, Error<CreateEmailLabelError>> {
653 let p_body_create_label_request = create_label_request;
655 let p_query_account_id = account_id;
656 let p_header_x_workspace_id = x_workspace_id;
657
658 let uri_str = format!("{}/v1/mail/labels", configuration.base_path);
659 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
660
661 if let Some(ref param_value) = p_query_account_id {
662 req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
663 }
664 if let Some(ref user_agent) = configuration.user_agent {
665 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
666 }
667 if let Some(param_value) = p_header_x_workspace_id {
668 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
669 }
670 if let Some(ref token) = configuration.bearer_access_token {
671 req_builder = req_builder.bearer_auth(token.to_owned());
672 };
673 req_builder = req_builder.json(&p_body_create_label_request);
674
675 let req = req_builder.build()?;
676 let resp = configuration.client.execute(req).await?;
677
678 let status = resp.status();
679 let content_type = resp
680 .headers()
681 .get("content-type")
682 .and_then(|v| v.to_str().ok())
683 .unwrap_or("application/octet-stream");
684 let content_type = super::ContentType::from(content_type);
685
686 if !status.is_client_error() && !status.is_server_error() {
687 let content = resp.text().await?;
688 match content_type {
689 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
690 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateLabelResponse`"))),
691 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreateLabelResponse`")))),
692 }
693 } else {
694 let content = resp.text().await?;
695 let entity: Option<CreateEmailLabelError> = serde_json::from_str(&content).ok();
696 Err(Error::ResponseError(ResponseContent { status, content, entity }))
697 }
698}
699
700pub async fn create_mail_template(configuration: &configuration::Configuration, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<CreateMailTemplateError>> {
701 let p_body_request_body = request_body;
703
704 let uri_str = format!("{}/v1/mail/templates", configuration.base_path);
705 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
706
707 if let Some(ref user_agent) = configuration.user_agent {
708 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
709 }
710 if let Some(ref token) = configuration.bearer_access_token {
711 req_builder = req_builder.bearer_auth(token.to_owned());
712 };
713 req_builder = req_builder.json(&p_body_request_body);
714
715 let req = req_builder.build()?;
716 let resp = configuration.client.execute(req).await?;
717
718 let status = resp.status();
719 let content_type = resp
720 .headers()
721 .get("content-type")
722 .and_then(|v| v.to_str().ok())
723 .unwrap_or("application/octet-stream");
724 let content_type = super::ContentType::from(content_type);
725
726 if !status.is_client_error() && !status.is_server_error() {
727 let content = resp.text().await?;
728 match content_type {
729 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
730 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
731 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
732 }
733 } else {
734 let content = resp.text().await?;
735 let entity: Option<CreateMailTemplateError> = serde_json::from_str(&content).ok();
736 Err(Error::ResponseError(ResponseContent { status, content, entity }))
737 }
738}
739
740pub async fn delete_draft(configuration: &configuration::Configuration, id: &str, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<(), Error<DeleteDraftError>> {
741 let p_path_id = id;
743 let p_query_account_id = account_id;
744 let p_header_x_workspace_id = x_workspace_id;
745
746 let uri_str = format!("{}/v1/mail/drafts/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
747 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
748
749 if let Some(ref param_value) = p_query_account_id {
750 req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
751 }
752 if let Some(ref user_agent) = configuration.user_agent {
753 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
754 }
755 if let Some(param_value) = p_header_x_workspace_id {
756 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
757 }
758 if let Some(ref token) = configuration.bearer_access_token {
759 req_builder = req_builder.bearer_auth(token.to_owned());
760 };
761
762 let req = req_builder.build()?;
763 let resp = configuration.client.execute(req).await?;
764
765 let status = resp.status();
766
767 if !status.is_client_error() && !status.is_server_error() {
768 Ok(())
769 } else {
770 let content = resp.text().await?;
771 let entity: Option<DeleteDraftError> = serde_json::from_str(&content).ok();
772 Err(Error::ResponseError(ResponseContent { status, content, entity }))
773 }
774}
775
776pub async fn delete_email(configuration: &configuration::Configuration, id: &str, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::SuccessFlag, Error<DeleteEmailError>> {
778 let p_path_id = id;
780 let p_query_account_id = account_id;
781 let p_header_x_workspace_id = x_workspace_id;
782
783 let uri_str = format!("{}/v1/mail/email/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
784 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
785
786 if let Some(ref param_value) = p_query_account_id {
787 req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
788 }
789 if let Some(ref user_agent) = configuration.user_agent {
790 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
791 }
792 if let Some(param_value) = p_header_x_workspace_id {
793 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
794 }
795 if let Some(ref token) = configuration.bearer_access_token {
796 req_builder = req_builder.bearer_auth(token.to_owned());
797 };
798
799 let req = req_builder.build()?;
800 let resp = configuration.client.execute(req).await?;
801
802 let status = resp.status();
803 let content_type = resp
804 .headers()
805 .get("content-type")
806 .and_then(|v| v.to_str().ok())
807 .unwrap_or("application/octet-stream");
808 let content_type = super::ContentType::from(content_type);
809
810 if !status.is_client_error() && !status.is_server_error() {
811 let content = resp.text().await?;
812 match content_type {
813 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
814 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessFlag`"))),
815 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SuccessFlag`")))),
816 }
817 } else {
818 let content = resp.text().await?;
819 let entity: Option<DeleteEmailError> = serde_json::from_str(&content).ok();
820 Err(Error::ResponseError(ResponseContent { status, content, entity }))
821 }
822}
823
824pub async fn delete_email_label(configuration: &configuration::Configuration, id: &str, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<(), Error<DeleteEmailLabelError>> {
825 let p_path_id = id;
827 let p_query_account_id = account_id;
828 let p_header_x_workspace_id = x_workspace_id;
829
830 let uri_str = format!("{}/v1/mail/labels/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
831 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
832
833 if let Some(ref param_value) = p_query_account_id {
834 req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
835 }
836 if let Some(ref user_agent) = configuration.user_agent {
837 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
838 }
839 if let Some(param_value) = p_header_x_workspace_id {
840 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
841 }
842 if let Some(ref token) = configuration.bearer_access_token {
843 req_builder = req_builder.bearer_auth(token.to_owned());
844 };
845
846 let req = req_builder.build()?;
847 let resp = configuration.client.execute(req).await?;
848
849 let status = resp.status();
850
851 if !status.is_client_error() && !status.is_server_error() {
852 Ok(())
853 } else {
854 let content = resp.text().await?;
855 let entity: Option<DeleteEmailLabelError> = serde_json::from_str(&content).ok();
856 Err(Error::ResponseError(ResponseContent { status, content, entity }))
857 }
858}
859
860pub async fn delete_mail_template(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DeleteMailTemplateError>> {
861 let p_path_id = id;
863
864 let uri_str = format!("{}/v1/mail/templates/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
865 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
866
867 if let Some(ref user_agent) = configuration.user_agent {
868 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
869 }
870 if let Some(ref token) = configuration.bearer_access_token {
871 req_builder = req_builder.bearer_auth(token.to_owned());
872 };
873
874 let req = req_builder.build()?;
875 let resp = configuration.client.execute(req).await?;
876
877 let status = resp.status();
878
879 if !status.is_client_error() && !status.is_server_error() {
880 Ok(())
881 } else {
882 let content = resp.text().await?;
883 let entity: Option<DeleteMailTemplateError> = serde_json::from_str(&content).ok();
884 Err(Error::ResponseError(ResponseContent { status, content, entity }))
885 }
886}
887
888pub async fn get_email(configuration: &configuration::Configuration, id: &str, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::GetEmailResponse, Error<GetEmailError>> {
889 let p_path_id = id;
891 let p_query_account_id = account_id;
892 let p_header_x_workspace_id = x_workspace_id;
893
894 let uri_str = format!("{}/v1/mail/email/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
895 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
896
897 if let Some(ref param_value) = p_query_account_id {
898 req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
899 }
900 if let Some(ref user_agent) = configuration.user_agent {
901 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
902 }
903 if let Some(param_value) = p_header_x_workspace_id {
904 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
905 }
906 if let Some(ref token) = configuration.bearer_access_token {
907 req_builder = req_builder.bearer_auth(token.to_owned());
908 };
909
910 let req = req_builder.build()?;
911 let resp = configuration.client.execute(req).await?;
912
913 let status = resp.status();
914 let content_type = resp
915 .headers()
916 .get("content-type")
917 .and_then(|v| v.to_str().ok())
918 .unwrap_or("application/octet-stream");
919 let content_type = super::ContentType::from(content_type);
920
921 if !status.is_client_error() && !status.is_server_error() {
922 let content = resp.text().await?;
923 match content_type {
924 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
925 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetEmailResponse`"))),
926 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetEmailResponse`")))),
927 }
928 } else {
929 let content = resp.text().await?;
930 let entity: Option<GetEmailError> = serde_json::from_str(&content).ok();
931 Err(Error::ResponseError(ResponseContent { status, content, entity }))
932 }
933}
934
935pub async fn get_email_attachment(configuration: &configuration::Configuration, message_id: &str, attachment_id: &str, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<reqwest::Response, Error<GetEmailAttachmentError>> {
937 let p_path_message_id = message_id;
939 let p_path_attachment_id = attachment_id;
940 let p_query_account_id = account_id;
941 let p_header_x_workspace_id = x_workspace_id;
942
943 let uri_str = format!("{}/v1/mail/attachment/{messageId}/{attachmentId}", configuration.base_path, messageId=crate::apis::urlencode(p_path_message_id), attachmentId=crate::apis::urlencode(p_path_attachment_id));
944 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
945
946 if let Some(ref param_value) = p_query_account_id {
947 req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
948 }
949 if let Some(ref user_agent) = configuration.user_agent {
950 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
951 }
952 if let Some(param_value) = p_header_x_workspace_id {
953 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
954 }
955 if let Some(ref token) = configuration.bearer_access_token {
956 req_builder = req_builder.bearer_auth(token.to_owned());
957 };
958
959 let req = req_builder.build()?;
960 let resp = configuration.client.execute(req).await?;
961
962 let status = resp.status();
963
964 if !status.is_client_error() && !status.is_server_error() {
965 Ok(resp)
966 } else {
967 let content = resp.text().await?;
968 let entity: Option<GetEmailAttachmentError> = serde_json::from_str(&content).ok();
969 Err(Error::ResponseError(ResponseContent { status, content, entity }))
970 }
971}
972
973pub async fn get_email_thread(configuration: &configuration::Configuration, id: &str, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::GetThreadResponse, Error<GetEmailThreadError>> {
974 let p_path_id = id;
976 let p_query_account_id = account_id;
977 let p_header_x_workspace_id = x_workspace_id;
978
979 let uri_str = format!("{}/v1/mail/thread/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
980 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
981
982 if let Some(ref param_value) = p_query_account_id {
983 req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
984 }
985 if let Some(ref user_agent) = configuration.user_agent {
986 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
987 }
988 if let Some(param_value) = p_header_x_workspace_id {
989 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
990 }
991 if let Some(ref token) = configuration.bearer_access_token {
992 req_builder = req_builder.bearer_auth(token.to_owned());
993 };
994
995 let req = req_builder.build()?;
996 let resp = configuration.client.execute(req).await?;
997
998 let status = resp.status();
999 let content_type = resp
1000 .headers()
1001 .get("content-type")
1002 .and_then(|v| v.to_str().ok())
1003 .unwrap_or("application/octet-stream");
1004 let content_type = super::ContentType::from(content_type);
1005
1006 if !status.is_client_error() && !status.is_server_error() {
1007 let content = resp.text().await?;
1008 match content_type {
1009 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1010 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetThreadResponse`"))),
1011 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetThreadResponse`")))),
1012 }
1013 } else {
1014 let content = resp.text().await?;
1015 let entity: Option<GetEmailThreadError> = serde_json::from_str(&content).ok();
1016 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1017 }
1018}
1019
1020pub async fn get_mail_template(configuration: &configuration::Configuration, id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<GetMailTemplateError>> {
1021 let p_path_id = id;
1023
1024 let uri_str = format!("{}/v1/mail/templates/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
1025 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1026
1027 if let Some(ref user_agent) = configuration.user_agent {
1028 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1029 }
1030 if let Some(ref token) = configuration.bearer_access_token {
1031 req_builder = req_builder.bearer_auth(token.to_owned());
1032 };
1033
1034 let req = req_builder.build()?;
1035 let resp = configuration.client.execute(req).await?;
1036
1037 let status = resp.status();
1038 let content_type = resp
1039 .headers()
1040 .get("content-type")
1041 .and_then(|v| v.to_str().ok())
1042 .unwrap_or("application/octet-stream");
1043 let content_type = super::ContentType::from(content_type);
1044
1045 if !status.is_client_error() && !status.is_server_error() {
1046 let content = resp.text().await?;
1047 match content_type {
1048 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1049 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
1050 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
1051 }
1052 } else {
1053 let content = resp.text().await?;
1054 let entity: Option<GetMailTemplateError> = serde_json::from_str(&content).ok();
1055 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1056 }
1057}
1058
1059pub async fn get_mail_thread_tracking(configuration: &configuration::Configuration, thread_id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<GetMailThreadTrackingError>> {
1060 let p_path_thread_id = thread_id;
1062
1063 let uri_str = format!("{}/v1/mail/threads/{threadId}/tracking", configuration.base_path, threadId=crate::apis::urlencode(p_path_thread_id));
1064 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1065
1066 if let Some(ref user_agent) = configuration.user_agent {
1067 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1068 }
1069 if let Some(ref token) = configuration.bearer_access_token {
1070 req_builder = req_builder.bearer_auth(token.to_owned());
1071 };
1072
1073 let req = req_builder.build()?;
1074 let resp = configuration.client.execute(req).await?;
1075
1076 let status = resp.status();
1077 let content_type = resp
1078 .headers()
1079 .get("content-type")
1080 .and_then(|v| v.to_str().ok())
1081 .unwrap_or("application/octet-stream");
1082 let content_type = super::ContentType::from(content_type);
1083
1084 if !status.is_client_error() && !status.is_server_error() {
1085 let content = resp.text().await?;
1086 match content_type {
1087 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1088 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
1089 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
1090 }
1091 } else {
1092 let content = resp.text().await?;
1093 let entity: Option<GetMailThreadTrackingError> = serde_json::from_str(&content).ok();
1094 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1095 }
1096}
1097
1098pub async fn instantiate_mail_template(configuration: &configuration::Configuration, id: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<InstantiateMailTemplateError>> {
1099 let p_path_id = id;
1101 let p_body_request_body = request_body;
1102
1103 let uri_str = format!("{}/v1/mail/templates/{id}/instantiate", configuration.base_path, id=crate::apis::urlencode(p_path_id));
1104 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1105
1106 if let Some(ref user_agent) = configuration.user_agent {
1107 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1108 }
1109 if let Some(ref token) = configuration.bearer_access_token {
1110 req_builder = req_builder.bearer_auth(token.to_owned());
1111 };
1112 req_builder = req_builder.json(&p_body_request_body);
1113
1114 let req = req_builder.build()?;
1115 let resp = configuration.client.execute(req).await?;
1116
1117 let status = resp.status();
1118 let content_type = resp
1119 .headers()
1120 .get("content-type")
1121 .and_then(|v| v.to_str().ok())
1122 .unwrap_or("application/octet-stream");
1123 let content_type = super::ContentType::from(content_type);
1124
1125 if !status.is_client_error() && !status.is_server_error() {
1126 let content = resp.text().await?;
1127 match content_type {
1128 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1129 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
1130 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
1131 }
1132 } else {
1133 let content = resp.text().await?;
1134 let entity: Option<InstantiateMailTemplateError> = serde_json::from_str(&content).ok();
1135 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1136 }
1137}
1138
1139pub async fn list_drafts(configuration: &configuration::Configuration, x_workspace_id: Option<&str>, account_ids: Option<Vec<String>>, providers: Option<Vec<String>>, limit: Option<i32>, next_page_token: Option<&str>) -> Result<models::ListDraftsResponse, Error<ListDraftsError>> {
1140 let p_header_x_workspace_id = x_workspace_id;
1142 let p_query_account_ids = account_ids;
1143 let p_query_providers = providers;
1144 let p_query_limit = limit;
1145 let p_query_next_page_token = next_page_token;
1146
1147 let uri_str = format!("{}/v1/mail/drafts", configuration.base_path);
1148 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1149
1150 if let Some(ref param_value) = p_query_account_ids {
1151 req_builder = match "multi" {
1152 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("accountIds".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
1153 _ => req_builder.query(&[("accountIds", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
1154 };
1155 }
1156 if let Some(ref param_value) = p_query_providers {
1157 req_builder = match "multi" {
1158 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("providers".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
1159 _ => req_builder.query(&[("providers", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
1160 };
1161 }
1162 if let Some(ref param_value) = p_query_limit {
1163 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
1164 }
1165 if let Some(ref param_value) = p_query_next_page_token {
1166 req_builder = req_builder.query(&[("nextPageToken", ¶m_value.to_string())]);
1167 }
1168 if let Some(ref user_agent) = configuration.user_agent {
1169 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1170 }
1171 if let Some(param_value) = p_header_x_workspace_id {
1172 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
1173 }
1174 if let Some(ref token) = configuration.bearer_access_token {
1175 req_builder = req_builder.bearer_auth(token.to_owned());
1176 };
1177
1178 let req = req_builder.build()?;
1179 let resp = configuration.client.execute(req).await?;
1180
1181 let status = resp.status();
1182 let content_type = resp
1183 .headers()
1184 .get("content-type")
1185 .and_then(|v| v.to_str().ok())
1186 .unwrap_or("application/octet-stream");
1187 let content_type = super::ContentType::from(content_type);
1188
1189 if !status.is_client_error() && !status.is_server_error() {
1190 let content = resp.text().await?;
1191 match content_type {
1192 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1193 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListDraftsResponse`"))),
1194 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListDraftsResponse`")))),
1195 }
1196 } else {
1197 let content = resp.text().await?;
1198 let entity: Option<ListDraftsError> = serde_json::from_str(&content).ok();
1199 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1200 }
1201}
1202
1203pub async fn list_email_labels(configuration: &configuration::Configuration, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::ListLabelsResponse, Error<ListEmailLabelsError>> {
1205 let p_query_account_id = account_id;
1207 let p_header_x_workspace_id = x_workspace_id;
1208
1209 let uri_str = format!("{}/v1/mail/labels", configuration.base_path);
1210 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1211
1212 if let Some(ref param_value) = p_query_account_id {
1213 req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
1214 }
1215 if let Some(ref user_agent) = configuration.user_agent {
1216 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1217 }
1218 if let Some(param_value) = p_header_x_workspace_id {
1219 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
1220 }
1221 if let Some(ref token) = configuration.bearer_access_token {
1222 req_builder = req_builder.bearer_auth(token.to_owned());
1223 };
1224
1225 let req = req_builder.build()?;
1226 let resp = configuration.client.execute(req).await?;
1227
1228 let status = resp.status();
1229 let content_type = resp
1230 .headers()
1231 .get("content-type")
1232 .and_then(|v| v.to_str().ok())
1233 .unwrap_or("application/octet-stream");
1234 let content_type = super::ContentType::from(content_type);
1235
1236 if !status.is_client_error() && !status.is_server_error() {
1237 let content = resp.text().await?;
1238 match content_type {
1239 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1240 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListLabelsResponse`"))),
1241 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListLabelsResponse`")))),
1242 }
1243 } else {
1244 let content = resp.text().await?;
1245 let entity: Option<ListEmailLabelsError> = serde_json::from_str(&content).ok();
1246 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1247 }
1248}
1249
1250pub async fn list_emails(configuration: &configuration::Configuration, account_ids: Option<Vec<String>>, providers: Option<Vec<String>>, x_workspace_id: Option<&str>, query: Option<&str>, labels: Option<Vec<String>>, folder: Option<&str>, limit: Option<i32>, offset: Option<i32>) -> Result<models::ListEmailsResponse, Error<ListEmailsError>> {
1252 let p_query_account_ids = account_ids;
1254 let p_query_providers = providers;
1255 let p_header_x_workspace_id = x_workspace_id;
1256 let p_query_query = query;
1257 let p_query_labels = labels;
1258 let p_query_folder = folder;
1259 let p_query_limit = limit;
1260 let p_query_offset = offset;
1261
1262 let uri_str = format!("{}/v1/mail/list", configuration.base_path);
1263 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1264
1265 if let Some(ref param_value) = p_query_account_ids {
1266 req_builder = match "multi" {
1267 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("accountIds".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
1268 _ => req_builder.query(&[("accountIds", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
1269 };
1270 }
1271 if let Some(ref param_value) = p_query_providers {
1272 req_builder = match "multi" {
1273 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("providers".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
1274 _ => req_builder.query(&[("providers", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
1275 };
1276 }
1277 if let Some(ref param_value) = p_query_query {
1278 req_builder = req_builder.query(&[("query", ¶m_value.to_string())]);
1279 }
1280 if let Some(ref param_value) = p_query_labels {
1281 req_builder = match "multi" {
1282 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("labels".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
1283 _ => req_builder.query(&[("labels", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
1284 };
1285 }
1286 if let Some(ref param_value) = p_query_folder {
1287 req_builder = req_builder.query(&[("folder", ¶m_value.to_string())]);
1288 }
1289 if let Some(ref param_value) = p_query_limit {
1290 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
1291 }
1292 if let Some(ref param_value) = p_query_offset {
1293 req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
1294 }
1295 if let Some(ref user_agent) = configuration.user_agent {
1296 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1297 }
1298 if let Some(param_value) = p_header_x_workspace_id {
1299 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
1300 }
1301 if let Some(ref token) = configuration.bearer_access_token {
1302 req_builder = req_builder.bearer_auth(token.to_owned());
1303 };
1304
1305 let req = req_builder.build()?;
1306 let resp = configuration.client.execute(req).await?;
1307
1308 let status = resp.status();
1309 let content_type = resp
1310 .headers()
1311 .get("content-type")
1312 .and_then(|v| v.to_str().ok())
1313 .unwrap_or("application/octet-stream");
1314 let content_type = super::ContentType::from(content_type);
1315
1316 if !status.is_client_error() && !status.is_server_error() {
1317 let content = resp.text().await?;
1318 match content_type {
1319 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1320 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListEmailsResponse`"))),
1321 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListEmailsResponse`")))),
1322 }
1323 } else {
1324 let content = resp.text().await?;
1325 let entity: Option<ListEmailsError> = serde_json::from_str(&content).ok();
1326 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1327 }
1328}
1329
1330pub async fn list_mail_templates(configuration: &configuration::Configuration, ) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<ListMailTemplatesError>> {
1331
1332 let uri_str = format!("{}/v1/mail/templates", configuration.base_path);
1333 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1334
1335 if let Some(ref user_agent) = configuration.user_agent {
1336 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1337 }
1338 if let Some(ref token) = configuration.bearer_access_token {
1339 req_builder = req_builder.bearer_auth(token.to_owned());
1340 };
1341
1342 let req = req_builder.build()?;
1343 let resp = configuration.client.execute(req).await?;
1344
1345 let status = resp.status();
1346 let content_type = resp
1347 .headers()
1348 .get("content-type")
1349 .and_then(|v| v.to_str().ok())
1350 .unwrap_or("application/octet-stream");
1351 let content_type = super::ContentType::from(content_type);
1352
1353 if !status.is_client_error() && !status.is_server_error() {
1354 let content = resp.text().await?;
1355 match content_type {
1356 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1357 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
1358 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
1359 }
1360 } else {
1361 let content = resp.text().await?;
1362 let entity: Option<ListMailTemplatesError> = serde_json::from_str(&content).ok();
1363 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1364 }
1365}
1366
1367pub async fn reply_email(configuration: &configuration::Configuration, message_id: &str, reply_email_request: models::ReplyEmailRequest, x_workspace_id: Option<&str>) -> Result<models::SendEmailResponse, Error<ReplyEmailError>> {
1369 let p_query_message_id = message_id;
1371 let p_body_reply_email_request = reply_email_request;
1372 let p_header_x_workspace_id = x_workspace_id;
1373
1374 let uri_str = format!("{}/v1/mail/reply", configuration.base_path);
1375 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1376
1377 req_builder = req_builder.query(&[("messageId", &p_query_message_id.to_string())]);
1378 if let Some(ref user_agent) = configuration.user_agent {
1379 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1380 }
1381 if let Some(param_value) = p_header_x_workspace_id {
1382 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
1383 }
1384 if let Some(ref token) = configuration.bearer_access_token {
1385 req_builder = req_builder.bearer_auth(token.to_owned());
1386 };
1387 req_builder = req_builder.json(&p_body_reply_email_request);
1388
1389 let req = req_builder.build()?;
1390 let resp = configuration.client.execute(req).await?;
1391
1392 let status = resp.status();
1393 let content_type = resp
1394 .headers()
1395 .get("content-type")
1396 .and_then(|v| v.to_str().ok())
1397 .unwrap_or("application/octet-stream");
1398 let content_type = super::ContentType::from(content_type);
1399
1400 if !status.is_client_error() && !status.is_server_error() {
1401 let content = resp.text().await?;
1402 match content_type {
1403 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1404 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendEmailResponse`"))),
1405 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SendEmailResponse`")))),
1406 }
1407 } else {
1408 let content = resp.text().await?;
1409 let entity: Option<ReplyEmailError> = serde_json::from_str(&content).ok();
1410 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1411 }
1412}
1413
1414pub async fn save_mail_template(configuration: &configuration::Configuration, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<SaveMailTemplateError>> {
1415 let p_body_request_body = request_body;
1417
1418 let uri_str = format!("{}/v1/mail/templates/save", configuration.base_path);
1419 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1420
1421 if let Some(ref user_agent) = configuration.user_agent {
1422 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1423 }
1424 if let Some(ref token) = configuration.bearer_access_token {
1425 req_builder = req_builder.bearer_auth(token.to_owned());
1426 };
1427 req_builder = req_builder.json(&p_body_request_body);
1428
1429 let req = req_builder.build()?;
1430 let resp = configuration.client.execute(req).await?;
1431
1432 let status = resp.status();
1433 let content_type = resp
1434 .headers()
1435 .get("content-type")
1436 .and_then(|v| v.to_str().ok())
1437 .unwrap_or("application/octet-stream");
1438 let content_type = super::ContentType::from(content_type);
1439
1440 if !status.is_client_error() && !status.is_server_error() {
1441 let content = resp.text().await?;
1442 match content_type {
1443 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1444 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
1445 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
1446 }
1447 } else {
1448 let content = resp.text().await?;
1449 let entity: Option<SaveMailTemplateError> = serde_json::from_str(&content).ok();
1450 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1451 }
1452}
1453
1454pub async fn search_emails(configuration: &configuration::Configuration, q: &str, account_ids: Option<Vec<String>>, providers: Option<Vec<String>>, x_workspace_id: Option<&str>, from: Option<&str>, to: Option<&str>, subject: Option<&str>, has_attachment: Option<bool>, is_unread: Option<bool>, is_starred: Option<bool>, labels: Option<Vec<String>>, after: Option<chrono::DateTime<chrono::FixedOffset>>, before: Option<chrono::DateTime<chrono::FixedOffset>>, limit: Option<i32>, next_page_token: Option<&str>) -> Result<models::SearchEmailsResponse, Error<SearchEmailsError>> {
1456 let p_query_q = q;
1458 let p_query_account_ids = account_ids;
1459 let p_query_providers = providers;
1460 let p_header_x_workspace_id = x_workspace_id;
1461 let p_query_from = from;
1462 let p_query_to = to;
1463 let p_query_subject = subject;
1464 let p_query_has_attachment = has_attachment;
1465 let p_query_is_unread = is_unread;
1466 let p_query_is_starred = is_starred;
1467 let p_query_labels = labels;
1468 let p_query_after = after;
1469 let p_query_before = before;
1470 let p_query_limit = limit;
1471 let p_query_next_page_token = next_page_token;
1472
1473 let uri_str = format!("{}/v1/mail/search", configuration.base_path);
1474 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1475
1476 if let Some(ref param_value) = p_query_account_ids {
1477 req_builder = match "multi" {
1478 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("accountIds".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
1479 _ => req_builder.query(&[("accountIds", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
1480 };
1481 }
1482 if let Some(ref param_value) = p_query_providers {
1483 req_builder = match "multi" {
1484 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("providers".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
1485 _ => req_builder.query(&[("providers", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
1486 };
1487 }
1488 req_builder = req_builder.query(&[("q", &p_query_q.to_string())]);
1489 if let Some(ref param_value) = p_query_from {
1490 req_builder = req_builder.query(&[("from", ¶m_value.to_string())]);
1491 }
1492 if let Some(ref param_value) = p_query_to {
1493 req_builder = req_builder.query(&[("to", ¶m_value.to_string())]);
1494 }
1495 if let Some(ref param_value) = p_query_subject {
1496 req_builder = req_builder.query(&[("subject", ¶m_value.to_string())]);
1497 }
1498 if let Some(ref param_value) = p_query_has_attachment {
1499 req_builder = req_builder.query(&[("hasAttachment", ¶m_value.to_string())]);
1500 }
1501 if let Some(ref param_value) = p_query_is_unread {
1502 req_builder = req_builder.query(&[("isUnread", ¶m_value.to_string())]);
1503 }
1504 if let Some(ref param_value) = p_query_is_starred {
1505 req_builder = req_builder.query(&[("isStarred", ¶m_value.to_string())]);
1506 }
1507 if let Some(ref param_value) = p_query_labels {
1508 req_builder = match "multi" {
1509 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("labels".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
1510 _ => req_builder.query(&[("labels", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
1511 };
1512 }
1513 if let Some(ref param_value) = p_query_after {
1514 req_builder = req_builder.query(&[("after", ¶m_value.to_string())]);
1515 }
1516 if let Some(ref param_value) = p_query_before {
1517 req_builder = req_builder.query(&[("before", ¶m_value.to_string())]);
1518 }
1519 if let Some(ref param_value) = p_query_limit {
1520 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
1521 }
1522 if let Some(ref param_value) = p_query_next_page_token {
1523 req_builder = req_builder.query(&[("nextPageToken", ¶m_value.to_string())]);
1524 }
1525 if let Some(ref user_agent) = configuration.user_agent {
1526 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1527 }
1528 if let Some(param_value) = p_header_x_workspace_id {
1529 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
1530 }
1531 if let Some(ref token) = configuration.bearer_access_token {
1532 req_builder = req_builder.bearer_auth(token.to_owned());
1533 };
1534
1535 let req = req_builder.build()?;
1536 let resp = configuration.client.execute(req).await?;
1537
1538 let status = resp.status();
1539 let content_type = resp
1540 .headers()
1541 .get("content-type")
1542 .and_then(|v| v.to_str().ok())
1543 .unwrap_or("application/octet-stream");
1544 let content_type = super::ContentType::from(content_type);
1545
1546 if !status.is_client_error() && !status.is_server_error() {
1547 let content = resp.text().await?;
1548 match content_type {
1549 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1550 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SearchEmailsResponse`"))),
1551 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SearchEmailsResponse`")))),
1552 }
1553 } else {
1554 let content = resp.text().await?;
1555 let entity: Option<SearchEmailsError> = serde_json::from_str(&content).ok();
1556 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1557 }
1558}
1559
1560pub async fn send_draft(configuration: &configuration::Configuration, id: &str, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::SendEmailResponse, Error<SendDraftError>> {
1562 let p_path_id = id;
1564 let p_query_account_id = account_id;
1565 let p_header_x_workspace_id = x_workspace_id;
1566
1567 let uri_str = format!("{}/v1/mail/drafts/{id}/send", configuration.base_path, id=crate::apis::urlencode(p_path_id));
1568 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1569
1570 if let Some(ref param_value) = p_query_account_id {
1571 req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
1572 }
1573 if let Some(ref user_agent) = configuration.user_agent {
1574 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1575 }
1576 if let Some(param_value) = p_header_x_workspace_id {
1577 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
1578 }
1579 if let Some(ref token) = configuration.bearer_access_token {
1580 req_builder = req_builder.bearer_auth(token.to_owned());
1581 };
1582
1583 let req = req_builder.build()?;
1584 let resp = configuration.client.execute(req).await?;
1585
1586 let status = resp.status();
1587 let content_type = resp
1588 .headers()
1589 .get("content-type")
1590 .and_then(|v| v.to_str().ok())
1591 .unwrap_or("application/octet-stream");
1592 let content_type = super::ContentType::from(content_type);
1593
1594 if !status.is_client_error() && !status.is_server_error() {
1595 let content = resp.text().await?;
1596 match content_type {
1597 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1598 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendEmailResponse`"))),
1599 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SendEmailResponse`")))),
1600 }
1601 } else {
1602 let content = resp.text().await?;
1603 let entity: Option<SendDraftError> = serde_json::from_str(&content).ok();
1604 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1605 }
1606}
1607
1608pub async fn send_email(configuration: &configuration::Configuration, send_email_request: models::SendEmailRequest, x_workspace_id: Option<&str>) -> Result<models::SendEmailResponse, Error<SendEmailError>> {
1610 let p_body_send_email_request = send_email_request;
1612 let p_header_x_workspace_id = x_workspace_id;
1613
1614 let uri_str = format!("{}/v1/mail/send", configuration.base_path);
1615 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1616
1617 if let Some(ref user_agent) = configuration.user_agent {
1618 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1619 }
1620 if let Some(param_value) = p_header_x_workspace_id {
1621 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
1622 }
1623 if let Some(ref token) = configuration.bearer_access_token {
1624 req_builder = req_builder.bearer_auth(token.to_owned());
1625 };
1626 req_builder = req_builder.json(&p_body_send_email_request);
1627
1628 let req = req_builder.build()?;
1629 let resp = configuration.client.execute(req).await?;
1630
1631 let status = resp.status();
1632 let content_type = resp
1633 .headers()
1634 .get("content-type")
1635 .and_then(|v| v.to_str().ok())
1636 .unwrap_or("application/octet-stream");
1637 let content_type = super::ContentType::from(content_type);
1638
1639 if !status.is_client_error() && !status.is_server_error() {
1640 let content = resp.text().await?;
1641 match content_type {
1642 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1643 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendEmailResponse`"))),
1644 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SendEmailResponse`")))),
1645 }
1646 } else {
1647 let content = resp.text().await?;
1648 let entity: Option<SendEmailError> = serde_json::from_str(&content).ok();
1649 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1650 }
1651}
1652
1653pub async fn update_draft(configuration: &configuration::Configuration, id: &str, update_draft_request: models::UpdateDraftRequest, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::DraftResponse, Error<UpdateDraftError>> {
1655 let p_path_id = id;
1657 let p_body_update_draft_request = update_draft_request;
1658 let p_query_account_id = account_id;
1659 let p_header_x_workspace_id = x_workspace_id;
1660
1661 let uri_str = format!("{}/v1/mail/drafts/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
1662 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
1663
1664 if let Some(ref param_value) = p_query_account_id {
1665 req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
1666 }
1667 if let Some(ref user_agent) = configuration.user_agent {
1668 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1669 }
1670 if let Some(param_value) = p_header_x_workspace_id {
1671 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
1672 }
1673 if let Some(ref token) = configuration.bearer_access_token {
1674 req_builder = req_builder.bearer_auth(token.to_owned());
1675 };
1676 req_builder = req_builder.json(&p_body_update_draft_request);
1677
1678 let req = req_builder.build()?;
1679 let resp = configuration.client.execute(req).await?;
1680
1681 let status = resp.status();
1682 let content_type = resp
1683 .headers()
1684 .get("content-type")
1685 .and_then(|v| v.to_str().ok())
1686 .unwrap_or("application/octet-stream");
1687 let content_type = super::ContentType::from(content_type);
1688
1689 if !status.is_client_error() && !status.is_server_error() {
1690 let content = resp.text().await?;
1691 match content_type {
1692 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1693 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DraftResponse`"))),
1694 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DraftResponse`")))),
1695 }
1696 } else {
1697 let content = resp.text().await?;
1698 let entity: Option<UpdateDraftError> = serde_json::from_str(&content).ok();
1699 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1700 }
1701}
1702
1703pub async fn update_email(configuration: &configuration::Configuration, id: &str, update_email_request: models::UpdateEmailRequest, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::UpdateEmailResponse, Error<UpdateEmailError>> {
1704 let p_path_id = id;
1706 let p_body_update_email_request = update_email_request;
1707 let p_query_account_id = account_id;
1708 let p_header_x_workspace_id = x_workspace_id;
1709
1710 let uri_str = format!("{}/v1/mail/email/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
1711 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
1712
1713 if let Some(ref param_value) = p_query_account_id {
1714 req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
1715 }
1716 if let Some(ref user_agent) = configuration.user_agent {
1717 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1718 }
1719 if let Some(param_value) = p_header_x_workspace_id {
1720 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
1721 }
1722 if let Some(ref token) = configuration.bearer_access_token {
1723 req_builder = req_builder.bearer_auth(token.to_owned());
1724 };
1725 req_builder = req_builder.json(&p_body_update_email_request);
1726
1727 let req = req_builder.build()?;
1728 let resp = configuration.client.execute(req).await?;
1729
1730 let status = resp.status();
1731 let content_type = resp
1732 .headers()
1733 .get("content-type")
1734 .and_then(|v| v.to_str().ok())
1735 .unwrap_or("application/octet-stream");
1736 let content_type = super::ContentType::from(content_type);
1737
1738 if !status.is_client_error() && !status.is_server_error() {
1739 let content = resp.text().await?;
1740 match content_type {
1741 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1742 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateEmailResponse`"))),
1743 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UpdateEmailResponse`")))),
1744 }
1745 } else {
1746 let content = resp.text().await?;
1747 let entity: Option<UpdateEmailError> = serde_json::from_str(&content).ok();
1748 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1749 }
1750}
1751
1752pub async fn update_mail_template(configuration: &configuration::Configuration, id: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<UpdateMailTemplateError>> {
1753 let p_path_id = id;
1755 let p_body_request_body = request_body;
1756
1757 let uri_str = format!("{}/v1/mail/templates/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
1758 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
1759
1760 if let Some(ref user_agent) = configuration.user_agent {
1761 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1762 }
1763 if let Some(ref token) = configuration.bearer_access_token {
1764 req_builder = req_builder.bearer_auth(token.to_owned());
1765 };
1766 req_builder = req_builder.json(&p_body_request_body);
1767
1768 let req = req_builder.build()?;
1769 let resp = configuration.client.execute(req).await?;
1770
1771 let status = resp.status();
1772 let content_type = resp
1773 .headers()
1774 .get("content-type")
1775 .and_then(|v| v.to_str().ok())
1776 .unwrap_or("application/octet-stream");
1777 let content_type = super::ContentType::from(content_type);
1778
1779 if !status.is_client_error() && !status.is_server_error() {
1780 let content = resp.text().await?;
1781 match content_type {
1782 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1783 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
1784 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
1785 }
1786 } else {
1787 let content = resp.text().await?;
1788 let entity: Option<UpdateMailTemplateError> = serde_json::from_str(&content).ok();
1789 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1790 }
1791}
1792
1793pub async fn workspace_add_mail_message_labels(configuration: &configuration::Configuration, org: &str, workspace: &str, message_id: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceAddMailMessageLabelsError>> {
1794 let p_path_org = org;
1796 let p_path_workspace = workspace;
1797 let p_path_message_id = message_id;
1798 let p_body_request_body = request_body;
1799
1800 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/mail/{messageId}/labels", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), messageId=crate::apis::urlencode(p_path_message_id));
1801 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1802
1803 if let Some(ref user_agent) = configuration.user_agent {
1804 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1805 }
1806 if let Some(ref token) = configuration.bearer_access_token {
1807 req_builder = req_builder.bearer_auth(token.to_owned());
1808 };
1809 req_builder = req_builder.json(&p_body_request_body);
1810
1811 let req = req_builder.build()?;
1812 let resp = configuration.client.execute(req).await?;
1813
1814 let status = resp.status();
1815 let content_type = resp
1816 .headers()
1817 .get("content-type")
1818 .and_then(|v| v.to_str().ok())
1819 .unwrap_or("application/octet-stream");
1820 let content_type = super::ContentType::from(content_type);
1821
1822 if !status.is_client_error() && !status.is_server_error() {
1823 let content = resp.text().await?;
1824 match content_type {
1825 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1826 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
1827 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
1828 }
1829 } else {
1830 let content = resp.text().await?;
1831 let entity: Option<WorkspaceAddMailMessageLabelsError> = serde_json::from_str(&content).ok();
1832 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1833 }
1834}
1835
1836pub async fn workspace_create_mail_draft(configuration: &configuration::Configuration, org: &str, workspace: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceCreateMailDraftError>> {
1837 let p_path_org = org;
1839 let p_path_workspace = workspace;
1840 let p_body_request_body = request_body;
1841
1842 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/mail/drafts", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
1843 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1844
1845 if let Some(ref user_agent) = configuration.user_agent {
1846 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1847 }
1848 if let Some(ref token) = configuration.bearer_access_token {
1849 req_builder = req_builder.bearer_auth(token.to_owned());
1850 };
1851 req_builder = req_builder.json(&p_body_request_body);
1852
1853 let req = req_builder.build()?;
1854 let resp = configuration.client.execute(req).await?;
1855
1856 let status = resp.status();
1857 let content_type = resp
1858 .headers()
1859 .get("content-type")
1860 .and_then(|v| v.to_str().ok())
1861 .unwrap_or("application/octet-stream");
1862 let content_type = super::ContentType::from(content_type);
1863
1864 if !status.is_client_error() && !status.is_server_error() {
1865 let content = resp.text().await?;
1866 match content_type {
1867 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1868 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
1869 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
1870 }
1871 } else {
1872 let content = resp.text().await?;
1873 let entity: Option<WorkspaceCreateMailDraftError> = serde_json::from_str(&content).ok();
1874 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1875 }
1876}
1877
1878pub async fn workspace_create_mail_label(configuration: &configuration::Configuration, org: &str, workspace: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceCreateMailLabelError>> {
1879 let p_path_org = org;
1881 let p_path_workspace = workspace;
1882 let p_body_request_body = request_body;
1883
1884 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/mail/labels", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
1885 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1886
1887 if let Some(ref user_agent) = configuration.user_agent {
1888 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1889 }
1890 if let Some(ref token) = configuration.bearer_access_token {
1891 req_builder = req_builder.bearer_auth(token.to_owned());
1892 };
1893 req_builder = req_builder.json(&p_body_request_body);
1894
1895 let req = req_builder.build()?;
1896 let resp = configuration.client.execute(req).await?;
1897
1898 let status = resp.status();
1899 let content_type = resp
1900 .headers()
1901 .get("content-type")
1902 .and_then(|v| v.to_str().ok())
1903 .unwrap_or("application/octet-stream");
1904 let content_type = super::ContentType::from(content_type);
1905
1906 if !status.is_client_error() && !status.is_server_error() {
1907 let content = resp.text().await?;
1908 match content_type {
1909 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1910 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
1911 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
1912 }
1913 } else {
1914 let content = resp.text().await?;
1915 let entity: Option<WorkspaceCreateMailLabelError> = serde_json::from_str(&content).ok();
1916 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1917 }
1918}
1919
1920pub async fn workspace_delete_mail(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str) -> Result<(), Error<WorkspaceDeleteMailError>> {
1921 let p_path_org = org;
1923 let p_path_workspace = workspace;
1924 let p_path_id = id;
1925
1926 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/mail/email/{id}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
1927 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1928
1929 if let Some(ref user_agent) = configuration.user_agent {
1930 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1931 }
1932 if let Some(ref token) = configuration.bearer_access_token {
1933 req_builder = req_builder.bearer_auth(token.to_owned());
1934 };
1935
1936 let req = req_builder.build()?;
1937 let resp = configuration.client.execute(req).await?;
1938
1939 let status = resp.status();
1940
1941 if !status.is_client_error() && !status.is_server_error() {
1942 Ok(())
1943 } else {
1944 let content = resp.text().await?;
1945 let entity: Option<WorkspaceDeleteMailError> = serde_json::from_str(&content).ok();
1946 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1947 }
1948}
1949
1950pub async fn workspace_delete_mail_draft(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str) -> Result<(), Error<WorkspaceDeleteMailDraftError>> {
1951 let p_path_org = org;
1953 let p_path_workspace = workspace;
1954 let p_path_id = id;
1955
1956 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/mail/drafts/{id}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
1957 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1958
1959 if let Some(ref user_agent) = configuration.user_agent {
1960 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1961 }
1962 if let Some(ref token) = configuration.bearer_access_token {
1963 req_builder = req_builder.bearer_auth(token.to_owned());
1964 };
1965
1966 let req = req_builder.build()?;
1967 let resp = configuration.client.execute(req).await?;
1968
1969 let status = resp.status();
1970
1971 if !status.is_client_error() && !status.is_server_error() {
1972 Ok(())
1973 } else {
1974 let content = resp.text().await?;
1975 let entity: Option<WorkspaceDeleteMailDraftError> = serde_json::from_str(&content).ok();
1976 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1977 }
1978}
1979
1980pub async fn workspace_delete_mail_label(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str) -> Result<(), Error<WorkspaceDeleteMailLabelError>> {
1981 let p_path_org = org;
1983 let p_path_workspace = workspace;
1984 let p_path_id = id;
1985
1986 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/mail/labels/{id}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
1987 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1988
1989 if let Some(ref user_agent) = configuration.user_agent {
1990 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1991 }
1992 if let Some(ref token) = configuration.bearer_access_token {
1993 req_builder = req_builder.bearer_auth(token.to_owned());
1994 };
1995
1996 let req = req_builder.build()?;
1997 let resp = configuration.client.execute(req).await?;
1998
1999 let status = resp.status();
2000
2001 if !status.is_client_error() && !status.is_server_error() {
2002 Ok(())
2003 } else {
2004 let content = resp.text().await?;
2005 let entity: Option<WorkspaceDeleteMailLabelError> = serde_json::from_str(&content).ok();
2006 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2007 }
2008}
2009
2010pub async fn workspace_get_mail(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceGetMailError>> {
2011 let p_path_org = org;
2013 let p_path_workspace = workspace;
2014 let p_path_id = id;
2015
2016 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/mail/email/{id}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
2017 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2018
2019 if let Some(ref user_agent) = configuration.user_agent {
2020 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2021 }
2022 if let Some(ref token) = configuration.bearer_access_token {
2023 req_builder = req_builder.bearer_auth(token.to_owned());
2024 };
2025
2026 let req = req_builder.build()?;
2027 let resp = configuration.client.execute(req).await?;
2028
2029 let status = resp.status();
2030 let content_type = resp
2031 .headers()
2032 .get("content-type")
2033 .and_then(|v| v.to_str().ok())
2034 .unwrap_or("application/octet-stream");
2035 let content_type = super::ContentType::from(content_type);
2036
2037 if !status.is_client_error() && !status.is_server_error() {
2038 let content = resp.text().await?;
2039 match content_type {
2040 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2041 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
2042 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
2043 }
2044 } else {
2045 let content = resp.text().await?;
2046 let entity: Option<WorkspaceGetMailError> = serde_json::from_str(&content).ok();
2047 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2048 }
2049}
2050
2051pub async fn workspace_get_mail_attachment(configuration: &configuration::Configuration, org: &str, workspace: &str, message_id: &str, attachment_id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceGetMailAttachmentError>> {
2052 let p_path_org = org;
2054 let p_path_workspace = workspace;
2055 let p_path_message_id = message_id;
2056 let p_path_attachment_id = attachment_id;
2057
2058 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/mail/attachment/{messageId}/{attachmentId}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), messageId=crate::apis::urlencode(p_path_message_id), attachmentId=crate::apis::urlencode(p_path_attachment_id));
2059 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2060
2061 if let Some(ref user_agent) = configuration.user_agent {
2062 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2063 }
2064 if let Some(ref token) = configuration.bearer_access_token {
2065 req_builder = req_builder.bearer_auth(token.to_owned());
2066 };
2067
2068 let req = req_builder.build()?;
2069 let resp = configuration.client.execute(req).await?;
2070
2071 let status = resp.status();
2072 let content_type = resp
2073 .headers()
2074 .get("content-type")
2075 .and_then(|v| v.to_str().ok())
2076 .unwrap_or("application/octet-stream");
2077 let content_type = super::ContentType::from(content_type);
2078
2079 if !status.is_client_error() && !status.is_server_error() {
2080 let content = resp.text().await?;
2081 match content_type {
2082 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2083 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
2084 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
2085 }
2086 } else {
2087 let content = resp.text().await?;
2088 let entity: Option<WorkspaceGetMailAttachmentError> = serde_json::from_str(&content).ok();
2089 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2090 }
2091}
2092
2093pub async fn workspace_get_mail_by_id(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceGetMailByIdError>> {
2094 let p_path_org = org;
2096 let p_path_workspace = workspace;
2097 let p_path_id = id;
2098
2099 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/mail/{id}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
2100 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2101
2102 if let Some(ref user_agent) = configuration.user_agent {
2103 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2104 }
2105 if let Some(ref token) = configuration.bearer_access_token {
2106 req_builder = req_builder.bearer_auth(token.to_owned());
2107 };
2108
2109 let req = req_builder.build()?;
2110 let resp = configuration.client.execute(req).await?;
2111
2112 let status = resp.status();
2113 let content_type = resp
2114 .headers()
2115 .get("content-type")
2116 .and_then(|v| v.to_str().ok())
2117 .unwrap_or("application/octet-stream");
2118 let content_type = super::ContentType::from(content_type);
2119
2120 if !status.is_client_error() && !status.is_server_error() {
2121 let content = resp.text().await?;
2122 match content_type {
2123 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2124 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
2125 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
2126 }
2127 } else {
2128 let content = resp.text().await?;
2129 let entity: Option<WorkspaceGetMailByIdError> = serde_json::from_str(&content).ok();
2130 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2131 }
2132}
2133
2134pub async fn workspace_get_mail_draft(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceGetMailDraftError>> {
2135 let p_path_org = org;
2137 let p_path_workspace = workspace;
2138 let p_path_id = id;
2139
2140 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/mail/drafts/{id}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
2141 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2142
2143 if let Some(ref user_agent) = configuration.user_agent {
2144 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2145 }
2146 if let Some(ref token) = configuration.bearer_access_token {
2147 req_builder = req_builder.bearer_auth(token.to_owned());
2148 };
2149
2150 let req = req_builder.build()?;
2151 let resp = configuration.client.execute(req).await?;
2152
2153 let status = resp.status();
2154 let content_type = resp
2155 .headers()
2156 .get("content-type")
2157 .and_then(|v| v.to_str().ok())
2158 .unwrap_or("application/octet-stream");
2159 let content_type = super::ContentType::from(content_type);
2160
2161 if !status.is_client_error() && !status.is_server_error() {
2162 let content = resp.text().await?;
2163 match content_type {
2164 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2165 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
2166 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
2167 }
2168 } else {
2169 let content = resp.text().await?;
2170 let entity: Option<WorkspaceGetMailDraftError> = serde_json::from_str(&content).ok();
2171 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2172 }
2173}
2174
2175pub async fn workspace_get_mail_thread(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceGetMailThreadError>> {
2176 let p_path_org = org;
2178 let p_path_workspace = workspace;
2179 let p_path_id = id;
2180
2181 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/mail/thread/{id}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
2182 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2183
2184 if let Some(ref user_agent) = configuration.user_agent {
2185 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2186 }
2187 if let Some(ref token) = configuration.bearer_access_token {
2188 req_builder = req_builder.bearer_auth(token.to_owned());
2189 };
2190
2191 let req = req_builder.build()?;
2192 let resp = configuration.client.execute(req).await?;
2193
2194 let status = resp.status();
2195 let content_type = resp
2196 .headers()
2197 .get("content-type")
2198 .and_then(|v| v.to_str().ok())
2199 .unwrap_or("application/octet-stream");
2200 let content_type = super::ContentType::from(content_type);
2201
2202 if !status.is_client_error() && !status.is_server_error() {
2203 let content = resp.text().await?;
2204 match content_type {
2205 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2206 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
2207 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
2208 }
2209 } else {
2210 let content = resp.text().await?;
2211 let entity: Option<WorkspaceGetMailThreadError> = serde_json::from_str(&content).ok();
2212 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2213 }
2214}
2215
2216pub async fn workspace_list_mail(configuration: &configuration::Configuration, org: &str, workspace: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceListMailError>> {
2217 let p_path_org = org;
2219 let p_path_workspace = workspace;
2220
2221 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/mail/list", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
2222 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2223
2224 if let Some(ref user_agent) = configuration.user_agent {
2225 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2226 }
2227 if let Some(ref token) = configuration.bearer_access_token {
2228 req_builder = req_builder.bearer_auth(token.to_owned());
2229 };
2230
2231 let req = req_builder.build()?;
2232 let resp = configuration.client.execute(req).await?;
2233
2234 let status = resp.status();
2235 let content_type = resp
2236 .headers()
2237 .get("content-type")
2238 .and_then(|v| v.to_str().ok())
2239 .unwrap_or("application/octet-stream");
2240 let content_type = super::ContentType::from(content_type);
2241
2242 if !status.is_client_error() && !status.is_server_error() {
2243 let content = resp.text().await?;
2244 match content_type {
2245 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2246 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
2247 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
2248 }
2249 } else {
2250 let content = resp.text().await?;
2251 let entity: Option<WorkspaceListMailError> = serde_json::from_str(&content).ok();
2252 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2253 }
2254}
2255
2256pub async fn workspace_list_mail_drafts(configuration: &configuration::Configuration, org: &str, workspace: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceListMailDraftsError>> {
2257 let p_path_org = org;
2259 let p_path_workspace = workspace;
2260
2261 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/mail/drafts", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
2262 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2263
2264 if let Some(ref user_agent) = configuration.user_agent {
2265 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2266 }
2267 if let Some(ref token) = configuration.bearer_access_token {
2268 req_builder = req_builder.bearer_auth(token.to_owned());
2269 };
2270
2271 let req = req_builder.build()?;
2272 let resp = configuration.client.execute(req).await?;
2273
2274 let status = resp.status();
2275 let content_type = resp
2276 .headers()
2277 .get("content-type")
2278 .and_then(|v| v.to_str().ok())
2279 .unwrap_or("application/octet-stream");
2280 let content_type = super::ContentType::from(content_type);
2281
2282 if !status.is_client_error() && !status.is_server_error() {
2283 let content = resp.text().await?;
2284 match content_type {
2285 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2286 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
2287 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
2288 }
2289 } else {
2290 let content = resp.text().await?;
2291 let entity: Option<WorkspaceListMailDraftsError> = serde_json::from_str(&content).ok();
2292 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2293 }
2294}
2295
2296pub async fn workspace_list_mail_labels(configuration: &configuration::Configuration, org: &str, workspace: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceListMailLabelsError>> {
2297 let p_path_org = org;
2299 let p_path_workspace = workspace;
2300
2301 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/mail/labels", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
2302 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2303
2304 if let Some(ref user_agent) = configuration.user_agent {
2305 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2306 }
2307 if let Some(ref token) = configuration.bearer_access_token {
2308 req_builder = req_builder.bearer_auth(token.to_owned());
2309 };
2310
2311 let req = req_builder.build()?;
2312 let resp = configuration.client.execute(req).await?;
2313
2314 let status = resp.status();
2315 let content_type = resp
2316 .headers()
2317 .get("content-type")
2318 .and_then(|v| v.to_str().ok())
2319 .unwrap_or("application/octet-stream");
2320 let content_type = super::ContentType::from(content_type);
2321
2322 if !status.is_client_error() && !status.is_server_error() {
2323 let content = resp.text().await?;
2324 match content_type {
2325 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2326 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
2327 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
2328 }
2329 } else {
2330 let content = resp.text().await?;
2331 let entity: Option<WorkspaceListMailLabelsError> = serde_json::from_str(&content).ok();
2332 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2333 }
2334}
2335
2336pub async fn workspace_patch_mail(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspacePatchMailError>> {
2337 let p_path_org = org;
2339 let p_path_workspace = workspace;
2340 let p_path_id = id;
2341 let p_body_request_body = request_body;
2342
2343 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/mail/email/{id}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
2344 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
2345
2346 if let Some(ref user_agent) = configuration.user_agent {
2347 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2348 }
2349 if let Some(ref token) = configuration.bearer_access_token {
2350 req_builder = req_builder.bearer_auth(token.to_owned());
2351 };
2352 req_builder = req_builder.json(&p_body_request_body);
2353
2354 let req = req_builder.build()?;
2355 let resp = configuration.client.execute(req).await?;
2356
2357 let status = resp.status();
2358 let content_type = resp
2359 .headers()
2360 .get("content-type")
2361 .and_then(|v| v.to_str().ok())
2362 .unwrap_or("application/octet-stream");
2363 let content_type = super::ContentType::from(content_type);
2364
2365 if !status.is_client_error() && !status.is_server_error() {
2366 let content = resp.text().await?;
2367 match content_type {
2368 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2369 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
2370 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
2371 }
2372 } else {
2373 let content = resp.text().await?;
2374 let entity: Option<WorkspacePatchMailError> = serde_json::from_str(&content).ok();
2375 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2376 }
2377}
2378
2379pub async fn workspace_remove_mail_message_label(configuration: &configuration::Configuration, org: &str, workspace: &str, message_id: &str, label_id: &str) -> Result<(), Error<WorkspaceRemoveMailMessageLabelError>> {
2380 let p_path_org = org;
2382 let p_path_workspace = workspace;
2383 let p_path_message_id = message_id;
2384 let p_path_label_id = label_id;
2385
2386 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/mail/{messageId}/labels/{labelId}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), messageId=crate::apis::urlencode(p_path_message_id), labelId=crate::apis::urlencode(p_path_label_id));
2387 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
2388
2389 if let Some(ref user_agent) = configuration.user_agent {
2390 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2391 }
2392 if let Some(ref token) = configuration.bearer_access_token {
2393 req_builder = req_builder.bearer_auth(token.to_owned());
2394 };
2395
2396 let req = req_builder.build()?;
2397 let resp = configuration.client.execute(req).await?;
2398
2399 let status = resp.status();
2400
2401 if !status.is_client_error() && !status.is_server_error() {
2402 Ok(())
2403 } else {
2404 let content = resp.text().await?;
2405 let entity: Option<WorkspaceRemoveMailMessageLabelError> = serde_json::from_str(&content).ok();
2406 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2407 }
2408}
2409
2410pub async fn workspace_reply_mail(configuration: &configuration::Configuration, org: &str, workspace: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceReplyMailError>> {
2411 let p_path_org = org;
2413 let p_path_workspace = workspace;
2414 let p_body_request_body = request_body;
2415
2416 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/mail/reply", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
2417 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2418
2419 if let Some(ref user_agent) = configuration.user_agent {
2420 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2421 }
2422 if let Some(ref token) = configuration.bearer_access_token {
2423 req_builder = req_builder.bearer_auth(token.to_owned());
2424 };
2425 req_builder = req_builder.json(&p_body_request_body);
2426
2427 let req = req_builder.build()?;
2428 let resp = configuration.client.execute(req).await?;
2429
2430 let status = resp.status();
2431 let content_type = resp
2432 .headers()
2433 .get("content-type")
2434 .and_then(|v| v.to_str().ok())
2435 .unwrap_or("application/octet-stream");
2436 let content_type = super::ContentType::from(content_type);
2437
2438 if !status.is_client_error() && !status.is_server_error() {
2439 let content = resp.text().await?;
2440 match content_type {
2441 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2442 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
2443 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
2444 }
2445 } else {
2446 let content = resp.text().await?;
2447 let entity: Option<WorkspaceReplyMailError> = serde_json::from_str(&content).ok();
2448 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2449 }
2450}
2451
2452pub async fn workspace_search_mail(configuration: &configuration::Configuration, org: &str, workspace: &str, q: Option<&str>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceSearchMailError>> {
2453 let p_path_org = org;
2455 let p_path_workspace = workspace;
2456 let p_query_q = q;
2457
2458 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/mail/search", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
2459 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2460
2461 if let Some(ref param_value) = p_query_q {
2462 req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
2463 }
2464 if let Some(ref user_agent) = configuration.user_agent {
2465 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2466 }
2467 if let Some(ref token) = configuration.bearer_access_token {
2468 req_builder = req_builder.bearer_auth(token.to_owned());
2469 };
2470
2471 let req = req_builder.build()?;
2472 let resp = configuration.client.execute(req).await?;
2473
2474 let status = resp.status();
2475 let content_type = resp
2476 .headers()
2477 .get("content-type")
2478 .and_then(|v| v.to_str().ok())
2479 .unwrap_or("application/octet-stream");
2480 let content_type = super::ContentType::from(content_type);
2481
2482 if !status.is_client_error() && !status.is_server_error() {
2483 let content = resp.text().await?;
2484 match content_type {
2485 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2486 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
2487 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
2488 }
2489 } else {
2490 let content = resp.text().await?;
2491 let entity: Option<WorkspaceSearchMailError> = serde_json::from_str(&content).ok();
2492 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2493 }
2494}
2495
2496pub async fn workspace_send_mail(configuration: &configuration::Configuration, org: &str, workspace: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceSendMailError>> {
2497 let p_path_org = org;
2499 let p_path_workspace = workspace;
2500 let p_body_request_body = request_body;
2501
2502 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/mail/send", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
2503 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2504
2505 if let Some(ref user_agent) = configuration.user_agent {
2506 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2507 }
2508 if let Some(ref token) = configuration.bearer_access_token {
2509 req_builder = req_builder.bearer_auth(token.to_owned());
2510 };
2511 req_builder = req_builder.json(&p_body_request_body);
2512
2513 let req = req_builder.build()?;
2514 let resp = configuration.client.execute(req).await?;
2515
2516 let status = resp.status();
2517 let content_type = resp
2518 .headers()
2519 .get("content-type")
2520 .and_then(|v| v.to_str().ok())
2521 .unwrap_or("application/octet-stream");
2522 let content_type = super::ContentType::from(content_type);
2523
2524 if !status.is_client_error() && !status.is_server_error() {
2525 let content = resp.text().await?;
2526 match content_type {
2527 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2528 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
2529 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
2530 }
2531 } else {
2532 let content = resp.text().await?;
2533 let entity: Option<WorkspaceSendMailError> = serde_json::from_str(&content).ok();
2534 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2535 }
2536}
2537
2538pub async fn workspace_send_mail_draft(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceSendMailDraftError>> {
2539 let p_path_org = org;
2541 let p_path_workspace = workspace;
2542 let p_path_id = id;
2543
2544 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/mail/drafts/{id}/send", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
2545 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2546
2547 if let Some(ref user_agent) = configuration.user_agent {
2548 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2549 }
2550 if let Some(ref token) = configuration.bearer_access_token {
2551 req_builder = req_builder.bearer_auth(token.to_owned());
2552 };
2553
2554 let req = req_builder.build()?;
2555 let resp = configuration.client.execute(req).await?;
2556
2557 let status = resp.status();
2558 let content_type = resp
2559 .headers()
2560 .get("content-type")
2561 .and_then(|v| v.to_str().ok())
2562 .unwrap_or("application/octet-stream");
2563 let content_type = super::ContentType::from(content_type);
2564
2565 if !status.is_client_error() && !status.is_server_error() {
2566 let content = resp.text().await?;
2567 match content_type {
2568 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2569 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
2570 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
2571 }
2572 } else {
2573 let content = resp.text().await?;
2574 let entity: Option<WorkspaceSendMailDraftError> = serde_json::from_str(&content).ok();
2575 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2576 }
2577}
2578
2579pub async fn workspace_send_mail_email_alias(configuration: &configuration::Configuration, org: &str, workspace: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceSendMailEmailAliasError>> {
2580 let p_path_org = org;
2582 let p_path_workspace = workspace;
2583 let p_body_request_body = request_body;
2584
2585 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/mail/email", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
2586 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
2587
2588 if let Some(ref user_agent) = configuration.user_agent {
2589 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2590 }
2591 if let Some(ref token) = configuration.bearer_access_token {
2592 req_builder = req_builder.bearer_auth(token.to_owned());
2593 };
2594 req_builder = req_builder.json(&p_body_request_body);
2595
2596 let req = req_builder.build()?;
2597 let resp = configuration.client.execute(req).await?;
2598
2599 let status = resp.status();
2600 let content_type = resp
2601 .headers()
2602 .get("content-type")
2603 .and_then(|v| v.to_str().ok())
2604 .unwrap_or("application/octet-stream");
2605 let content_type = super::ContentType::from(content_type);
2606
2607 if !status.is_client_error() && !status.is_server_error() {
2608 let content = resp.text().await?;
2609 match content_type {
2610 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2611 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
2612 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
2613 }
2614 } else {
2615 let content = resp.text().await?;
2616 let entity: Option<WorkspaceSendMailEmailAliasError> = serde_json::from_str(&content).ok();
2617 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2618 }
2619}
2620
2621pub async fn workspace_update_mail(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceUpdateMailError>> {
2622 let p_path_org = org;
2624 let p_path_workspace = workspace;
2625 let p_path_id = id;
2626 let p_body_request_body = request_body;
2627
2628 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/mail/email/{id}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
2629 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
2630
2631 if let Some(ref user_agent) = configuration.user_agent {
2632 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2633 }
2634 if let Some(ref token) = configuration.bearer_access_token {
2635 req_builder = req_builder.bearer_auth(token.to_owned());
2636 };
2637 req_builder = req_builder.json(&p_body_request_body);
2638
2639 let req = req_builder.build()?;
2640 let resp = configuration.client.execute(req).await?;
2641
2642 let status = resp.status();
2643 let content_type = resp
2644 .headers()
2645 .get("content-type")
2646 .and_then(|v| v.to_str().ok())
2647 .unwrap_or("application/octet-stream");
2648 let content_type = super::ContentType::from(content_type);
2649
2650 if !status.is_client_error() && !status.is_server_error() {
2651 let content = resp.text().await?;
2652 match content_type {
2653 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2654 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
2655 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
2656 }
2657 } else {
2658 let content = resp.text().await?;
2659 let entity: Option<WorkspaceUpdateMailError> = serde_json::from_str(&content).ok();
2660 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2661 }
2662}
2663
2664pub async fn workspace_update_mail_draft(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceUpdateMailDraftError>> {
2665 let p_path_org = org;
2667 let p_path_workspace = workspace;
2668 let p_path_id = id;
2669 let p_body_request_body = request_body;
2670
2671 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/mail/drafts/{id}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
2672 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
2673
2674 if let Some(ref user_agent) = configuration.user_agent {
2675 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2676 }
2677 if let Some(ref token) = configuration.bearer_access_token {
2678 req_builder = req_builder.bearer_auth(token.to_owned());
2679 };
2680 req_builder = req_builder.json(&p_body_request_body);
2681
2682 let req = req_builder.build()?;
2683 let resp = configuration.client.execute(req).await?;
2684
2685 let status = resp.status();
2686 let content_type = resp
2687 .headers()
2688 .get("content-type")
2689 .and_then(|v| v.to_str().ok())
2690 .unwrap_or("application/octet-stream");
2691 let content_type = super::ContentType::from(content_type);
2692
2693 if !status.is_client_error() && !status.is_server_error() {
2694 let content = resp.text().await?;
2695 match content_type {
2696 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2697 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
2698 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
2699 }
2700 } else {
2701 let content = resp.text().await?;
2702 let entity: Option<WorkspaceUpdateMailDraftError> = serde_json::from_str(&content).ok();
2703 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2704 }
2705}
2706
2707pub async fn workspace_update_mail_label(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceUpdateMailLabelError>> {
2708 let p_path_org = org;
2710 let p_path_workspace = workspace;
2711 let p_path_id = id;
2712 let p_body_request_body = request_body;
2713
2714 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/mail/labels/{id}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
2715 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
2716
2717 if let Some(ref user_agent) = configuration.user_agent {
2718 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2719 }
2720 if let Some(ref token) = configuration.bearer_access_token {
2721 req_builder = req_builder.bearer_auth(token.to_owned());
2722 };
2723 req_builder = req_builder.json(&p_body_request_body);
2724
2725 let req = req_builder.build()?;
2726 let resp = configuration.client.execute(req).await?;
2727
2728 let status = resp.status();
2729 let content_type = resp
2730 .headers()
2731 .get("content-type")
2732 .and_then(|v| v.to_str().ok())
2733 .unwrap_or("application/octet-stream");
2734 let content_type = super::ContentType::from(content_type);
2735
2736 if !status.is_client_error() && !status.is_server_error() {
2737 let content = resp.text().await?;
2738 match content_type {
2739 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2740 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
2741 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
2742 }
2743 } else {
2744 let content = resp.text().await?;
2745 let entity: Option<WorkspaceUpdateMailLabelError> = serde_json::from_str(&content).ok();
2746 Err(Error::ResponseError(ResponseContent { status, content, entity }))
2747 }
2748}
2749