/*
* MailSlurp API
*
* 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
*
* The version of the OpenAPI document: 6.5.2
*
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use crate::apis::ResponseContent;
use super::{Error, configuration};
/// struct for passing parameters to the method `create_inbox`
#[derive(Clone, Debug)]
pub struct CreateInboxParams {
/// 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.
pub allow_team_access: Option<bool>,
/// Optional description of the inbox for labelling purposes. Is shown in the dashboard and can be used with
pub description: Option<String>,
/// 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.
pub email_address: Option<String>,
/// 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.
pub expires_at: Option<String>,
/// Number of milliseconds that inbox should exist for
pub expires_in: Option<i64>,
/// Is the inbox a favorite. Marking an inbox as a favorite is typically done in the dashboard for quick access or filtering
pub favourite: Option<bool>,
/// 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`.
pub inbox_type: Option<String>,
/// Optional name of the inbox. Displayed in the dashboard for easier search and used as the sender name when sending emails.
pub name: Option<String>,
/// 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.
pub tags: Option<Vec<String>>,
/// 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.
pub use_domain_pool: Option<bool>
}
/// struct for passing parameters to the method `create_inbox_ruleset`
#[derive(Clone, Debug)]
pub struct CreateInboxRulesetParams {
/// inboxId
pub inbox_id: String,
/// createInboxRulesetOptions
pub create_inbox_ruleset_options: crate::models::CreateInboxRulesetOptions
}
/// struct for passing parameters to the method `create_inbox_with_options`
#[derive(Clone, Debug)]
pub struct CreateInboxWithOptionsParams {
/// createInboxDto
pub create_inbox_dto: crate::models::CreateInboxDto
}
/// struct for passing parameters to the method `delete_inbox`
#[derive(Clone, Debug)]
pub struct DeleteInboxParams {
/// inboxId
pub inbox_id: String
}
/// struct for passing parameters to the method `get_all_inboxes`
#[derive(Clone, Debug)]
pub struct GetAllInboxesParams {
/// Optional filter by created before given date time
pub before: Option<String>,
/// Optionally filter results for favourites only
pub favourite: Option<bool>,
/// Optional page index in list pagination
pub page: Option<i32>,
/// Optionally filter by search words partial matching ID, tags, name, and email address
pub search: Option<String>,
/// Optional filter by created after given date time
pub since: Option<String>,
/// Optional page size in list pagination
pub size: Option<i32>,
/// Optional createdAt sort direction ASC or DESC
pub sort: Option<String>,
/// Optionally filter by tags. Will return inboxes that include given tags
pub tag: Option<String>,
/// DEPRECATED. Optionally filter by team access.
pub team_access: Option<bool>
}
/// struct for passing parameters to the method `get_emails`
#[derive(Clone, Debug)]
pub struct GetEmailsParams {
/// Id of inbox that emails belongs to
pub inbox_id: String,
/// Exclude emails received after this ISO 8601 date time
pub before: Option<String>,
/// delayTimeout
pub delay_timeout: Option<i64>,
/// Limit the result set, ordered by received date time sort direction. Maximum 100. For more listing options see the email controller
pub limit: Option<i32>,
/// Minimum acceptable email count. Will cause request to hang (and retry) until minCount is satisfied or retryTimeout is reached.
pub min_count: Option<i64>,
/// Maximum milliseconds to spend retrying inbox database until minCount emails are returned
pub retry_timeout: Option<i64>,
/// Exclude emails received before this ISO 8601 date time
pub since: Option<String>,
/// Alias for limit. Assessed first before assessing any passed limit.
pub size: Option<i32>,
/// Sort the results by received date and direction ASC or DESC
pub sort: Option<String>,
/// unreadOnly
pub unread_only: Option<bool>
}
/// struct for passing parameters to the method `get_inbox`
#[derive(Clone, Debug)]
pub struct GetInboxParams {
/// inboxId
pub inbox_id: String
}
/// struct for passing parameters to the method `get_inbox_emails_paginated`
#[derive(Clone, Debug)]
pub struct GetInboxEmailsPaginatedParams {
/// Id of inbox that emails belongs to
pub inbox_id: String,
/// Optional filter by received before given date time
pub before: Option<String>,
/// Optional page index in inbox emails list pagination
pub page: Option<i32>,
/// Optional filter by received after given date time
pub since: Option<String>,
/// Optional page size in inbox emails list pagination
pub size: Option<i32>,
/// Optional createdAt sort direction ASC or DESC
pub sort: Option<String>
}
/// struct for passing parameters to the method `get_inbox_sent_emails`
#[derive(Clone, Debug)]
pub struct GetInboxSentEmailsParams {
/// inboxId
pub inbox_id: String,
/// Optional filter by sent before given date time
pub before: Option<String>,
/// Optional page index in inbox sent email list pagination
pub page: Option<i32>,
/// Optional sent email search
pub search_filter: Option<String>,
/// Optional filter by sent after given date time
pub since: Option<String>,
/// Optional page size in inbox sent email list pagination
pub size: Option<i32>,
/// Optional createdAt sort direction ASC or DESC
pub sort: Option<String>
}
/// struct for passing parameters to the method `get_inboxes`
#[derive(Clone, Debug)]
pub struct GetInboxesParams {
/// Optional filter by created before given date time
pub before: Option<String>,
/// Optional filter by created after given date time
pub since: Option<String>,
/// Optional result size limit. Note an automatic limit of 100 results is applied. See the paginated `getAllEmails` for larger queries.
pub size: Option<i32>,
/// Optional createdAt sort direction ASC or DESC
pub sort: Option<String>
}
/// struct for passing parameters to the method `get_organization_inboxes`
#[derive(Clone, Debug)]
pub struct GetOrganizationInboxesParams {
/// Optional filter by created before given date time
pub before: Option<String>,
/// Optional page index in list pagination
pub page: Option<i32>,
/// Optional search filter
pub search_filter: Option<String>,
/// Optional filter by created after given date time
pub since: Option<String>,
/// Optional page size in list pagination
pub size: Option<i32>,
/// Optional createdAt sort direction ASC or DESC
pub sort: Option<String>
}
/// struct for passing parameters to the method `list_inbox_rulesets`
#[derive(Clone, Debug)]
pub struct ListInboxRulesetsParams {
/// inboxId
pub inbox_id: String,
/// Optional filter by created before given date time
pub before: Option<String>,
/// Optional page index in inbox ruleset list pagination
pub page: Option<i32>,
/// Optional search filter
pub search_filter: Option<String>,
/// Optional filter by created after given date time
pub since: Option<String>,
/// Optional page size in inbox ruleset list pagination
pub size: Option<i32>,
/// Optional createdAt sort direction ASC or DESC
pub sort: Option<String>
}
/// struct for passing parameters to the method `list_inbox_tracking_pixels`
#[derive(Clone, Debug)]
pub struct ListInboxTrackingPixelsParams {
/// inboxId
pub inbox_id: String,
/// Optional filter by created before given date time
pub before: Option<String>,
/// Optional page index in inbox tracking pixel list pagination
pub page: Option<i32>,
/// Optional search filter
pub search_filter: Option<String>,
/// Optional filter by created after given date time
pub since: Option<String>,
/// Optional page size in inbox tracking pixel list pagination
pub size: Option<i32>,
/// Optional createdAt sort direction ASC or DESC
pub sort: Option<String>
}
/// struct for passing parameters to the method `send_email`
#[derive(Clone, Debug)]
pub struct SendEmailParams {
/// ID of the inbox you want to send the email from
pub inbox_id: String,
/// Options for the email
pub send_email_options: Option<crate::models::SendEmailOptions>
}
/// struct for passing parameters to the method `send_email_and_confirm`
#[derive(Clone, Debug)]
pub struct SendEmailAndConfirmParams {
/// ID of the inbox you want to send the email from
pub inbox_id: String,
/// Options for the email
pub send_email_options: Option<crate::models::SendEmailOptions>
}
/// struct for passing parameters to the method `send_test_email`
#[derive(Clone, Debug)]
pub struct SendTestEmailParams {
/// inboxId
pub inbox_id: String
}
/// struct for passing parameters to the method `set_inbox_favourited`
#[derive(Clone, Debug)]
pub struct SetInboxFavouritedParams {
/// inboxId
pub inbox_id: String,
/// setInboxFavouritedOptions
pub set_inbox_favourited_options: crate::models::SetInboxFavouritedOptions
}
/// struct for passing parameters to the method `update_inbox`
#[derive(Clone, Debug)]
pub struct UpdateInboxParams {
/// inboxId
pub inbox_id: String,
/// updateInboxOptions
pub update_inbox_options: crate::models::UpdateInboxOptions
}
/// struct for typed errors of method `create_inbox`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateInboxError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `create_inbox_ruleset`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateInboxRulesetError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `create_inbox_with_defaults`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateInboxWithDefaultsError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `create_inbox_with_options`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateInboxWithOptionsError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `delete_all_inboxes`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteAllInboxesError {
Status401(),
Status403(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `delete_inbox`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteInboxError {
Status401(),
Status403(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `get_all_inboxes`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAllInboxesError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `get_emails`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetEmailsError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `get_inbox`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetInboxError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `get_inbox_emails_paginated`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetInboxEmailsPaginatedError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `get_inbox_sent_emails`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetInboxSentEmailsError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `get_inbox_tags`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetInboxTagsError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `get_inboxes`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetInboxesError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `get_organization_inboxes`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetOrganizationInboxesError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `list_inbox_rulesets`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListInboxRulesetsError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `list_inbox_tracking_pixels`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListInboxTrackingPixelsError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `send_email`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendEmailError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `send_email_and_confirm`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendEmailAndConfirmError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `send_test_email`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendTestEmailError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `set_inbox_favourited`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetInboxFavouritedError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `update_inbox`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateInboxError {
Status401(),
Status403(),
UnknownValue(serde_json::Value),
}
/// 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.
pub async fn create_inbox(configuration: &configuration::Configuration, params: CreateInboxParams) -> Result<crate::models::Inbox, Error<CreateInboxError>> {
// unbox the parameters
let allow_team_access = params.allow_team_access;
let description = params.description;
let email_address = params.email_address;
let expires_at = params.expires_at;
let expires_in = params.expires_in;
let favourite = params.favourite;
let inbox_type = params.inbox_type;
let name = params.name;
let tags = params.tags;
let use_domain_pool = params.use_domain_pool;
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/inboxes", configuration.base_path);
let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
if let Some(ref local_var_str) = allow_team_access {
local_var_req_builder = local_var_req_builder.query(&[("allowTeamAccess", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = description {
local_var_req_builder = local_var_req_builder.query(&[("description", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = email_address {
local_var_req_builder = local_var_req_builder.query(&[("emailAddress", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = expires_at {
local_var_req_builder = local_var_req_builder.query(&[("expiresAt", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = expires_in {
local_var_req_builder = local_var_req_builder.query(&[("expiresIn", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = favourite {
local_var_req_builder = local_var_req_builder.query(&[("favourite", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = inbox_type {
local_var_req_builder = local_var_req_builder.query(&[("inboxType", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = name {
local_var_req_builder = local_var_req_builder.query(&[("name", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = tags {
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())]);
}
if let Some(ref local_var_str) = use_domain_pool {
local_var_req_builder = local_var_req_builder.query(&[("useDomainPool", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<CreateInboxError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Create a new inbox rule for forwarding, blocking, and allowing emails when sending and receiving
pub async fn create_inbox_ruleset(configuration: &configuration::Configuration, params: CreateInboxRulesetParams) -> Result<crate::models::InboxRulesetDto, Error<CreateInboxRulesetError>> {
// unbox the parameters
let inbox_id = params.inbox_id;
let create_inbox_ruleset_options = params.create_inbox_ruleset_options;
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/inboxes/{inboxId}/rulesets", configuration.base_path, inboxId=inbox_id);
let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&create_inbox_ruleset_options);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<CreateInboxRulesetError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub async fn create_inbox_with_defaults(configuration: &configuration::Configuration) -> Result<crate::models::Inbox, Error<CreateInboxWithDefaultsError>> {
// unbox the parameters
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/inboxes/withDefaults", configuration.base_path);
let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<CreateInboxWithDefaultsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Additional endpoint that allows inbox creation with request body options. Can be more flexible that other methods for some clients.
pub async fn create_inbox_with_options(configuration: &configuration::Configuration, params: CreateInboxWithOptionsParams) -> Result<crate::models::Inbox, Error<CreateInboxWithOptionsError>> {
// unbox the parameters
let create_inbox_dto = params.create_inbox_dto;
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/inboxes/withOptions", configuration.base_path);
let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&create_inbox_dto);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<CreateInboxWithOptionsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn delete_all_inboxes(configuration: &configuration::Configuration) -> Result<(), Error<DeleteAllInboxesError>> {
// unbox the parameters
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/inboxes", configuration.base_path);
let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
Ok(())
} else {
let local_var_entity: Option<DeleteAllInboxesError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn delete_inbox(configuration: &configuration::Configuration, params: DeleteInboxParams) -> Result<(), Error<DeleteInboxError>> {
// unbox the parameters
let inbox_id = params.inbox_id;
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/inboxes/{inboxId}", configuration.base_path, inboxId=inbox_id);
let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
Ok(())
} else {
let local_var_entity: Option<DeleteInboxError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn get_all_inboxes(configuration: &configuration::Configuration, params: GetAllInboxesParams) -> Result<crate::models::PageInboxProjection, Error<GetAllInboxesError>> {
// unbox the parameters
let before = params.before;
let favourite = params.favourite;
let page = params.page;
let search = params.search;
let since = params.since;
let size = params.size;
let sort = params.sort;
let tag = params.tag;
let team_access = params.team_access;
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/inboxes/paginated", configuration.base_path);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref local_var_str) = before {
local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = favourite {
local_var_req_builder = local_var_req_builder.query(&[("favourite", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = page {
local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = search {
local_var_req_builder = local_var_req_builder.query(&[("search", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = since {
local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = size {
local_var_req_builder = local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = sort {
local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = tag {
local_var_req_builder = local_var_req_builder.query(&[("tag", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = team_access {
local_var_req_builder = local_var_req_builder.query(&[("teamAccess", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetAllInboxesError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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
pub async fn get_emails(configuration: &configuration::Configuration, params: GetEmailsParams) -> Result<Vec<crate::models::EmailPreview>, Error<GetEmailsError>> {
// unbox the parameters
let inbox_id = params.inbox_id;
let before = params.before;
let delay_timeout = params.delay_timeout;
let limit = params.limit;
let min_count = params.min_count;
let retry_timeout = params.retry_timeout;
let since = params.since;
let size = params.size;
let sort = params.sort;
let unread_only = params.unread_only;
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/inboxes/{inboxId}/emails", configuration.base_path, inboxId=inbox_id);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref local_var_str) = before {
local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = delay_timeout {
local_var_req_builder = local_var_req_builder.query(&[("delayTimeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = limit {
local_var_req_builder = local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = min_count {
local_var_req_builder = local_var_req_builder.query(&[("minCount", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = retry_timeout {
local_var_req_builder = local_var_req_builder.query(&[("retryTimeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = since {
local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = size {
local_var_req_builder = local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = sort {
local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = unread_only {
local_var_req_builder = local_var_req_builder.query(&[("unreadOnly", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetEmailsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Returns an inbox's properties, including its email address and ID.
pub async fn get_inbox(configuration: &configuration::Configuration, params: GetInboxParams) -> Result<crate::models::Inbox, Error<GetInboxError>> {
// unbox the parameters
let inbox_id = params.inbox_id;
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/inboxes/{inboxId}", configuration.base_path, inboxId=inbox_id);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetInboxError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Get a paginated list of emails in an inbox. Does not hold connections open.
pub async fn get_inbox_emails_paginated(configuration: &configuration::Configuration, params: GetInboxEmailsPaginatedParams) -> Result<crate::models::PageEmailPreview, Error<GetInboxEmailsPaginatedError>> {
// unbox the parameters
let inbox_id = params.inbox_id;
let before = params.before;
let page = params.page;
let since = params.since;
let size = params.size;
let sort = params.sort;
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/inboxes/{inboxId}/emails/paginated", configuration.base_path, inboxId=inbox_id);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref local_var_str) = before {
local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = page {
local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = since {
local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = size {
local_var_req_builder = local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = sort {
local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetInboxEmailsPaginatedError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn get_inbox_sent_emails(configuration: &configuration::Configuration, params: GetInboxSentEmailsParams) -> Result<crate::models::PageSentEmailProjection, Error<GetInboxSentEmailsError>> {
// unbox the parameters
let inbox_id = params.inbox_id;
let before = params.before;
let page = params.page;
let search_filter = params.search_filter;
let since = params.since;
let size = params.size;
let sort = params.sort;
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/inboxes/{inboxId}/sent", configuration.base_path, inboxId=inbox_id);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref local_var_str) = before {
local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = page {
local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = search_filter {
local_var_req_builder = local_var_req_builder.query(&[("searchFilter", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = since {
local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = size {
local_var_req_builder = local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = sort {
local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetInboxSentEmailsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Get all inbox tags
pub async fn get_inbox_tags(configuration: &configuration::Configuration) -> Result<Vec<String>, Error<GetInboxTagsError>> {
// unbox the parameters
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/inboxes/tags", configuration.base_path);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetInboxTagsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn get_inboxes(configuration: &configuration::Configuration, params: GetInboxesParams) -> Result<Vec<crate::models::Inbox>, Error<GetInboxesError>> {
// unbox the parameters
let before = params.before;
let since = params.since;
let size = params.size;
let sort = params.sort;
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/inboxes", configuration.base_path);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref local_var_str) = before {
local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = since {
local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = size {
local_var_req_builder = local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = sort {
local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetInboxesError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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).
pub async fn get_organization_inboxes(configuration: &configuration::Configuration, params: GetOrganizationInboxesParams) -> Result<crate::models::PageOrganizationInboxProjection, Error<GetOrganizationInboxesError>> {
// unbox the parameters
let before = params.before;
let page = params.page;
let search_filter = params.search_filter;
let since = params.since;
let size = params.size;
let sort = params.sort;
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/inboxes/organization", configuration.base_path);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref local_var_str) = before {
local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = page {
local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = search_filter {
local_var_req_builder = local_var_req_builder.query(&[("searchFilter", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = since {
local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = size {
local_var_req_builder = local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = sort {
local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetOrganizationInboxesError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// List all rulesets attached to an inbox
pub async fn list_inbox_rulesets(configuration: &configuration::Configuration, params: ListInboxRulesetsParams) -> Result<crate::models::PageInboxRulesetDto, Error<ListInboxRulesetsError>> {
// unbox the parameters
let inbox_id = params.inbox_id;
let before = params.before;
let page = params.page;
let search_filter = params.search_filter;
let since = params.since;
let size = params.size;
let sort = params.sort;
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/inboxes/{inboxId}/rulesets", configuration.base_path, inboxId=inbox_id);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref local_var_str) = before {
local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = page {
local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = search_filter {
local_var_req_builder = local_var_req_builder.query(&[("searchFilter", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = since {
local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = size {
local_var_req_builder = local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = sort {
local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ListInboxRulesetsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// List all tracking pixels sent from an inbox
pub async fn list_inbox_tracking_pixels(configuration: &configuration::Configuration, params: ListInboxTrackingPixelsParams) -> Result<crate::models::PageTrackingPixelProjection, Error<ListInboxTrackingPixelsError>> {
// unbox the parameters
let inbox_id = params.inbox_id;
let before = params.before;
let page = params.page;
let search_filter = params.search_filter;
let since = params.since;
let size = params.size;
let sort = params.sort;
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/inboxes/{inboxId}/tracking-pixels", configuration.base_path, inboxId=inbox_id);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref local_var_str) = before {
local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = page {
local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = search_filter {
local_var_req_builder = local_var_req_builder.query(&[("searchFilter", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = since {
local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = size {
local_var_req_builder = local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = sort {
local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ListInboxTrackingPixelsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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`.
pub async fn send_email(configuration: &configuration::Configuration, params: SendEmailParams) -> Result<(), Error<SendEmailError>> {
// unbox the parameters
let inbox_id = params.inbox_id;
let send_email_options = params.send_email_options;
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/inboxes/{inboxId}", configuration.base_path, inboxId=inbox_id);
let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&send_email_options);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
Ok(())
} else {
let local_var_entity: Option<SendEmailError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn send_email_and_confirm(configuration: &configuration::Configuration, params: SendEmailAndConfirmParams) -> Result<crate::models::SentEmailDto, Error<SendEmailAndConfirmError>> {
// unbox the parameters
let inbox_id = params.inbox_id;
let send_email_options = params.send_email_options;
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/inboxes/{inboxId}/confirm", configuration.base_path, inboxId=inbox_id);
let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&send_email_options);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<SendEmailAndConfirmError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Send an inbox a test email to test email receiving is working
pub async fn send_test_email(configuration: &configuration::Configuration, params: SendTestEmailParams) -> Result<(), Error<SendTestEmailError>> {
// unbox the parameters
let inbox_id = params.inbox_id;
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/inboxes/{inboxId}/send-test-email", configuration.base_path, inboxId=inbox_id);
let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
Ok(())
} else {
let local_var_entity: Option<SendTestEmailError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Set and return new favourite state for an inbox
pub async fn set_inbox_favourited(configuration: &configuration::Configuration, params: SetInboxFavouritedParams) -> Result<crate::models::Inbox, Error<SetInboxFavouritedError>> {
// unbox the parameters
let inbox_id = params.inbox_id;
let set_inbox_favourited_options = params.set_inbox_favourited_options;
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/inboxes/{inboxId}/favourite", configuration.base_path, inboxId=inbox_id);
let mut local_var_req_builder = local_var_client.put(local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&set_inbox_favourited_options);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<SetInboxFavouritedError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Update editable fields on an inbox
pub async fn update_inbox(configuration: &configuration::Configuration, params: UpdateInboxParams) -> Result<crate::models::Inbox, Error<UpdateInboxError>> {
// unbox the parameters
let inbox_id = params.inbox_id;
let update_inbox_options = params.update_inbox_options;
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/inboxes/{inboxId}", configuration.base_path, inboxId=inbox_id);
let mut local_var_req_builder = local_var_client.patch(local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&update_inbox_options);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<UpdateInboxError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}