mailslurp/apis/
inbox_controller_api.rs

1/*
2 * MailSlurp API
3 *
4 * MailSlurp is an API for sending and receiving emails from dynamically allocated email addresses. It's designed for developers and QA teams to test applications, process inbound emails, send templated notifications, attachments, and more.  ## Resources  - [Homepage](https://www.mailslurp.com) - Get an [API KEY](https://app.mailslurp.com/sign-up/) - Generated [SDK Clients](https://www.mailslurp.com/docs/) - [Examples](https://github.com/mailslurp/examples) repository
5 *
6 * The version of the OpenAPI document: 6.5.2
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17/// struct for passing parameters to the method `create_inbox`
18#[derive(Clone, Debug)]
19pub struct CreateInboxParams {
20    /// DEPRECATED (team access is always true). Grant team access to this inbox and the emails that belong to it for team members of your organization.
21    pub allow_team_access: Option<bool>,
22    /// Optional description of the inbox for labelling purposes. Is shown in the dashboard and can be used with
23    pub description: Option<String>,
24    /// A custom email address to use with the inbox. Defaults to null. When null MailSlurp will assign a random email address to the inbox such as `123@mailslurp.com`. If you use the `useDomainPool` option when the email address is null it will generate an email address with a more varied domain ending such as `123@mailslurp.info` or `123@mailslurp.biz`. When a custom email address is provided the address is split into a domain and the domain is queried against your user. If you have created the domain in the MailSlurp dashboard and verified it you can use any email address that ends with the domain. Note domain types must match the inbox type - so `SMTP` inboxes will only work with `SMTP` type domains. Send an email to this address and the inbox will receive and store it for you. To retrieve the email use the Inbox and Email Controller endpoints with the inbox ID.
25    pub email_address: Option<String>,
26    /// Optional inbox expiration date. If null then this inbox is permanent and the emails in it won't be deleted. If an expiration date is provided or is required by your plan the inbox will be closed when the expiration time is reached. Expired inboxes still contain their emails but can no longer send or receive emails. An ExpiredInboxRecord is created when an inbox and the email address and inbox ID are recorded. The expiresAt property is a timestamp string in ISO DateTime Format yyyy-MM-dd'T'HH:mm:ss.SSSXXX.
27    pub expires_at: Option<String>,
28    /// Number of milliseconds that inbox should exist for
29    pub expires_in: Option<i64>,
30    /// Is the inbox a favorite. Marking an inbox as a favorite is typically done in the dashboard for quick access or filtering
31    pub favourite: Option<bool>,
32    /// HTTP (default) or SMTP inbox type. HTTP inboxes are best for testing while SMTP inboxes are more reliable for public inbound email consumption. When using custom domains the domain type must match the inbox type. HTTP inboxes are processed by AWS SES while SMTP inboxes use a custom mail server running at `mx.mailslurp.com`.
33    pub inbox_type: Option<String>,
34    /// Optional name of the inbox. Displayed in the dashboard for easier search and used as the sender name when sending emails.
35    pub name: Option<String>,
36    /// Tags that inbox has been tagged with. Tags can be added to inboxes to group different inboxes within an account. You can also search for inboxes by tag in the dashboard UI.
37    pub tags: Option<Vec<String>>,
38    /// Use the MailSlurp domain name pool with this inbox when creating the email address. Defaults to null. If enabled the inbox will be an email address with a domain randomly chosen from a list of the MailSlurp domains. This is useful when the default `@mailslurp.com` email addresses used with inboxes are blocked or considered spam by a provider or receiving service. When domain pool is enabled an email address will be generated ending in `@mailslurp.{world,info,xyz,...}` . This means a TLD is randomly selecting from a list of `.biz`, `.info`, `.xyz` etc to add variance to the generated email addresses. When null or false MailSlurp uses the default behavior of `@mailslurp.com` or custom email address provided by the emailAddress field. Note this feature is only available for `HTTP` inbox types.
39    pub use_domain_pool: Option<bool>
40}
41
42/// struct for passing parameters to the method `create_inbox_ruleset`
43#[derive(Clone, Debug)]
44pub struct CreateInboxRulesetParams {
45    /// inboxId
46    pub inbox_id: String,
47    /// createInboxRulesetOptions
48    pub create_inbox_ruleset_options: crate::models::CreateInboxRulesetOptions
49}
50
51/// struct for passing parameters to the method `create_inbox_with_options`
52#[derive(Clone, Debug)]
53pub struct CreateInboxWithOptionsParams {
54    /// createInboxDto
55    pub create_inbox_dto: crate::models::CreateInboxDto
56}
57
58/// struct for passing parameters to the method `delete_inbox`
59#[derive(Clone, Debug)]
60pub struct DeleteInboxParams {
61    /// inboxId
62    pub inbox_id: String
63}
64
65/// struct for passing parameters to the method `get_all_inboxes`
66#[derive(Clone, Debug)]
67pub struct GetAllInboxesParams {
68    /// Optional filter by created before given date time
69    pub before: Option<String>,
70    /// Optionally filter results for favourites only
71    pub favourite: Option<bool>,
72    /// Optional page index in list pagination
73    pub page: Option<i32>,
74    /// Optionally filter by search words partial matching ID, tags, name, and email address
75    pub search: Option<String>,
76    /// Optional filter by created after given date time
77    pub since: Option<String>,
78    /// Optional page size in list pagination
79    pub size: Option<i32>,
80    /// Optional createdAt sort direction ASC or DESC
81    pub sort: Option<String>,
82    /// Optionally filter by tags. Will return inboxes that include given tags
83    pub tag: Option<String>,
84    /// DEPRECATED. Optionally filter by team access.
85    pub team_access: Option<bool>
86}
87
88/// struct for passing parameters to the method `get_emails`
89#[derive(Clone, Debug)]
90pub struct GetEmailsParams {
91    /// Id of inbox that emails belongs to
92    pub inbox_id: String,
93    /// Exclude emails received after this ISO 8601 date time
94    pub before: Option<String>,
95    /// delayTimeout
96    pub delay_timeout: Option<i64>,
97    /// Limit the result set, ordered by received date time sort direction. Maximum 100. For more listing options see the email controller
98    pub limit: Option<i32>,
99    /// Minimum acceptable email count. Will cause request to hang (and retry) until minCount is satisfied or retryTimeout is reached.
100    pub min_count: Option<i64>,
101    /// Maximum milliseconds to spend retrying inbox database until minCount emails are returned
102    pub retry_timeout: Option<i64>,
103    /// Exclude emails received before this ISO 8601 date time
104    pub since: Option<String>,
105    /// Alias for limit. Assessed first before assessing any passed limit.
106    pub size: Option<i32>,
107    /// Sort the results by received date and direction ASC or DESC
108    pub sort: Option<String>,
109    /// unreadOnly
110    pub unread_only: Option<bool>
111}
112
113/// struct for passing parameters to the method `get_inbox`
114#[derive(Clone, Debug)]
115pub struct GetInboxParams {
116    /// inboxId
117    pub inbox_id: String
118}
119
120/// struct for passing parameters to the method `get_inbox_emails_paginated`
121#[derive(Clone, Debug)]
122pub struct GetInboxEmailsPaginatedParams {
123    /// Id of inbox that emails belongs to
124    pub inbox_id: String,
125    /// Optional filter by received before given date time
126    pub before: Option<String>,
127    /// Optional page index in inbox emails list pagination
128    pub page: Option<i32>,
129    /// Optional filter by received after given date time
130    pub since: Option<String>,
131    /// Optional page size in inbox emails list pagination
132    pub size: Option<i32>,
133    /// Optional createdAt sort direction ASC or DESC
134    pub sort: Option<String>
135}
136
137/// struct for passing parameters to the method `get_inbox_sent_emails`
138#[derive(Clone, Debug)]
139pub struct GetInboxSentEmailsParams {
140    /// inboxId
141    pub inbox_id: String,
142    /// Optional filter by sent before given date time
143    pub before: Option<String>,
144    /// Optional page index in inbox sent email list pagination
145    pub page: Option<i32>,
146    /// Optional sent email search
147    pub search_filter: Option<String>,
148    /// Optional filter by sent after given date time
149    pub since: Option<String>,
150    /// Optional page size in inbox sent email list pagination
151    pub size: Option<i32>,
152    /// Optional createdAt sort direction ASC or DESC
153    pub sort: Option<String>
154}
155
156/// struct for passing parameters to the method `get_inboxes`
157#[derive(Clone, Debug)]
158pub struct GetInboxesParams {
159    /// Optional filter by created before given date time
160    pub before: Option<String>,
161    /// Optional filter by created after given date time
162    pub since: Option<String>,
163    /// Optional result size limit. Note an automatic limit of 100 results is applied. See the paginated `getAllEmails` for larger queries.
164    pub size: Option<i32>,
165    /// Optional createdAt sort direction ASC or DESC
166    pub sort: Option<String>
167}
168
169/// struct for passing parameters to the method `get_organization_inboxes`
170#[derive(Clone, Debug)]
171pub struct GetOrganizationInboxesParams {
172    /// Optional filter by created before given date time
173    pub before: Option<String>,
174    /// Optional page index in list pagination
175    pub page: Option<i32>,
176    /// Optional search filter
177    pub search_filter: Option<String>,
178    /// Optional filter by created after given date time
179    pub since: Option<String>,
180    /// Optional page size in list pagination
181    pub size: Option<i32>,
182    /// Optional createdAt sort direction ASC or DESC
183    pub sort: Option<String>
184}
185
186/// struct for passing parameters to the method `list_inbox_rulesets`
187#[derive(Clone, Debug)]
188pub struct ListInboxRulesetsParams {
189    /// inboxId
190    pub inbox_id: String,
191    /// Optional filter by created before given date time
192    pub before: Option<String>,
193    /// Optional page index in inbox ruleset list pagination
194    pub page: Option<i32>,
195    /// Optional search filter
196    pub search_filter: Option<String>,
197    /// Optional filter by created after given date time
198    pub since: Option<String>,
199    /// Optional page size in inbox ruleset list pagination
200    pub size: Option<i32>,
201    /// Optional createdAt sort direction ASC or DESC
202    pub sort: Option<String>
203}
204
205/// struct for passing parameters to the method `list_inbox_tracking_pixels`
206#[derive(Clone, Debug)]
207pub struct ListInboxTrackingPixelsParams {
208    /// inboxId
209    pub inbox_id: String,
210    /// Optional filter by created before given date time
211    pub before: Option<String>,
212    /// Optional page index in inbox tracking pixel list pagination
213    pub page: Option<i32>,
214    /// Optional search filter
215    pub search_filter: Option<String>,
216    /// Optional filter by created after given date time
217    pub since: Option<String>,
218    /// Optional page size in inbox tracking pixel list pagination
219    pub size: Option<i32>,
220    /// Optional createdAt sort direction ASC or DESC
221    pub sort: Option<String>
222}
223
224/// struct for passing parameters to the method `send_email`
225#[derive(Clone, Debug)]
226pub struct SendEmailParams {
227    /// ID of the inbox you want to send the email from
228    pub inbox_id: String,
229    /// Options for the email
230    pub send_email_options: Option<crate::models::SendEmailOptions>
231}
232
233/// struct for passing parameters to the method `send_email_and_confirm`
234#[derive(Clone, Debug)]
235pub struct SendEmailAndConfirmParams {
236    /// ID of the inbox you want to send the email from
237    pub inbox_id: String,
238    /// Options for the email
239    pub send_email_options: Option<crate::models::SendEmailOptions>
240}
241
242/// struct for passing parameters to the method `send_test_email`
243#[derive(Clone, Debug)]
244pub struct SendTestEmailParams {
245    /// inboxId
246    pub inbox_id: String
247}
248
249/// struct for passing parameters to the method `set_inbox_favourited`
250#[derive(Clone, Debug)]
251pub struct SetInboxFavouritedParams {
252    /// inboxId
253    pub inbox_id: String,
254    /// setInboxFavouritedOptions
255    pub set_inbox_favourited_options: crate::models::SetInboxFavouritedOptions
256}
257
258/// struct for passing parameters to the method `update_inbox`
259#[derive(Clone, Debug)]
260pub struct UpdateInboxParams {
261    /// inboxId
262    pub inbox_id: String,
263    /// updateInboxOptions
264    pub update_inbox_options: crate::models::UpdateInboxOptions
265}
266
267
268/// struct for typed errors of method `create_inbox`
269#[derive(Debug, Clone, Serialize, Deserialize)]
270#[serde(untagged)]
271pub enum CreateInboxError {
272    Status401(),
273    Status403(),
274    Status404(),
275    UnknownValue(serde_json::Value),
276}
277
278/// struct for typed errors of method `create_inbox_ruleset`
279#[derive(Debug, Clone, Serialize, Deserialize)]
280#[serde(untagged)]
281pub enum CreateInboxRulesetError {
282    Status401(),
283    Status403(),
284    Status404(),
285    UnknownValue(serde_json::Value),
286}
287
288/// struct for typed errors of method `create_inbox_with_defaults`
289#[derive(Debug, Clone, Serialize, Deserialize)]
290#[serde(untagged)]
291pub enum CreateInboxWithDefaultsError {
292    Status401(),
293    Status403(),
294    Status404(),
295    UnknownValue(serde_json::Value),
296}
297
298/// struct for typed errors of method `create_inbox_with_options`
299#[derive(Debug, Clone, Serialize, Deserialize)]
300#[serde(untagged)]
301pub enum CreateInboxWithOptionsError {
302    Status401(),
303    Status403(),
304    Status404(),
305    UnknownValue(serde_json::Value),
306}
307
308/// struct for typed errors of method `delete_all_inboxes`
309#[derive(Debug, Clone, Serialize, Deserialize)]
310#[serde(untagged)]
311pub enum DeleteAllInboxesError {
312    Status401(),
313    Status403(),
314    UnknownValue(serde_json::Value),
315}
316
317/// struct for typed errors of method `delete_inbox`
318#[derive(Debug, Clone, Serialize, Deserialize)]
319#[serde(untagged)]
320pub enum DeleteInboxError {
321    Status401(),
322    Status403(),
323    UnknownValue(serde_json::Value),
324}
325
326/// struct for typed errors of method `get_all_inboxes`
327#[derive(Debug, Clone, Serialize, Deserialize)]
328#[serde(untagged)]
329pub enum GetAllInboxesError {
330    Status401(),
331    Status403(),
332    Status404(),
333    UnknownValue(serde_json::Value),
334}
335
336/// struct for typed errors of method `get_emails`
337#[derive(Debug, Clone, Serialize, Deserialize)]
338#[serde(untagged)]
339pub enum GetEmailsError {
340    Status401(),
341    Status403(),
342    Status404(),
343    UnknownValue(serde_json::Value),
344}
345
346/// struct for typed errors of method `get_inbox`
347#[derive(Debug, Clone, Serialize, Deserialize)]
348#[serde(untagged)]
349pub enum GetInboxError {
350    Status401(),
351    Status403(),
352    Status404(),
353    UnknownValue(serde_json::Value),
354}
355
356/// struct for typed errors of method `get_inbox_emails_paginated`
357#[derive(Debug, Clone, Serialize, Deserialize)]
358#[serde(untagged)]
359pub enum GetInboxEmailsPaginatedError {
360    Status401(),
361    Status403(),
362    Status404(),
363    UnknownValue(serde_json::Value),
364}
365
366/// struct for typed errors of method `get_inbox_sent_emails`
367#[derive(Debug, Clone, Serialize, Deserialize)]
368#[serde(untagged)]
369pub enum GetInboxSentEmailsError {
370    Status401(),
371    Status403(),
372    Status404(),
373    UnknownValue(serde_json::Value),
374}
375
376/// struct for typed errors of method `get_inbox_tags`
377#[derive(Debug, Clone, Serialize, Deserialize)]
378#[serde(untagged)]
379pub enum GetInboxTagsError {
380    Status401(),
381    Status403(),
382    Status404(),
383    UnknownValue(serde_json::Value),
384}
385
386/// struct for typed errors of method `get_inboxes`
387#[derive(Debug, Clone, Serialize, Deserialize)]
388#[serde(untagged)]
389pub enum GetInboxesError {
390    Status401(),
391    Status403(),
392    Status404(),
393    UnknownValue(serde_json::Value),
394}
395
396/// struct for typed errors of method `get_organization_inboxes`
397#[derive(Debug, Clone, Serialize, Deserialize)]
398#[serde(untagged)]
399pub enum GetOrganizationInboxesError {
400    Status401(),
401    Status403(),
402    Status404(),
403    UnknownValue(serde_json::Value),
404}
405
406/// struct for typed errors of method `list_inbox_rulesets`
407#[derive(Debug, Clone, Serialize, Deserialize)]
408#[serde(untagged)]
409pub enum ListInboxRulesetsError {
410    Status401(),
411    Status403(),
412    Status404(),
413    UnknownValue(serde_json::Value),
414}
415
416/// struct for typed errors of method `list_inbox_tracking_pixels`
417#[derive(Debug, Clone, Serialize, Deserialize)]
418#[serde(untagged)]
419pub enum ListInboxTrackingPixelsError {
420    Status401(),
421    Status403(),
422    Status404(),
423    UnknownValue(serde_json::Value),
424}
425
426/// struct for typed errors of method `send_email`
427#[derive(Debug, Clone, Serialize, Deserialize)]
428#[serde(untagged)]
429pub enum SendEmailError {
430    Status401(),
431    Status403(),
432    Status404(),
433    UnknownValue(serde_json::Value),
434}
435
436/// struct for typed errors of method `send_email_and_confirm`
437#[derive(Debug, Clone, Serialize, Deserialize)]
438#[serde(untagged)]
439pub enum SendEmailAndConfirmError {
440    Status401(),
441    Status403(),
442    Status404(),
443    UnknownValue(serde_json::Value),
444}
445
446/// struct for typed errors of method `send_test_email`
447#[derive(Debug, Clone, Serialize, Deserialize)]
448#[serde(untagged)]
449pub enum SendTestEmailError {
450    Status401(),
451    Status403(),
452    Status404(),
453    UnknownValue(serde_json::Value),
454}
455
456/// struct for typed errors of method `set_inbox_favourited`
457#[derive(Debug, Clone, Serialize, Deserialize)]
458#[serde(untagged)]
459pub enum SetInboxFavouritedError {
460    Status401(),
461    Status403(),
462    Status404(),
463    UnknownValue(serde_json::Value),
464}
465
466/// struct for typed errors of method `update_inbox`
467#[derive(Debug, Clone, Serialize, Deserialize)]
468#[serde(untagged)]
469pub enum UpdateInboxError {
470    Status401(),
471    Status403(),
472    UnknownValue(serde_json::Value),
473}
474
475
476/// Create a new inbox and with a randomized email address to send and receive from. Pass emailAddress parameter if you wish to use a specific email address. Creating an inbox is required before sending or receiving emails. If writing tests it is recommended that you create a new inbox during each test method so that it is unique and empty. 
477pub async fn create_inbox(configuration: &configuration::Configuration, params: CreateInboxParams) -> Result<crate::models::Inbox, Error<CreateInboxError>> {
478    // unbox the parameters
479    let allow_team_access = params.allow_team_access;
480    let description = params.description;
481    let email_address = params.email_address;
482    let expires_at = params.expires_at;
483    let expires_in = params.expires_in;
484    let favourite = params.favourite;
485    let inbox_type = params.inbox_type;
486    let name = params.name;
487    let tags = params.tags;
488    let use_domain_pool = params.use_domain_pool;
489
490
491    let local_var_client = &configuration.client;
492
493    let local_var_uri_str = format!("{}/inboxes", configuration.base_path);
494    let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
495
496    if let Some(ref local_var_str) = allow_team_access {
497        local_var_req_builder = local_var_req_builder.query(&[("allowTeamAccess", &local_var_str.to_string())]);
498    }
499    if let Some(ref local_var_str) = description {
500        local_var_req_builder = local_var_req_builder.query(&[("description", &local_var_str.to_string())]);
501    }
502    if let Some(ref local_var_str) = email_address {
503        local_var_req_builder = local_var_req_builder.query(&[("emailAddress", &local_var_str.to_string())]);
504    }
505    if let Some(ref local_var_str) = expires_at {
506        local_var_req_builder = local_var_req_builder.query(&[("expiresAt", &local_var_str.to_string())]);
507    }
508    if let Some(ref local_var_str) = expires_in {
509        local_var_req_builder = local_var_req_builder.query(&[("expiresIn", &local_var_str.to_string())]);
510    }
511    if let Some(ref local_var_str) = favourite {
512        local_var_req_builder = local_var_req_builder.query(&[("favourite", &local_var_str.to_string())]);
513    }
514    if let Some(ref local_var_str) = inbox_type {
515        local_var_req_builder = local_var_req_builder.query(&[("inboxType", &local_var_str.to_string())]);
516    }
517    if let Some(ref local_var_str) = name {
518        local_var_req_builder = local_var_req_builder.query(&[("name", &local_var_str.to_string())]);
519    }
520    if let Some(ref local_var_str) = tags {
521        local_var_req_builder = local_var_req_builder.query(&[("tags", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]);
522    }
523    if let Some(ref local_var_str) = use_domain_pool {
524        local_var_req_builder = local_var_req_builder.query(&[("useDomainPool", &local_var_str.to_string())]);
525    }
526    if let Some(ref local_var_user_agent) = configuration.user_agent {
527        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
528    }
529    if let Some(ref local_var_apikey) = configuration.api_key {
530        let local_var_key = local_var_apikey.key.clone();
531        let local_var_value = match local_var_apikey.prefix {
532            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
533            None => local_var_key,
534        };
535        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
536    };
537
538    let local_var_req = local_var_req_builder.build()?;
539    let local_var_resp = local_var_client.execute(local_var_req).await?;
540
541    let local_var_status = local_var_resp.status();
542    let local_var_content = local_var_resp.text().await?;
543
544    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
545        serde_json::from_str(&local_var_content).map_err(Error::from)
546    } else {
547        let local_var_entity: Option<CreateInboxError> = serde_json::from_str(&local_var_content).ok();
548        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
549        Err(Error::ResponseError(local_var_error))
550    }
551}
552
553/// Create a new inbox rule for forwarding, blocking, and allowing emails when sending and receiving
554pub async fn create_inbox_ruleset(configuration: &configuration::Configuration, params: CreateInboxRulesetParams) -> Result<crate::models::InboxRulesetDto, Error<CreateInboxRulesetError>> {
555    // unbox the parameters
556    let inbox_id = params.inbox_id;
557    let create_inbox_ruleset_options = params.create_inbox_ruleset_options;
558
559
560    let local_var_client = &configuration.client;
561
562    let local_var_uri_str = format!("{}/inboxes/{inboxId}/rulesets", configuration.base_path, inboxId=inbox_id);
563    let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
564
565    if let Some(ref local_var_user_agent) = configuration.user_agent {
566        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
567    }
568    if let Some(ref local_var_apikey) = configuration.api_key {
569        let local_var_key = local_var_apikey.key.clone();
570        let local_var_value = match local_var_apikey.prefix {
571            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
572            None => local_var_key,
573        };
574        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
575    };
576    local_var_req_builder = local_var_req_builder.json(&create_inbox_ruleset_options);
577
578    let local_var_req = local_var_req_builder.build()?;
579    let local_var_resp = local_var_client.execute(local_var_req).await?;
580
581    let local_var_status = local_var_resp.status();
582    let local_var_content = local_var_resp.text().await?;
583
584    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
585        serde_json::from_str(&local_var_content).map_err(Error::from)
586    } else {
587        let local_var_entity: Option<CreateInboxRulesetError> = serde_json::from_str(&local_var_content).ok();
588        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
589        Err(Error::ResponseError(local_var_error))
590    }
591}
592
593pub async fn create_inbox_with_defaults(configuration: &configuration::Configuration) -> Result<crate::models::Inbox, Error<CreateInboxWithDefaultsError>> {
594    // unbox the parameters
595
596
597    let local_var_client = &configuration.client;
598
599    let local_var_uri_str = format!("{}/inboxes/withDefaults", configuration.base_path);
600    let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
601
602    if let Some(ref local_var_user_agent) = configuration.user_agent {
603        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
604    }
605    if let Some(ref local_var_apikey) = configuration.api_key {
606        let local_var_key = local_var_apikey.key.clone();
607        let local_var_value = match local_var_apikey.prefix {
608            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
609            None => local_var_key,
610        };
611        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
612    };
613
614    let local_var_req = local_var_req_builder.build()?;
615    let local_var_resp = local_var_client.execute(local_var_req).await?;
616
617    let local_var_status = local_var_resp.status();
618    let local_var_content = local_var_resp.text().await?;
619
620    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
621        serde_json::from_str(&local_var_content).map_err(Error::from)
622    } else {
623        let local_var_entity: Option<CreateInboxWithDefaultsError> = serde_json::from_str(&local_var_content).ok();
624        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
625        Err(Error::ResponseError(local_var_error))
626    }
627}
628
629/// Additional endpoint that allows inbox creation with request body options. Can be more flexible that other methods for some clients.
630pub async fn create_inbox_with_options(configuration: &configuration::Configuration, params: CreateInboxWithOptionsParams) -> Result<crate::models::Inbox, Error<CreateInboxWithOptionsError>> {
631    // unbox the parameters
632    let create_inbox_dto = params.create_inbox_dto;
633
634
635    let local_var_client = &configuration.client;
636
637    let local_var_uri_str = format!("{}/inboxes/withOptions", configuration.base_path);
638    let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
639
640    if let Some(ref local_var_user_agent) = configuration.user_agent {
641        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
642    }
643    if let Some(ref local_var_apikey) = configuration.api_key {
644        let local_var_key = local_var_apikey.key.clone();
645        let local_var_value = match local_var_apikey.prefix {
646            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
647            None => local_var_key,
648        };
649        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
650    };
651    local_var_req_builder = local_var_req_builder.json(&create_inbox_dto);
652
653    let local_var_req = local_var_req_builder.build()?;
654    let local_var_resp = local_var_client.execute(local_var_req).await?;
655
656    let local_var_status = local_var_resp.status();
657    let local_var_content = local_var_resp.text().await?;
658
659    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
660        serde_json::from_str(&local_var_content).map_err(Error::from)
661    } else {
662        let local_var_entity: Option<CreateInboxWithOptionsError> = serde_json::from_str(&local_var_content).ok();
663        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
664        Err(Error::ResponseError(local_var_error))
665    }
666}
667
668/// Permanently delete all inboxes and associated email addresses. This will also delete all emails within the inboxes. Be careful as inboxes cannot be recovered once deleted. Note: deleting inboxes will not impact your usage limits. Monthly inbox creation limits are based on how many inboxes were created in the last 30 days, not how many inboxes you currently have.
669pub async fn delete_all_inboxes(configuration: &configuration::Configuration) -> Result<(), Error<DeleteAllInboxesError>> {
670    // unbox the parameters
671
672
673    let local_var_client = &configuration.client;
674
675    let local_var_uri_str = format!("{}/inboxes", configuration.base_path);
676    let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str());
677
678    if let Some(ref local_var_user_agent) = configuration.user_agent {
679        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
680    }
681    if let Some(ref local_var_apikey) = configuration.api_key {
682        let local_var_key = local_var_apikey.key.clone();
683        let local_var_value = match local_var_apikey.prefix {
684            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
685            None => local_var_key,
686        };
687        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
688    };
689
690    let local_var_req = local_var_req_builder.build()?;
691    let local_var_resp = local_var_client.execute(local_var_req).await?;
692
693    let local_var_status = local_var_resp.status();
694    let local_var_content = local_var_resp.text().await?;
695
696    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
697        Ok(())
698    } else {
699        let local_var_entity: Option<DeleteAllInboxesError> = serde_json::from_str(&local_var_content).ok();
700        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
701        Err(Error::ResponseError(local_var_error))
702    }
703}
704
705/// Permanently delete an inbox and associated email address as well as all emails within the given inbox. This action cannot be undone. Note: deleting an inbox will not affect your account usage. Monthly inbox usage is based on how many inboxes you create within 30 days, not how many exist at time of request.
706pub async fn delete_inbox(configuration: &configuration::Configuration, params: DeleteInboxParams) -> Result<(), Error<DeleteInboxError>> {
707    // unbox the parameters
708    let inbox_id = params.inbox_id;
709
710
711    let local_var_client = &configuration.client;
712
713    let local_var_uri_str = format!("{}/inboxes/{inboxId}", configuration.base_path, inboxId=inbox_id);
714    let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str());
715
716    if let Some(ref local_var_user_agent) = configuration.user_agent {
717        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
718    }
719    if let Some(ref local_var_apikey) = configuration.api_key {
720        let local_var_key = local_var_apikey.key.clone();
721        let local_var_value = match local_var_apikey.prefix {
722            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
723            None => local_var_key,
724        };
725        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
726    };
727
728    let local_var_req = local_var_req_builder.build()?;
729    let local_var_resp = local_var_client.execute(local_var_req).await?;
730
731    let local_var_status = local_var_resp.status();
732    let local_var_content = local_var_resp.text().await?;
733
734    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
735        Ok(())
736    } else {
737        let local_var_entity: Option<DeleteInboxError> = serde_json::from_str(&local_var_content).ok();
738        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
739        Err(Error::ResponseError(local_var_error))
740    }
741}
742
743/// List inboxes in paginated form. The results are available on the `content` property of the returned object. This method allows for page index (zero based), page size (how many results to return), and a sort direction (based on createdAt time). You Can also filter by whether an inbox is favorited or use email address pattern. This method is the recommended way to query inboxes. The alternative `getInboxes` method returns a full list of inboxes but is limited to 100 results.
744pub async fn get_all_inboxes(configuration: &configuration::Configuration, params: GetAllInboxesParams) -> Result<crate::models::PageInboxProjection, Error<GetAllInboxesError>> {
745    // unbox the parameters
746    let before = params.before;
747    let favourite = params.favourite;
748    let page = params.page;
749    let search = params.search;
750    let since = params.since;
751    let size = params.size;
752    let sort = params.sort;
753    let tag = params.tag;
754    let team_access = params.team_access;
755
756
757    let local_var_client = &configuration.client;
758
759    let local_var_uri_str = format!("{}/inboxes/paginated", configuration.base_path);
760    let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
761
762    if let Some(ref local_var_str) = before {
763        local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
764    }
765    if let Some(ref local_var_str) = favourite {
766        local_var_req_builder = local_var_req_builder.query(&[("favourite", &local_var_str.to_string())]);
767    }
768    if let Some(ref local_var_str) = page {
769        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
770    }
771    if let Some(ref local_var_str) = search {
772        local_var_req_builder = local_var_req_builder.query(&[("search", &local_var_str.to_string())]);
773    }
774    if let Some(ref local_var_str) = since {
775        local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
776    }
777    if let Some(ref local_var_str) = size {
778        local_var_req_builder = local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
779    }
780    if let Some(ref local_var_str) = sort {
781        local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
782    }
783    if let Some(ref local_var_str) = tag {
784        local_var_req_builder = local_var_req_builder.query(&[("tag", &local_var_str.to_string())]);
785    }
786    if let Some(ref local_var_str) = team_access {
787        local_var_req_builder = local_var_req_builder.query(&[("teamAccess", &local_var_str.to_string())]);
788    }
789    if let Some(ref local_var_user_agent) = configuration.user_agent {
790        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
791    }
792    if let Some(ref local_var_apikey) = configuration.api_key {
793        let local_var_key = local_var_apikey.key.clone();
794        let local_var_value = match local_var_apikey.prefix {
795            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
796            None => local_var_key,
797        };
798        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
799    };
800
801    let local_var_req = local_var_req_builder.build()?;
802    let local_var_resp = local_var_client.execute(local_var_req).await?;
803
804    let local_var_status = local_var_resp.status();
805    let local_var_content = local_var_resp.text().await?;
806
807    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
808        serde_json::from_str(&local_var_content).map_err(Error::from)
809    } else {
810        let local_var_entity: Option<GetAllInboxesError> = serde_json::from_str(&local_var_content).ok();
811        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
812        Err(Error::ResponseError(local_var_error))
813    }
814}
815
816/// List emails that an inbox has received. Only emails that are sent to the inbox's email address will appear in the inbox. It may take several seconds for any email you send to an inbox's email address to appear in the inbox. To make this endpoint wait for a minimum number of emails use the `minCount` parameter. The server will retry the inbox database until the `minCount` is satisfied or the `retryTimeout` is reached
817pub async fn get_emails(configuration: &configuration::Configuration, params: GetEmailsParams) -> Result<Vec<crate::models::EmailPreview>, Error<GetEmailsError>> {
818    // unbox the parameters
819    let inbox_id = params.inbox_id;
820    let before = params.before;
821    let delay_timeout = params.delay_timeout;
822    let limit = params.limit;
823    let min_count = params.min_count;
824    let retry_timeout = params.retry_timeout;
825    let since = params.since;
826    let size = params.size;
827    let sort = params.sort;
828    let unread_only = params.unread_only;
829
830
831    let local_var_client = &configuration.client;
832
833    let local_var_uri_str = format!("{}/inboxes/{inboxId}/emails", configuration.base_path, inboxId=inbox_id);
834    let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
835
836    if let Some(ref local_var_str) = before {
837        local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
838    }
839    if let Some(ref local_var_str) = delay_timeout {
840        local_var_req_builder = local_var_req_builder.query(&[("delayTimeout", &local_var_str.to_string())]);
841    }
842    if let Some(ref local_var_str) = limit {
843        local_var_req_builder = local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
844    }
845    if let Some(ref local_var_str) = min_count {
846        local_var_req_builder = local_var_req_builder.query(&[("minCount", &local_var_str.to_string())]);
847    }
848    if let Some(ref local_var_str) = retry_timeout {
849        local_var_req_builder = local_var_req_builder.query(&[("retryTimeout", &local_var_str.to_string())]);
850    }
851    if let Some(ref local_var_str) = since {
852        local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
853    }
854    if let Some(ref local_var_str) = size {
855        local_var_req_builder = local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
856    }
857    if let Some(ref local_var_str) = sort {
858        local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
859    }
860    if let Some(ref local_var_str) = unread_only {
861        local_var_req_builder = local_var_req_builder.query(&[("unreadOnly", &local_var_str.to_string())]);
862    }
863    if let Some(ref local_var_user_agent) = configuration.user_agent {
864        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
865    }
866    if let Some(ref local_var_apikey) = configuration.api_key {
867        let local_var_key = local_var_apikey.key.clone();
868        let local_var_value = match local_var_apikey.prefix {
869            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
870            None => local_var_key,
871        };
872        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
873    };
874
875    let local_var_req = local_var_req_builder.build()?;
876    let local_var_resp = local_var_client.execute(local_var_req).await?;
877
878    let local_var_status = local_var_resp.status();
879    let local_var_content = local_var_resp.text().await?;
880
881    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
882        serde_json::from_str(&local_var_content).map_err(Error::from)
883    } else {
884        let local_var_entity: Option<GetEmailsError> = serde_json::from_str(&local_var_content).ok();
885        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
886        Err(Error::ResponseError(local_var_error))
887    }
888}
889
890/// Returns an inbox's properties, including its email address and ID.
891pub async fn get_inbox(configuration: &configuration::Configuration, params: GetInboxParams) -> Result<crate::models::Inbox, Error<GetInboxError>> {
892    // unbox the parameters
893    let inbox_id = params.inbox_id;
894
895
896    let local_var_client = &configuration.client;
897
898    let local_var_uri_str = format!("{}/inboxes/{inboxId}", configuration.base_path, inboxId=inbox_id);
899    let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
900
901    if let Some(ref local_var_user_agent) = configuration.user_agent {
902        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
903    }
904    if let Some(ref local_var_apikey) = configuration.api_key {
905        let local_var_key = local_var_apikey.key.clone();
906        let local_var_value = match local_var_apikey.prefix {
907            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
908            None => local_var_key,
909        };
910        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
911    };
912
913    let local_var_req = local_var_req_builder.build()?;
914    let local_var_resp = local_var_client.execute(local_var_req).await?;
915
916    let local_var_status = local_var_resp.status();
917    let local_var_content = local_var_resp.text().await?;
918
919    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
920        serde_json::from_str(&local_var_content).map_err(Error::from)
921    } else {
922        let local_var_entity: Option<GetInboxError> = serde_json::from_str(&local_var_content).ok();
923        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
924        Err(Error::ResponseError(local_var_error))
925    }
926}
927
928/// Get a paginated list of emails in an inbox. Does not hold connections open.
929pub async fn get_inbox_emails_paginated(configuration: &configuration::Configuration, params: GetInboxEmailsPaginatedParams) -> Result<crate::models::PageEmailPreview, Error<GetInboxEmailsPaginatedError>> {
930    // unbox the parameters
931    let inbox_id = params.inbox_id;
932    let before = params.before;
933    let page = params.page;
934    let since = params.since;
935    let size = params.size;
936    let sort = params.sort;
937
938
939    let local_var_client = &configuration.client;
940
941    let local_var_uri_str = format!("{}/inboxes/{inboxId}/emails/paginated", configuration.base_path, inboxId=inbox_id);
942    let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
943
944    if let Some(ref local_var_str) = before {
945        local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
946    }
947    if let Some(ref local_var_str) = page {
948        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
949    }
950    if let Some(ref local_var_str) = since {
951        local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
952    }
953    if let Some(ref local_var_str) = size {
954        local_var_req_builder = local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
955    }
956    if let Some(ref local_var_str) = sort {
957        local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
958    }
959    if let Some(ref local_var_user_agent) = configuration.user_agent {
960        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
961    }
962    if let Some(ref local_var_apikey) = configuration.api_key {
963        let local_var_key = local_var_apikey.key.clone();
964        let local_var_value = match local_var_apikey.prefix {
965            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
966            None => local_var_key,
967        };
968        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
969    };
970
971    let local_var_req = local_var_req_builder.build()?;
972    let local_var_resp = local_var_client.execute(local_var_req).await?;
973
974    let local_var_status = local_var_resp.status();
975    let local_var_content = local_var_resp.text().await?;
976
977    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
978        serde_json::from_str(&local_var_content).map_err(Error::from)
979    } else {
980        let local_var_entity: Option<GetInboxEmailsPaginatedError> = serde_json::from_str(&local_var_content).ok();
981        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
982        Err(Error::ResponseError(local_var_error))
983    }
984}
985
986/// Returns an inbox's sent email receipts. Call individual sent email endpoints for more details. Note for privacy reasons the full body of sent emails is never stored. An MD5 hash hex is available for comparison instead.
987pub async fn get_inbox_sent_emails(configuration: &configuration::Configuration, params: GetInboxSentEmailsParams) -> Result<crate::models::PageSentEmailProjection, Error<GetInboxSentEmailsError>> {
988    // unbox the parameters
989    let inbox_id = params.inbox_id;
990    let before = params.before;
991    let page = params.page;
992    let search_filter = params.search_filter;
993    let since = params.since;
994    let size = params.size;
995    let sort = params.sort;
996
997
998    let local_var_client = &configuration.client;
999
1000    let local_var_uri_str = format!("{}/inboxes/{inboxId}/sent", configuration.base_path, inboxId=inbox_id);
1001    let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
1002
1003    if let Some(ref local_var_str) = before {
1004        local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
1005    }
1006    if let Some(ref local_var_str) = page {
1007        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
1008    }
1009    if let Some(ref local_var_str) = search_filter {
1010        local_var_req_builder = local_var_req_builder.query(&[("searchFilter", &local_var_str.to_string())]);
1011    }
1012    if let Some(ref local_var_str) = since {
1013        local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
1014    }
1015    if let Some(ref local_var_str) = size {
1016        local_var_req_builder = local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
1017    }
1018    if let Some(ref local_var_str) = sort {
1019        local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
1020    }
1021    if let Some(ref local_var_user_agent) = configuration.user_agent {
1022        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1023    }
1024    if let Some(ref local_var_apikey) = configuration.api_key {
1025        let local_var_key = local_var_apikey.key.clone();
1026        let local_var_value = match local_var_apikey.prefix {
1027            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
1028            None => local_var_key,
1029        };
1030        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
1031    };
1032
1033    let local_var_req = local_var_req_builder.build()?;
1034    let local_var_resp = local_var_client.execute(local_var_req).await?;
1035
1036    let local_var_status = local_var_resp.status();
1037    let local_var_content = local_var_resp.text().await?;
1038
1039    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1040        serde_json::from_str(&local_var_content).map_err(Error::from)
1041    } else {
1042        let local_var_entity: Option<GetInboxSentEmailsError> = serde_json::from_str(&local_var_content).ok();
1043        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1044        Err(Error::ResponseError(local_var_error))
1045    }
1046}
1047
1048/// Get all inbox tags
1049pub async fn get_inbox_tags(configuration: &configuration::Configuration) -> Result<Vec<String>, Error<GetInboxTagsError>> {
1050    // unbox the parameters
1051
1052
1053    let local_var_client = &configuration.client;
1054
1055    let local_var_uri_str = format!("{}/inboxes/tags", configuration.base_path);
1056    let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
1057
1058    if let Some(ref local_var_user_agent) = configuration.user_agent {
1059        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1060    }
1061    if let Some(ref local_var_apikey) = configuration.api_key {
1062        let local_var_key = local_var_apikey.key.clone();
1063        let local_var_value = match local_var_apikey.prefix {
1064            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
1065            None => local_var_key,
1066        };
1067        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
1068    };
1069
1070    let local_var_req = local_var_req_builder.build()?;
1071    let local_var_resp = local_var_client.execute(local_var_req).await?;
1072
1073    let local_var_status = local_var_resp.status();
1074    let local_var_content = local_var_resp.text().await?;
1075
1076    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1077        serde_json::from_str(&local_var_content).map_err(Error::from)
1078    } else {
1079        let local_var_entity: Option<GetInboxTagsError> = serde_json::from_str(&local_var_content).ok();
1080        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1081        Err(Error::ResponseError(local_var_error))
1082    }
1083}
1084
1085/// List the inboxes you have created. Note use of the more advanced `getAllEmails` is recommended and allows paginated access using a limit and sort parameter.
1086pub async fn get_inboxes(configuration: &configuration::Configuration, params: GetInboxesParams) -> Result<Vec<crate::models::Inbox>, Error<GetInboxesError>> {
1087    // unbox the parameters
1088    let before = params.before;
1089    let since = params.since;
1090    let size = params.size;
1091    let sort = params.sort;
1092
1093
1094    let local_var_client = &configuration.client;
1095
1096    let local_var_uri_str = format!("{}/inboxes", configuration.base_path);
1097    let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
1098
1099    if let Some(ref local_var_str) = before {
1100        local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
1101    }
1102    if let Some(ref local_var_str) = since {
1103        local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
1104    }
1105    if let Some(ref local_var_str) = size {
1106        local_var_req_builder = local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
1107    }
1108    if let Some(ref local_var_str) = sort {
1109        local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
1110    }
1111    if let Some(ref local_var_user_agent) = configuration.user_agent {
1112        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1113    }
1114    if let Some(ref local_var_apikey) = configuration.api_key {
1115        let local_var_key = local_var_apikey.key.clone();
1116        let local_var_value = match local_var_apikey.prefix {
1117            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
1118            None => local_var_key,
1119        };
1120        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
1121    };
1122
1123    let local_var_req = local_var_req_builder.build()?;
1124    let local_var_resp = local_var_client.execute(local_var_req).await?;
1125
1126    let local_var_status = local_var_resp.status();
1127    let local_var_content = local_var_resp.text().await?;
1128
1129    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1130        serde_json::from_str(&local_var_content).map_err(Error::from)
1131    } else {
1132        let local_var_entity: Option<GetInboxesError> = serde_json::from_str(&local_var_content).ok();
1133        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1134        Err(Error::ResponseError(local_var_error))
1135    }
1136}
1137
1138/// List organization inboxes in paginated form. These are inboxes created with `allowTeamAccess` flag enabled. Organization inboxes are `readOnly` for non-admin users. The results are available on the `content` property of the returned object. This method allows for page index (zero based), page size (how many results to return), and a sort direction (based on createdAt time). 
1139pub async fn get_organization_inboxes(configuration: &configuration::Configuration, params: GetOrganizationInboxesParams) -> Result<crate::models::PageOrganizationInboxProjection, Error<GetOrganizationInboxesError>> {
1140    // unbox the parameters
1141    let before = params.before;
1142    let page = params.page;
1143    let search_filter = params.search_filter;
1144    let since = params.since;
1145    let size = params.size;
1146    let sort = params.sort;
1147
1148
1149    let local_var_client = &configuration.client;
1150
1151    let local_var_uri_str = format!("{}/inboxes/organization", configuration.base_path);
1152    let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
1153
1154    if let Some(ref local_var_str) = before {
1155        local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
1156    }
1157    if let Some(ref local_var_str) = page {
1158        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
1159    }
1160    if let Some(ref local_var_str) = search_filter {
1161        local_var_req_builder = local_var_req_builder.query(&[("searchFilter", &local_var_str.to_string())]);
1162    }
1163    if let Some(ref local_var_str) = since {
1164        local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
1165    }
1166    if let Some(ref local_var_str) = size {
1167        local_var_req_builder = local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
1168    }
1169    if let Some(ref local_var_str) = sort {
1170        local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
1171    }
1172    if let Some(ref local_var_user_agent) = configuration.user_agent {
1173        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1174    }
1175    if let Some(ref local_var_apikey) = configuration.api_key {
1176        let local_var_key = local_var_apikey.key.clone();
1177        let local_var_value = match local_var_apikey.prefix {
1178            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
1179            None => local_var_key,
1180        };
1181        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
1182    };
1183
1184    let local_var_req = local_var_req_builder.build()?;
1185    let local_var_resp = local_var_client.execute(local_var_req).await?;
1186
1187    let local_var_status = local_var_resp.status();
1188    let local_var_content = local_var_resp.text().await?;
1189
1190    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1191        serde_json::from_str(&local_var_content).map_err(Error::from)
1192    } else {
1193        let local_var_entity: Option<GetOrganizationInboxesError> = serde_json::from_str(&local_var_content).ok();
1194        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1195        Err(Error::ResponseError(local_var_error))
1196    }
1197}
1198
1199/// List all rulesets attached to an inbox
1200pub async fn list_inbox_rulesets(configuration: &configuration::Configuration, params: ListInboxRulesetsParams) -> Result<crate::models::PageInboxRulesetDto, Error<ListInboxRulesetsError>> {
1201    // unbox the parameters
1202    let inbox_id = params.inbox_id;
1203    let before = params.before;
1204    let page = params.page;
1205    let search_filter = params.search_filter;
1206    let since = params.since;
1207    let size = params.size;
1208    let sort = params.sort;
1209
1210
1211    let local_var_client = &configuration.client;
1212
1213    let local_var_uri_str = format!("{}/inboxes/{inboxId}/rulesets", configuration.base_path, inboxId=inbox_id);
1214    let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
1215
1216    if let Some(ref local_var_str) = before {
1217        local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
1218    }
1219    if let Some(ref local_var_str) = page {
1220        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
1221    }
1222    if let Some(ref local_var_str) = search_filter {
1223        local_var_req_builder = local_var_req_builder.query(&[("searchFilter", &local_var_str.to_string())]);
1224    }
1225    if let Some(ref local_var_str) = since {
1226        local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
1227    }
1228    if let Some(ref local_var_str) = size {
1229        local_var_req_builder = local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
1230    }
1231    if let Some(ref local_var_str) = sort {
1232        local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
1233    }
1234    if let Some(ref local_var_user_agent) = configuration.user_agent {
1235        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1236    }
1237    if let Some(ref local_var_apikey) = configuration.api_key {
1238        let local_var_key = local_var_apikey.key.clone();
1239        let local_var_value = match local_var_apikey.prefix {
1240            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
1241            None => local_var_key,
1242        };
1243        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
1244    };
1245
1246    let local_var_req = local_var_req_builder.build()?;
1247    let local_var_resp = local_var_client.execute(local_var_req).await?;
1248
1249    let local_var_status = local_var_resp.status();
1250    let local_var_content = local_var_resp.text().await?;
1251
1252    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1253        serde_json::from_str(&local_var_content).map_err(Error::from)
1254    } else {
1255        let local_var_entity: Option<ListInboxRulesetsError> = serde_json::from_str(&local_var_content).ok();
1256        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1257        Err(Error::ResponseError(local_var_error))
1258    }
1259}
1260
1261/// List all tracking pixels sent from an inbox
1262pub async fn list_inbox_tracking_pixels(configuration: &configuration::Configuration, params: ListInboxTrackingPixelsParams) -> Result<crate::models::PageTrackingPixelProjection, Error<ListInboxTrackingPixelsError>> {
1263    // unbox the parameters
1264    let inbox_id = params.inbox_id;
1265    let before = params.before;
1266    let page = params.page;
1267    let search_filter = params.search_filter;
1268    let since = params.since;
1269    let size = params.size;
1270    let sort = params.sort;
1271
1272
1273    let local_var_client = &configuration.client;
1274
1275    let local_var_uri_str = format!("{}/inboxes/{inboxId}/tracking-pixels", configuration.base_path, inboxId=inbox_id);
1276    let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
1277
1278    if let Some(ref local_var_str) = before {
1279        local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
1280    }
1281    if let Some(ref local_var_str) = page {
1282        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
1283    }
1284    if let Some(ref local_var_str) = search_filter {
1285        local_var_req_builder = local_var_req_builder.query(&[("searchFilter", &local_var_str.to_string())]);
1286    }
1287    if let Some(ref local_var_str) = since {
1288        local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
1289    }
1290    if let Some(ref local_var_str) = size {
1291        local_var_req_builder = local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
1292    }
1293    if let Some(ref local_var_str) = sort {
1294        local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
1295    }
1296    if let Some(ref local_var_user_agent) = configuration.user_agent {
1297        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1298    }
1299    if let Some(ref local_var_apikey) = configuration.api_key {
1300        let local_var_key = local_var_apikey.key.clone();
1301        let local_var_value = match local_var_apikey.prefix {
1302            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
1303            None => local_var_key,
1304        };
1305        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
1306    };
1307
1308    let local_var_req = local_var_req_builder.build()?;
1309    let local_var_resp = local_var_client.execute(local_var_req).await?;
1310
1311    let local_var_status = local_var_resp.status();
1312    let local_var_content = local_var_resp.text().await?;
1313
1314    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1315        serde_json::from_str(&local_var_content).map_err(Error::from)
1316    } else {
1317        let local_var_entity: Option<ListInboxTrackingPixelsError> = serde_json::from_str(&local_var_content).ok();
1318        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1319        Err(Error::ResponseError(local_var_error))
1320    }
1321}
1322
1323/// Send an email from an inbox's email address.  The request body should contain the `SendEmailOptions` that include recipients, attachments, body etc. See `SendEmailOptions` for all available properties. Note the `inboxId` refers to the inbox's id not the inbox's email address. See https://www.mailslurp.com/guides/ for more information on how to send emails. This method does not return a sent email entity due to legacy reasons. To send and get a sent email as returned response use the sister method `sendEmailAndConfirm`.
1324pub async fn send_email(configuration: &configuration::Configuration, params: SendEmailParams) -> Result<(), Error<SendEmailError>> {
1325    // unbox the parameters
1326    let inbox_id = params.inbox_id;
1327    let send_email_options = params.send_email_options;
1328
1329
1330    let local_var_client = &configuration.client;
1331
1332    let local_var_uri_str = format!("{}/inboxes/{inboxId}", configuration.base_path, inboxId=inbox_id);
1333    let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
1334
1335    if let Some(ref local_var_user_agent) = configuration.user_agent {
1336        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1337    }
1338    if let Some(ref local_var_apikey) = configuration.api_key {
1339        let local_var_key = local_var_apikey.key.clone();
1340        let local_var_value = match local_var_apikey.prefix {
1341            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
1342            None => local_var_key,
1343        };
1344        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
1345    };
1346    local_var_req_builder = local_var_req_builder.json(&send_email_options);
1347
1348    let local_var_req = local_var_req_builder.build()?;
1349    let local_var_resp = local_var_client.execute(local_var_req).await?;
1350
1351    let local_var_status = local_var_resp.status();
1352    let local_var_content = local_var_resp.text().await?;
1353
1354    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1355        Ok(())
1356    } else {
1357        let local_var_entity: Option<SendEmailError> = serde_json::from_str(&local_var_content).ok();
1358        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1359        Err(Error::ResponseError(local_var_error))
1360    }
1361}
1362
1363/// Sister method for standard `sendEmail` method with the benefit of returning a `SentEmail` entity confirming the successful sending of the email with a link to the sent object created for it.
1364pub async fn send_email_and_confirm(configuration: &configuration::Configuration, params: SendEmailAndConfirmParams) -> Result<crate::models::SentEmailDto, Error<SendEmailAndConfirmError>> {
1365    // unbox the parameters
1366    let inbox_id = params.inbox_id;
1367    let send_email_options = params.send_email_options;
1368
1369
1370    let local_var_client = &configuration.client;
1371
1372    let local_var_uri_str = format!("{}/inboxes/{inboxId}/confirm", configuration.base_path, inboxId=inbox_id);
1373    let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
1374
1375    if let Some(ref local_var_user_agent) = configuration.user_agent {
1376        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1377    }
1378    if let Some(ref local_var_apikey) = configuration.api_key {
1379        let local_var_key = local_var_apikey.key.clone();
1380        let local_var_value = match local_var_apikey.prefix {
1381            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
1382            None => local_var_key,
1383        };
1384        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
1385    };
1386    local_var_req_builder = local_var_req_builder.json(&send_email_options);
1387
1388    let local_var_req = local_var_req_builder.build()?;
1389    let local_var_resp = local_var_client.execute(local_var_req).await?;
1390
1391    let local_var_status = local_var_resp.status();
1392    let local_var_content = local_var_resp.text().await?;
1393
1394    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1395        serde_json::from_str(&local_var_content).map_err(Error::from)
1396    } else {
1397        let local_var_entity: Option<SendEmailAndConfirmError> = serde_json::from_str(&local_var_content).ok();
1398        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1399        Err(Error::ResponseError(local_var_error))
1400    }
1401}
1402
1403/// Send an inbox a test email to test email receiving is working
1404pub async fn send_test_email(configuration: &configuration::Configuration, params: SendTestEmailParams) -> Result<(), Error<SendTestEmailError>> {
1405    // unbox the parameters
1406    let inbox_id = params.inbox_id;
1407
1408
1409    let local_var_client = &configuration.client;
1410
1411    let local_var_uri_str = format!("{}/inboxes/{inboxId}/send-test-email", configuration.base_path, inboxId=inbox_id);
1412    let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
1413
1414    if let Some(ref local_var_user_agent) = configuration.user_agent {
1415        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1416    }
1417    if let Some(ref local_var_apikey) = configuration.api_key {
1418        let local_var_key = local_var_apikey.key.clone();
1419        let local_var_value = match local_var_apikey.prefix {
1420            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
1421            None => local_var_key,
1422        };
1423        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
1424    };
1425
1426    let local_var_req = local_var_req_builder.build()?;
1427    let local_var_resp = local_var_client.execute(local_var_req).await?;
1428
1429    let local_var_status = local_var_resp.status();
1430    let local_var_content = local_var_resp.text().await?;
1431
1432    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1433        Ok(())
1434    } else {
1435        let local_var_entity: Option<SendTestEmailError> = serde_json::from_str(&local_var_content).ok();
1436        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1437        Err(Error::ResponseError(local_var_error))
1438    }
1439}
1440
1441/// Set and return new favourite state for an inbox
1442pub async fn set_inbox_favourited(configuration: &configuration::Configuration, params: SetInboxFavouritedParams) -> Result<crate::models::Inbox, Error<SetInboxFavouritedError>> {
1443    // unbox the parameters
1444    let inbox_id = params.inbox_id;
1445    let set_inbox_favourited_options = params.set_inbox_favourited_options;
1446
1447
1448    let local_var_client = &configuration.client;
1449
1450    let local_var_uri_str = format!("{}/inboxes/{inboxId}/favourite", configuration.base_path, inboxId=inbox_id);
1451    let mut local_var_req_builder = local_var_client.put(local_var_uri_str.as_str());
1452
1453    if let Some(ref local_var_user_agent) = configuration.user_agent {
1454        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1455    }
1456    if let Some(ref local_var_apikey) = configuration.api_key {
1457        let local_var_key = local_var_apikey.key.clone();
1458        let local_var_value = match local_var_apikey.prefix {
1459            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
1460            None => local_var_key,
1461        };
1462        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
1463    };
1464    local_var_req_builder = local_var_req_builder.json(&set_inbox_favourited_options);
1465
1466    let local_var_req = local_var_req_builder.build()?;
1467    let local_var_resp = local_var_client.execute(local_var_req).await?;
1468
1469    let local_var_status = local_var_resp.status();
1470    let local_var_content = local_var_resp.text().await?;
1471
1472    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1473        serde_json::from_str(&local_var_content).map_err(Error::from)
1474    } else {
1475        let local_var_entity: Option<SetInboxFavouritedError> = serde_json::from_str(&local_var_content).ok();
1476        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1477        Err(Error::ResponseError(local_var_error))
1478    }
1479}
1480
1481/// Update editable fields on an inbox
1482pub async fn update_inbox(configuration: &configuration::Configuration, params: UpdateInboxParams) -> Result<crate::models::Inbox, Error<UpdateInboxError>> {
1483    // unbox the parameters
1484    let inbox_id = params.inbox_id;
1485    let update_inbox_options = params.update_inbox_options;
1486
1487
1488    let local_var_client = &configuration.client;
1489
1490    let local_var_uri_str = format!("{}/inboxes/{inboxId}", configuration.base_path, inboxId=inbox_id);
1491    let mut local_var_req_builder = local_var_client.patch(local_var_uri_str.as_str());
1492
1493    if let Some(ref local_var_user_agent) = configuration.user_agent {
1494        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1495    }
1496    if let Some(ref local_var_apikey) = configuration.api_key {
1497        let local_var_key = local_var_apikey.key.clone();
1498        let local_var_value = match local_var_apikey.prefix {
1499            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
1500            None => local_var_key,
1501        };
1502        local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
1503    };
1504    local_var_req_builder = local_var_req_builder.json(&update_inbox_options);
1505
1506    let local_var_req = local_var_req_builder.build()?;
1507    let local_var_resp = local_var_client.execute(local_var_req).await?;
1508
1509    let local_var_status = local_var_resp.status();
1510    let local_var_content = local_var_resp.text().await?;
1511
1512    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1513        serde_json::from_str(&local_var_content).map_err(Error::from)
1514    } else {
1515        let local_var_entity: Option<UpdateInboxError> = serde_json::from_str(&local_var_content).ok();
1516        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1517        Err(Error::ResponseError(local_var_error))
1518    }
1519}
1520