use reqwest;
use crate::apis::ResponseContent;
use super::{Error, configuration};
#[derive(Clone, Debug)]
pub struct CreateInboxParams {
pub allow_team_access: Option<bool>,
pub description: Option<String>,
pub email_address: Option<String>,
pub expires_at: Option<String>,
pub expires_in: Option<i64>,
pub favourite: Option<bool>,
pub name: Option<String>,
pub tags: Option<Vec<String>>,
pub use_domain_pool: Option<bool>
}
#[derive(Clone, Debug)]
pub struct CreateInboxWithOptionsParams {
pub create_inbox_dto: crate::models::CreateInboxDto
}
#[derive(Clone, Debug)]
pub struct DeleteInboxParams {
pub inbox_id: String
}
#[derive(Clone, Debug)]
pub struct GetAllInboxesParams {
pub favourite: Option<bool>,
pub page: Option<i32>,
pub search: Option<String>,
pub size: Option<i32>,
pub sort: Option<String>,
pub tag: Option<String>,
pub team_access: Option<bool>
}
#[derive(Clone, Debug)]
pub struct GetEmailsParams {
pub inbox_id: String,
pub limit: Option<i32>,
pub min_count: Option<i64>,
pub retry_timeout: Option<i64>,
pub since: Option<String>,
pub size: Option<i32>,
pub sort: Option<String>
}
#[derive(Clone, Debug)]
pub struct GetInboxParams {
pub inbox_id: String
}
#[derive(Clone, Debug)]
pub struct GetInboxEmailsPaginatedParams {
pub inbox_id: String,
pub page: Option<i32>,
pub size: Option<i32>,
pub sort: Option<String>
}
#[derive(Clone, Debug)]
pub struct GetInboxSentEmailsParams {
pub inbox_id: String,
pub page: Option<i32>,
pub size: Option<i32>,
pub sort: Option<String>
}
#[derive(Clone, Debug)]
pub struct GetInboxesParams {
pub size: Option<i32>,
pub sort: Option<String>
}
#[derive(Clone, Debug)]
pub struct GetOrganizationInboxesParams {
pub page: Option<i32>,
pub size: Option<i32>,
pub sort: Option<String>
}
#[derive(Clone, Debug)]
pub struct SendEmailParams {
pub inbox_id: String,
pub send_email_options: Option<crate::models::SendEmailOptions>
}
#[derive(Clone, Debug)]
pub struct SendEmailAndConfirmParams {
pub inbox_id: String,
pub send_email_options: Option<crate::models::SendEmailOptions>
}
#[derive(Clone, Debug)]
pub struct SetInboxFavouritedParams {
pub inbox_id: String,
pub set_inbox_favourited_options: crate::models::SetInboxFavouritedOptions
}
#[derive(Clone, Debug)]
pub struct UpdateInboxParams {
pub inbox_id: String,
pub update_inbox_options: crate::models::UpdateInboxOptions
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateInboxError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateInboxWithOptionsError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteAllInboxesError {
Status401(),
Status403(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteInboxError {
Status401(),
Status403(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAllInboxesError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetEmailsError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetInboxError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetInboxEmailsPaginatedError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetInboxSentEmailsError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetInboxTagsError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetInboxesError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetOrganizationInboxesError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendEmailError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendEmailAndConfirmError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetInboxFavouritedError {
Status401(),
Status403(),
Status404(),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateInboxError {
Status401(),
Status403(),
UnknownValue(serde_json::Value),
}
pub async fn create_inbox(configuration: &configuration::Configuration, params: CreateInboxParams) -> Result<crate::models::Inbox, Error<CreateInboxError>> {
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 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) = 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))
}
}
pub async fn create_inbox_with_options(configuration: &configuration::Configuration, params: CreateInboxWithOptionsParams) -> Result<crate::models::Inbox, Error<CreateInboxWithOptionsError>> {
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))
}
}
pub async fn delete_all_inboxes(configuration: &configuration::Configuration) -> Result<(), Error<DeleteAllInboxesError>> {
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))
}
}
pub async fn delete_inbox(configuration: &configuration::Configuration, params: DeleteInboxParams) -> Result<(), Error<DeleteInboxError>> {
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))
}
}
pub async fn get_all_inboxes(configuration: &configuration::Configuration, params: GetAllInboxesParams) -> Result<crate::models::PageInboxProjection, Error<GetAllInboxesError>> {
let favourite = params.favourite;
let page = params.page;
let search = params.search;
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) = 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) = 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))
}
}
pub async fn get_emails(configuration: &configuration::Configuration, params: GetEmailsParams) -> Result<Vec<crate::models::EmailPreview>, Error<GetEmailsError>> {
let inbox_id = params.inbox_id;
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 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) = 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_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))
}
}
pub async fn get_inbox(configuration: &configuration::Configuration, params: GetInboxParams) -> Result<crate::models::Inbox, Error<GetInboxError>> {
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))
}
}
pub async fn get_inbox_emails_paginated(configuration: &configuration::Configuration, params: GetInboxEmailsPaginatedParams) -> Result<crate::models::PageEmailPreview, Error<GetInboxEmailsPaginatedError>> {
let inbox_id = params.inbox_id;
let page = params.page;
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) = page {
local_var_req_builder = local_var_req_builder.query(&[("page", &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))
}
}
pub async fn get_inbox_sent_emails(configuration: &configuration::Configuration, params: GetInboxSentEmailsParams) -> Result<crate::models::PageSentEmailProjection, Error<GetInboxSentEmailsError>> {
let inbox_id = params.inbox_id;
let page = params.page;
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) = page {
local_var_req_builder = local_var_req_builder.query(&[("page", &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))
}
}
pub async fn get_inbox_tags(configuration: &configuration::Configuration) -> Result<Vec<String>, Error<GetInboxTagsError>> {
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))
}
}
pub async fn get_inboxes(configuration: &configuration::Configuration, params: GetInboxesParams) -> Result<Vec<crate::models::Inbox>, Error<GetInboxesError>> {
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) = 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))
}
}
pub async fn get_organization_inboxes(configuration: &configuration::Configuration, params: GetOrganizationInboxesParams) -> Result<crate::models::PageOrganizationInboxProjection, Error<GetOrganizationInboxesError>> {
let page = params.page;
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) = page {
local_var_req_builder = local_var_req_builder.query(&[("page", &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))
}
}
pub async fn send_email(configuration: &configuration::Configuration, params: SendEmailParams) -> Result<(), Error<SendEmailError>> {
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))
}
}
pub async fn send_email_and_confirm(configuration: &configuration::Configuration, params: SendEmailAndConfirmParams) -> Result<crate::models::SentEmailDto, Error<SendEmailAndConfirmError>> {
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))
}
}
pub async fn set_inbox_favourited(configuration: &configuration::Configuration, params: SetInboxFavouritedParams) -> Result<crate::models::Inbox, Error<SetInboxFavouritedError>> {
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))
}
}
pub async fn update_inbox(configuration: &configuration::Configuration, params: UpdateInboxParams) -> Result<crate::models::Inbox, Error<UpdateInboxError>> {
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))
}
}