use super::{configuration, ContentType, Error};
use crate::gen::manager::{apis::ResponseContent, models};
use reqwest;
use serde::{de::Error as _, Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAllSimpleReportingCallsError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListDialerSimpleReportingCallsError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListInboundSimpleReportingCallsError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListOutboundSimpleReportingCallsError {
UnknownValue(serde_json::Value),
}
pub async fn list_all_simple_reporting_calls(
configuration: &configuration::Configuration,
page: Option<i32>,
max: Option<i32>,
session_id: Option<&str>,
conversation_id: Option<&str>,
id: Option<models::ListReportingCallsIdParameter>,
parent_id: Option<models::ListReportingCallsIdParameter>,
r#type: Option<models::ListReportingCallsTypeParameter>,
from: Option<&str>,
from_number: Option<&str>,
to: Option<models::ListReportingCallsToParameter>,
to_number: Option<models::ListReportingCallsToParameter>,
time_start: Option<i32>,
time_end: Option<i32>,
agent_id: Option<models::ListReportingCallsIdParameter>,
queue_name: Option<&str>,
agent_name: Option<&str>,
bridged: Option<bool>,
duration_start: Option<f64>,
duration_end: Option<f64>,
wait_time_start: Option<f64>,
wait_time_end: Option<f64>,
queue_wait_time_start: Option<f64>,
queue_wait_time_end: Option<f64>,
bridge_time_start: Option<f64>,
bridge_time_end: Option<f64>,
talk_time_start: Option<f64>,
talk_time_end: Option<f64>,
hold_time_start: Option<f64>,
hold_time_end: Option<f64>,
wrapup_time_start: Option<f64>,
wrapup_time_end: Option<f64>,
handle_time_start: Option<f64>,
handle_time_end: Option<f64>,
) -> Result<models::PaginatedReportingCallResponse, Error<ListAllSimpleReportingCallsError>> {
let p_query_page = page;
let p_query_max = max;
let p_query_session_id = session_id;
let p_query_conversation_id = conversation_id;
let p_query_id = id;
let p_query_parent_id = parent_id;
let p_query_type = r#type;
let p_query_from = from;
let p_query_from_number = from_number;
let p_query_to = to;
let p_query_to_number = to_number;
let p_query_time_start = time_start;
let p_query_time_end = time_end;
let p_query_agent_id = agent_id;
let p_query_queue_name = queue_name;
let p_query_agent_name = agent_name;
let p_query_bridged = bridged;
let p_query_duration_start = duration_start;
let p_query_duration_end = duration_end;
let p_query_wait_time_start = wait_time_start;
let p_query_wait_time_end = wait_time_end;
let p_query_queue_wait_time_start = queue_wait_time_start;
let p_query_queue_wait_time_end = queue_wait_time_end;
let p_query_bridge_time_start = bridge_time_start;
let p_query_bridge_time_end = bridge_time_end;
let p_query_talk_time_start = talk_time_start;
let p_query_talk_time_end = talk_time_end;
let p_query_hold_time_start = hold_time_start;
let p_query_hold_time_end = hold_time_end;
let p_query_wrapup_time_start = wrapup_time_start;
let p_query_wrapup_time_end = wrapup_time_end;
let p_query_handle_time_start = handle_time_start;
let p_query_handle_time_end = handle_time_end;
let uri_str = format!("{}/api/v2/calls/reporting/simple", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_page {
req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_max {
req_builder = req_builder.query(&[("max", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_session_id {
req_builder = req_builder.query(&[("sessionId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_conversation_id {
req_builder = req_builder.query(&[("conversationId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_id {
req_builder = req_builder.query(&[("id", &serde_json::to_string(param_value)?)]);
}
if let Some(ref param_value) = p_query_parent_id {
req_builder = req_builder.query(&[("parentId", &serde_json::to_string(param_value)?)]);
}
if let Some(ref param_value) = p_query_type {
req_builder = req_builder.query(&[("type", &serde_json::to_string(param_value)?)]);
}
if let Some(ref param_value) = p_query_from {
req_builder = req_builder.query(&[("from", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_from_number {
req_builder = req_builder.query(&[("fromNumber", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_to {
req_builder = req_builder.query(&[("to", &serde_json::to_string(param_value)?)]);
}
if let Some(ref param_value) = p_query_to_number {
req_builder = req_builder.query(&[("toNumber", &serde_json::to_string(param_value)?)]);
}
if let Some(ref param_value) = p_query_time_start {
req_builder = req_builder.query(&[("time.start", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_time_end {
req_builder = req_builder.query(&[("time.end", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_agent_id {
req_builder = req_builder.query(&[("agentId", &serde_json::to_string(param_value)?)]);
}
if let Some(ref param_value) = p_query_queue_name {
req_builder = req_builder.query(&[("queueName", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_agent_name {
req_builder = req_builder.query(&[("agentName", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_bridged {
req_builder = req_builder.query(&[("bridged", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_duration_start {
req_builder = req_builder.query(&[("duration.start", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_duration_end {
req_builder = req_builder.query(&[("duration.end", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_wait_time_start {
req_builder = req_builder.query(&[("waitTime.start", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_wait_time_end {
req_builder = req_builder.query(&[("waitTime.end", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_queue_wait_time_start {
req_builder = req_builder.query(&[("queueWaitTime.start", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_queue_wait_time_end {
req_builder = req_builder.query(&[("queueWaitTime.end", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_bridge_time_start {
req_builder = req_builder.query(&[("bridgeTime.start", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_bridge_time_end {
req_builder = req_builder.query(&[("bridgeTime.end", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_talk_time_start {
req_builder = req_builder.query(&[("talkTime.start", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_talk_time_end {
req_builder = req_builder.query(&[("talkTime.end", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_hold_time_start {
req_builder = req_builder.query(&[("holdTime.start", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_hold_time_end {
req_builder = req_builder.query(&[("holdTime.end", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_wrapup_time_start {
req_builder = req_builder.query(&[("wrapupTime.start", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_wrapup_time_end {
req_builder = req_builder.query(&[("wrapupTime.end", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_handle_time_start {
req_builder = req_builder.query(&[("handleTime.start", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_handle_time_end {
req_builder = req_builder.query(&[("handleTime.end", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedReportingCallResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PaginatedReportingCallResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAllSimpleReportingCallsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn list_dialer_simple_reporting_calls(
configuration: &configuration::Configuration,
page: Option<i32>,
max: Option<i32>,
) -> Result<models::PaginatedReportingCallResponse, Error<ListDialerSimpleReportingCallsError>> {
let p_query_page = page;
let p_query_max = max;
let uri_str = format!(
"{}/api/v2/calls/reporting/simple/dialer",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_page {
req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_max {
req_builder = req_builder.query(&[("max", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedReportingCallResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PaginatedReportingCallResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListDialerSimpleReportingCallsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn list_inbound_simple_reporting_calls(
configuration: &configuration::Configuration,
page: Option<i32>,
max: Option<i32>,
) -> Result<models::PaginatedReportingCallResponse, Error<ListInboundSimpleReportingCallsError>> {
let p_query_page = page;
let p_query_max = max;
let uri_str = format!(
"{}/api/v2/calls/reporting/simple/inbound",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_page {
req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_max {
req_builder = req_builder.query(&[("max", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedReportingCallResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PaginatedReportingCallResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListInboundSimpleReportingCallsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn list_outbound_simple_reporting_calls(
configuration: &configuration::Configuration,
page: Option<i32>,
max: Option<i32>,
) -> Result<models::PaginatedReportingCallResponse, Error<ListOutboundSimpleReportingCallsError>> {
let p_query_page = page;
let p_query_max = max;
let uri_str = format!(
"{}/api/v2/calls/reporting/simple/outbound",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_page {
req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_max {
req_builder = req_builder.query(&[("max", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedReportingCallResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PaginatedReportingCallResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListOutboundSimpleReportingCallsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}