/*
 * 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 CommonActionsControllerApiClient<C: hyper::client::Connect> {
    configuration: Rc<configuration::Configuration<C>>,
}

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

pub trait CommonActionsControllerApi {
    fn create_new_email_address(&self, allow_team_access: Option<bool>, expires_at: Option<String>, expires_in: Option<i64>, use_domain_pool: Option<bool>) -> Box<dyn Future<Item = crate::models::Inbox, Error = Error<serde_json::Value>>>;
    fn create_new_email_address1(&self, allow_team_access: Option<bool>, expires_at: Option<String>, expires_in: Option<i64>, use_domain_pool: Option<bool>) -> Box<dyn Future<Item = crate::models::Inbox, Error = Error<serde_json::Value>>>;
    fn empty_inbox(&self, inbox_id: &str) -> Box<dyn Future<Item = (), Error = Error<serde_json::Value>>>;
    fn send_email_simple(&self, email_options: crate::models::SimpleSendEmailOptions) -> Box<dyn Future<Item = (), Error = Error<serde_json::Value>>>;
}

impl<C: hyper::client::Connect>CommonActionsControllerApi for CommonActionsControllerApiClient<C> {
    fn create_new_email_address(&self, allow_team_access: Option<bool>, expires_at: Option<String>, expires_in: Option<i64>, use_domain_pool: Option<bool>) -> Box<dyn Future<Item = crate::models::Inbox, Error = Error<serde_json::Value>>> {
        let mut req = __internal_request::Request::new(hyper::Method::Post, "/createInbox".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) = allow_team_access {
            req = req.with_query_param("allowTeamAccess".to_string(), s.to_string());
        }
        if let Some(ref s) = expires_at {
            req = req.with_query_param("expiresAt".to_string(), s.to_string());
        }
        if let Some(ref s) = expires_in {
            req = req.with_query_param("expiresIn".to_string(), s.to_string());
        }
        if let Some(ref s) = use_domain_pool {
            req = req.with_query_param("useDomainPool".to_string(), s.to_string());
        }

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

    fn create_new_email_address1(&self, allow_team_access: Option<bool>, expires_at: Option<String>, expires_in: Option<i64>, use_domain_pool: Option<bool>) -> Box<dyn Future<Item = crate::models::Inbox, Error = Error<serde_json::Value>>> {
        let mut req = __internal_request::Request::new(hyper::Method::Post, "/newEmailAddress".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) = allow_team_access {
            req = req.with_query_param("allowTeamAccess".to_string(), s.to_string());
        }
        if let Some(ref s) = expires_at {
            req = req.with_query_param("expiresAt".to_string(), s.to_string());
        }
        if let Some(ref s) = expires_in {
            req = req.with_query_param("expiresIn".to_string(), s.to_string());
        }
        if let Some(ref s) = use_domain_pool {
            req = req.with_query_param("useDomainPool".to_string(), s.to_string());
        }

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

    fn empty_inbox(&self, inbox_id: &str) -> Box<dyn Future<Item = (), Error = Error<serde_json::Value>>> {
        let mut req = __internal_request::Request::new(hyper::Method::Delete, "/emptyInbox".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_query_param("inboxId".to_string(), inbox_id.to_string());
        req = req.returns_nothing();

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

    fn send_email_simple(&self, email_options: crate::models::SimpleSendEmailOptions) -> Box<dyn Future<Item = (), Error = Error<serde_json::Value>>> {
        let mut req = __internal_request::Request::new(hyper::Method::Post, "/sendEmail".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(email_options);
        req = req.returns_nothing();

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

}
