/*
 * LINE Messaging API(Insight)
 *
 * This document describes LINE Messaging API(Insight).
 *
 * The version of the OpenAPI document: 0.0.1
 * 
 * Generated by: https://openapi-generator.tech
 */

use std::sync::Arc;
use std::borrow::Borrow;
use std::pin::Pin;
#[allow(unused_imports)]
use std::option::Option;

use hyper;
use hyper_util::client::legacy::connect::Connect;
use futures::Future;

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

pub struct InsightApiClient<C: Connect>
    where C: Clone + std::marker::Send + Sync + 'static {
    configuration: Arc<configuration::Configuration<C>>,
}

impl<C: Connect> InsightApiClient<C>
    where C: Clone + std::marker::Send + Sync {
    pub fn new(configuration: Arc<configuration::Configuration<C>>) -> InsightApiClient<C> {
        InsightApiClient {
            configuration,
        }
    }
}

pub trait InsightApi: Send + Sync {
    fn get_friends_demographics(&self, ) -> Pin<Box<dyn Future<Output = Result<models::GetFriendsDemographicsResponse, Error>> + Send>>;
    fn get_message_event(&self, request_id: &str) -> Pin<Box<dyn Future<Output = Result<models::GetMessageEventResponse, Error>> + Send>>;
    fn get_number_of_followers(&self, date: Option<&str>) -> Pin<Box<dyn Future<Output = Result<models::GetNumberOfFollowersResponse, Error>> + Send>>;
    fn get_number_of_message_deliveries(&self, date: &str) -> Pin<Box<dyn Future<Output = Result<models::GetNumberOfMessageDeliveriesResponse, Error>> + Send>>;
    fn get_statistics_per_unit(&self, custom_aggregation_unit: &str, from: &str, to: &str) -> Pin<Box<dyn Future<Output = Result<models::GetStatisticsPerUnitResponse, Error>> + Send>>;
}

impl<C: Connect>InsightApi for InsightApiClient<C>
    where C: Clone + std::marker::Send + Sync {
    #[allow(unused_mut)]
    fn get_friends_demographics(&self, ) -> Pin<Box<dyn Future<Output = Result<models::GetFriendsDemographicsResponse, Error>> + Send>> {
        let mut req = __internal_request::Request::new(hyper::Method::GET, "/v2/bot/insight/demographic".to_string())
        ;

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

    #[allow(unused_mut)]
    fn get_message_event(&self, request_id: &str) -> Pin<Box<dyn Future<Output = Result<models::GetMessageEventResponse, Error>> + Send>> {
        let mut req = __internal_request::Request::new(hyper::Method::GET, "/v2/bot/insight/message/event".to_string())
        ;
        req = req.with_query_param("requestId".to_string(), request_id.to_string());

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

    #[allow(unused_mut)]
    fn get_number_of_followers(&self, date: Option<&str>) -> Pin<Box<dyn Future<Output = Result<models::GetNumberOfFollowersResponse, Error>> + Send>> {
        let mut req = __internal_request::Request::new(hyper::Method::GET, "/v2/bot/insight/followers".to_string())
        ;
        if let Some(ref s) = date {
            let query_value = s.to_string();
            req = req.with_query_param("date".to_string(), query_value);
        }

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

    #[allow(unused_mut)]
    fn get_number_of_message_deliveries(&self, date: &str) -> Pin<Box<dyn Future<Output = Result<models::GetNumberOfMessageDeliveriesResponse, Error>> + Send>> {
        let mut req = __internal_request::Request::new(hyper::Method::GET, "/v2/bot/insight/message/delivery".to_string())
        ;
        req = req.with_query_param("date".to_string(), date.to_string());

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

    #[allow(unused_mut)]
    fn get_statistics_per_unit(&self, custom_aggregation_unit: &str, from: &str, to: &str) -> Pin<Box<dyn Future<Output = Result<models::GetStatisticsPerUnitResponse, Error>> + Send>> {
        let mut req = __internal_request::Request::new(hyper::Method::GET, "/v2/bot/insight/message/event/aggregation".to_string())
        ;
        req = req.with_query_param("customAggregationUnit".to_string(), custom_aggregation_unit.to_string());
        req = req.with_query_param("from".to_string(), from.to_string());
        req = req.with_query_param("to".to_string(), to.to_string());

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

}
