mailslurp 11.5.20

Official MailSlurp Email API Client
Documentation
/*
 * 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 std::rc::Rc;
use std::borrow::Borrow;
#[allow(unused_imports)]
use std::option::Option;

use hyper;
use serde_json;
use futures::Future;

use super::{Error, configuration};
use super::request as __internal_request;

pub struct AliasControllerApiClient<C: hyper::client::Connect> {
    configuration: Rc<configuration::Configuration<C>>,
}

impl<C: hyper::client::Connect> AliasControllerApiClient<C> {
    pub fn new(configuration: Rc<configuration::Configuration<C>>) -> AliasControllerApiClient<C> {
        AliasControllerApiClient {
            configuration,
        }
    }
}

pub trait AliasControllerApi {
    fn create_alias(&self, create_alias_options: crate::models::CreateAliasOptions) -> Box<dyn Future<Item = crate::models::AliasDto, Error = Error<serde_json::Value>>>;
    fn delete_alias(&self, alias_id: &str) -> Box<dyn Future<Item = (), Error = Error<serde_json::Value>>>;
    fn get_alias(&self, alias_id: &str) -> Box<dyn Future<Item = crate::models::AliasDto, Error = Error<serde_json::Value>>>;
    fn get_alias_emails(&self, alias_id: &str, page: Option<i32>, size: Option<i32>, sort: Option<&str>) -> Box<dyn Future<Item = crate::models::PageEmailProjection, Error = Error<serde_json::Value>>>;
    fn get_alias_threads(&self, alias_id: &str, page: Option<i32>, size: Option<i32>, sort: Option<&str>) -> Box<dyn Future<Item = crate::models::PageThreadProjection, Error = Error<serde_json::Value>>>;
    fn get_aliases(&self, page: Option<i32>, size: Option<i32>, sort: Option<&str>) -> Box<dyn Future<Item = crate::models::PageAlias, Error = Error<serde_json::Value>>>;
    fn reply_to_alias_email(&self, alias_id: &str, email_id: &str, reply_to_alias_email_options: crate::models::ReplyToAliasEmailOptions) -> Box<dyn Future<Item = crate::models::SentEmailDto, Error = Error<serde_json::Value>>>;
    fn send_alias_email(&self, alias_id: &str, send_email_options: Option<crate::models::SendEmailOptions>) -> Box<dyn Future<Item = crate::models::SentEmailDto, Error = Error<serde_json::Value>>>;
    fn update_alias(&self, alias_id: &str, update_alias_options: crate::models::UpdateAliasOptions) -> Box<dyn Future<Item = (), Error = Error<serde_json::Value>>>;
}

impl<C: hyper::client::Connect>AliasControllerApi for AliasControllerApiClient<C> {
    fn create_alias(&self, create_alias_options: crate::models::CreateAliasOptions) -> Box<dyn Future<Item = crate::models::AliasDto, Error = Error<serde_json::Value>>> {
        let mut req = __internal_request::Request::new(hyper::Method::Post, "/aliases".to_string())
            .with_auth(__internal_request::Auth::ApiKey(__internal_request::ApiKey{
                in_header: true,
                in_query: false,
                param_name: "x-api-key".to_owned(),
            }))
        ;
        req = req.with_body_param(create_alias_options);

        req.execute(self.configuration.borrow())
    }

    fn delete_alias(&self, alias_id: &str) -> Box<dyn Future<Item = (), Error = Error<serde_json::Value>>> {
        let mut req = __internal_request::Request::new(hyper::Method::Delete, "/aliases/{aliasId}".to_string())
            .with_auth(__internal_request::Auth::ApiKey(__internal_request::ApiKey{
                in_header: true,
                in_query: false,
                param_name: "x-api-key".to_owned(),
            }))
        ;
        req = req.with_path_param("aliasId".to_string(), alias_id.to_string());
        req = req.returns_nothing();

        req.execute(self.configuration.borrow())
    }

    fn get_alias(&self, alias_id: &str) -> Box<dyn Future<Item = crate::models::AliasDto, Error = Error<serde_json::Value>>> {
        let mut req = __internal_request::Request::new(hyper::Method::Get, "/aliases/{aliasId}".to_string())
            .with_auth(__internal_request::Auth::ApiKey(__internal_request::ApiKey{
                in_header: true,
                in_query: false,
                param_name: "x-api-key".to_owned(),
            }))
        ;
        req = req.with_path_param("aliasId".to_string(), alias_id.to_string());

        req.execute(self.configuration.borrow())
    }

    fn get_alias_emails(&self, alias_id: &str, page: Option<i32>, size: Option<i32>, sort: Option<&str>) -> Box<dyn Future<Item = crate::models::PageEmailProjection, Error = Error<serde_json::Value>>> {
        let mut req = __internal_request::Request::new(hyper::Method::Get, "/aliases/{aliasId}/emails".to_string())
            .with_auth(__internal_request::Auth::ApiKey(__internal_request::ApiKey{
                in_header: true,
                in_query: false,
                param_name: "x-api-key".to_owned(),
            }))
        ;
        if let Some(ref s) = page {
            req = req.with_query_param("page".to_string(), s.to_string());
        }
        if let Some(ref s) = size {
            req = req.with_query_param("size".to_string(), s.to_string());
        }
        if let Some(ref s) = sort {
            req = req.with_query_param("sort".to_string(), s.to_string());
        }
        req = req.with_path_param("aliasId".to_string(), alias_id.to_string());

        req.execute(self.configuration.borrow())
    }

    fn get_alias_threads(&self, alias_id: &str, page: Option<i32>, size: Option<i32>, sort: Option<&str>) -> Box<dyn Future<Item = crate::models::PageThreadProjection, Error = Error<serde_json::Value>>> {
        let mut req = __internal_request::Request::new(hyper::Method::Get, "/aliases/{aliasId}/threads".to_string())
            .with_auth(__internal_request::Auth::ApiKey(__internal_request::ApiKey{
                in_header: true,
                in_query: false,
                param_name: "x-api-key".to_owned(),
            }))
        ;
        if let Some(ref s) = page {
            req = req.with_query_param("page".to_string(), s.to_string());
        }
        if let Some(ref s) = size {
            req = req.with_query_param("size".to_string(), s.to_string());
        }
        if let Some(ref s) = sort {
            req = req.with_query_param("sort".to_string(), s.to_string());
        }
        req = req.with_path_param("aliasId".to_string(), alias_id.to_string());

        req.execute(self.configuration.borrow())
    }

    fn get_aliases(&self, page: Option<i32>, size: Option<i32>, sort: Option<&str>) -> Box<dyn Future<Item = crate::models::PageAlias, Error = Error<serde_json::Value>>> {
        let mut req = __internal_request::Request::new(hyper::Method::Get, "/aliases".to_string())
            .with_auth(__internal_request::Auth::ApiKey(__internal_request::ApiKey{
                in_header: true,
                in_query: false,
                param_name: "x-api-key".to_owned(),
            }))
        ;
        if let Some(ref s) = page {
            req = req.with_query_param("page".to_string(), s.to_string());
        }
        if let Some(ref s) = size {
            req = req.with_query_param("size".to_string(), s.to_string());
        }
        if let Some(ref s) = sort {
            req = req.with_query_param("sort".to_string(), s.to_string());
        }

        req.execute(self.configuration.borrow())
    }

    fn reply_to_alias_email(&self, alias_id: &str, email_id: &str, reply_to_alias_email_options: crate::models::ReplyToAliasEmailOptions) -> Box<dyn Future<Item = crate::models::SentEmailDto, Error = Error<serde_json::Value>>> {
        let mut req = __internal_request::Request::new(hyper::Method::Put, "/aliases/{aliasId}/emails/{emailId}".to_string())
            .with_auth(__internal_request::Auth::ApiKey(__internal_request::ApiKey{
                in_header: true,
                in_query: false,
                param_name: "x-api-key".to_owned(),
            }))
        ;
        req = req.with_path_param("aliasId".to_string(), alias_id.to_string());
        req = req.with_path_param("emailId".to_string(), email_id.to_string());
        req = req.with_body_param(reply_to_alias_email_options);

        req.execute(self.configuration.borrow())
    }

    fn send_alias_email(&self, alias_id: &str, send_email_options: Option<crate::models::SendEmailOptions>) -> Box<dyn Future<Item = crate::models::SentEmailDto, Error = Error<serde_json::Value>>> {
        let mut req = __internal_request::Request::new(hyper::Method::Post, "/aliases/{aliasId}/emails".to_string())
            .with_auth(__internal_request::Auth::ApiKey(__internal_request::ApiKey{
                in_header: true,
                in_query: false,
                param_name: "x-api-key".to_owned(),
            }))
        ;
        req = req.with_path_param("aliasId".to_string(), alias_id.to_string());
        req = req.with_body_param(send_email_options);

        req.execute(self.configuration.borrow())
    }

    fn update_alias(&self, alias_id: &str, update_alias_options: crate::models::UpdateAliasOptions) -> Box<dyn Future<Item = (), Error = Error<serde_json::Value>>> {
        let mut req = __internal_request::Request::new(hyper::Method::Put, "/aliases/{aliasId}".to_string())
            .with_auth(__internal_request::Auth::ApiKey(__internal_request::ApiKey{
                in_header: true,
                in_query: false,
                param_name: "x-api-key".to_owned(),
            }))
        ;
        req = req.with_path_param("aliasId".to_string(), alias_id.to_string());
        req = req.with_body_param(update_alias_options);
        req = req.returns_nothing();

        req.execute(self.configuration.borrow())
    }

}