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

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

pub trait GroupControllerApi {
    fn add_contacts_to_group(&self, group_id: &str, update_group_contacts_option: crate::models::UpdateGroupContacts) -> Box<dyn Future<Item = crate::models::GroupContactsDto, Error = Error<serde_json::Value>>>;
    fn create_group(&self, create_group_options: crate::models::CreateGroupOptions) -> Box<dyn Future<Item = crate::models::GroupDto, Error = Error<serde_json::Value>>>;
    fn delete_group(&self, group_id: &str) -> Box<dyn Future<Item = (), Error = Error<serde_json::Value>>>;
    fn get_all_groups(&self, page: Option<i32>, size: Option<i32>, sort: Option<&str>) -> Box<dyn Future<Item = crate::models::PageGroupProjection, Error = Error<serde_json::Value>>>;
    fn get_group(&self, group_id: &str) -> Box<dyn Future<Item = crate::models::GroupDto, Error = Error<serde_json::Value>>>;
    fn get_group_with_contacts(&self, group_id: &str) -> Box<dyn Future<Item = crate::models::GroupContactsDto, Error = Error<serde_json::Value>>>;
    fn get_group_with_contacts_paginated(&self, group_id: &str, page: Option<i32>, size: Option<i32>, sort: Option<&str>) -> Box<dyn Future<Item = crate::models::PageContactProjection, Error = Error<serde_json::Value>>>;
    fn get_groups(&self, ) -> Box<dyn Future<Item = Vec<crate::models::GroupProjection>, Error = Error<serde_json::Value>>>;
    fn remove_contacts_from_group(&self, group_id: &str, update_group_contacts_option: crate::models::UpdateGroupContacts) -> Box<dyn Future<Item = crate::models::GroupContactsDto, Error = Error<serde_json::Value>>>;
}

impl<C: hyper::client::Connect>GroupControllerApi for GroupControllerApiClient<C> {
    fn add_contacts_to_group(&self, group_id: &str, update_group_contacts_option: crate::models::UpdateGroupContacts) -> Box<dyn Future<Item = crate::models::GroupContactsDto, Error = Error<serde_json::Value>>> {
        let mut req = __internal_request::Request::new(hyper::Method::Put, "/groups/{groupId}/contacts".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("groupId".to_string(), group_id.to_string());
        req = req.with_body_param(update_group_contacts_option);

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

    fn create_group(&self, create_group_options: crate::models::CreateGroupOptions) -> Box<dyn Future<Item = crate::models::GroupDto, Error = Error<serde_json::Value>>> {
        let mut req = __internal_request::Request::new(hyper::Method::Post, "/groups".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_group_options);

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

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

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

    fn get_all_groups(&self, page: Option<i32>, size: Option<i32>, sort: Option<&str>) -> Box<dyn Future<Item = crate::models::PageGroupProjection, Error = Error<serde_json::Value>>> {
        let mut req = __internal_request::Request::new(hyper::Method::Get, "/groups/paginated".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 get_group(&self, group_id: &str) -> Box<dyn Future<Item = crate::models::GroupDto, Error = Error<serde_json::Value>>> {
        let mut req = __internal_request::Request::new(hyper::Method::Get, "/groups/{groupId}".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("groupId".to_string(), group_id.to_string());

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

    fn get_group_with_contacts(&self, group_id: &str) -> Box<dyn Future<Item = crate::models::GroupContactsDto, Error = Error<serde_json::Value>>> {
        let mut req = __internal_request::Request::new(hyper::Method::Get, "/groups/{groupId}/contacts".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("groupId".to_string(), group_id.to_string());

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

    fn get_group_with_contacts_paginated(&self, group_id: &str, page: Option<i32>, size: Option<i32>, sort: Option<&str>) -> Box<dyn Future<Item = crate::models::PageContactProjection, Error = Error<serde_json::Value>>> {
        let mut req = __internal_request::Request::new(hyper::Method::Get, "/groups/{groupId}/contacts-paginated".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("groupId".to_string(), group_id.to_string());

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

    fn get_groups(&self, ) -> Box<dyn Future<Item = Vec<crate::models::GroupProjection>, Error = Error<serde_json::Value>>> {
        let mut req = __internal_request::Request::new(hyper::Method::Get, "/groups".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.execute(self.configuration.borrow())
    }

    fn remove_contacts_from_group(&self, group_id: &str, update_group_contacts_option: crate::models::UpdateGroupContacts) -> Box<dyn Future<Item = crate::models::GroupContactsDto, Error = Error<serde_json::Value>>> {
        let mut req = __internal_request::Request::new(hyper::Method::Delete, "/groups/{groupId}/contacts".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("groupId".to_string(), group_id.to_string());
        req = req.with_body_param(update_group_contacts_option);

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

}
