use std::borrow::Borrow;
#[allow(unused_imports)]
use std::option::Option;
use std::sync::Arc;
use hyper;
use hyper_util::client::legacy::connect::Connect;
use super::request as __internal_request;
use super::{configuration, Error};
use crate::line_insight::models;
#[derive(Clone)]
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,
) -> impl std::future::Future<Output = Result<models::GetFriendsDemographicsResponse, Error>> + Send;
fn get_message_event(
&self,
request_id: &str,
) -> impl std::future::Future<Output = Result<models::GetMessageEventResponse, Error>> + Send;
fn get_number_of_followers(
&self,
date: Option<&str>,
) -> impl std::future::Future<Output = Result<models::GetNumberOfFollowersResponse, Error>> + Send;
fn get_number_of_message_deliveries(
&self,
date: &str,
) -> impl std::future::Future<Output = Result<models::GetNumberOfMessageDeliveriesResponse, Error>>
+ Send;
fn get_statistics_per_unit(
&self,
custom_aggregation_unit: &str,
from: &str,
to: &str,
) -> impl std::future::Future<Output = Result<models::GetStatisticsPerUnitResponse, Error>> + Send;
}
impl<C: Connect> InsightApi for InsightApiClient<C>
where
C: Clone + std::marker::Send + Sync,
{
#[allow(unused_mut)]
async fn get_friends_demographics(
&self,
) -> Result<models::GetFriendsDemographicsResponse, Error> {
let mut req = __internal_request::Request::new(
hyper::Method::GET,
"/v2/bot/insight/demographic".to_string(),
);
req.execute(self.configuration.borrow()).await
}
#[allow(unused_mut)]
async fn get_message_event(
&self,
request_id: &str,
) -> Result<models::GetMessageEventResponse, Error> {
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()).await
}
#[allow(unused_mut)]
async fn get_number_of_followers(
&self,
date: Option<&str>,
) -> Result<models::GetNumberOfFollowersResponse, Error> {
let mut req = __internal_request::Request::new(
hyper::Method::GET,
"/v2/bot/insight/followers".to_string(),
);
if let Some(ref s) = date {
req = req.with_query_param("date".to_string(), s.to_string());
}
req.execute(self.configuration.borrow()).await
}
#[allow(unused_mut)]
async fn get_number_of_message_deliveries(
&self,
date: &str,
) -> Result<models::GetNumberOfMessageDeliveriesResponse, Error> {
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()).await
}
#[allow(unused_mut)]
async fn get_statistics_per_unit(
&self,
custom_aggregation_unit: &str,
from: &str,
to: &str,
) -> Result<models::GetStatisticsPerUnitResponse, Error> {
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()).await
}
}