/*
* Firefly III API v6.4.14
*
* This is the documentation of the Firefly III API. Please report any bugs or issues. You may use the \"Authorize\" button to try the API below. <br><br> Please keep in mind that the demo site does **not** accept requests from `curl`, `colly`, `wget`, etc. You must use a browser or a tool like Insomnia to make your test requests. <br><br> To learn more about the idiosyncrasies of this API, please read about the API in the [Firefly III API documentation](https://docs.firefly-iii.org/references/firefly-iii/api/). <br><br> <small>This file was last generated on 2025-12-26 @ 15:17:41 (Europe/Amsterdam)</small>
*
* The version of the OpenAPI document: v6.4.14
* Contact: james@firefly-iii.org
* Generated by: https://openapi-generator.tech
*/
#![allow(unused_imports)]
use reqwest;
use super::{configuration, Error};
use crate::apis::ResponseContent;
use crate::models::{self, *};
/// struct for typed errors of method [`insight_expense_asset`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsightExpenseAssetError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
Status422(models::ValidationErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`insight_expense_bill`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsightExpenseBillError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
Status422(models::ValidationErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`insight_expense_budget`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsightExpenseBudgetError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
Status422(models::ValidationErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`insight_expense_category`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsightExpenseCategoryError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
Status422(models::ValidationErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`insight_expense_expense`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsightExpenseExpenseError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
Status422(models::ValidationErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`insight_expense_no_bill`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsightExpenseNoBillError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
Status422(models::ValidationErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`insight_expense_no_budget`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsightExpenseNoBudgetError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
Status422(models::ValidationErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`insight_expense_no_category`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsightExpenseNoCategoryError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
Status422(models::ValidationErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`insight_expense_no_tag`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsightExpenseNoTagError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
Status422(models::ValidationErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`insight_expense_tag`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsightExpenseTagError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
Status422(models::ValidationErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`insight_expense_total`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsightExpenseTotalError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status422(models::ValidationErrorResponse),
Status500(models::InternalExceptionResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`insight_income_asset`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsightIncomeAssetError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
Status422(models::ValidationErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`insight_income_category`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsightIncomeCategoryError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
Status422(models::ValidationErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`insight_income_no_category`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsightIncomeNoCategoryError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
Status422(models::ValidationErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`insight_income_no_tag`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsightIncomeNoTagError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
Status422(models::ValidationErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`insight_income_revenue`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsightIncomeRevenueError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
Status422(models::ValidationErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`insight_income_tag`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsightIncomeTagError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
Status422(models::ValidationErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`insight_income_total`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsightIncomeTotalError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
Status422(models::ValidationErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`insight_transfer_category`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsightTransferCategoryError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
Status422(models::ValidationErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`insight_transfer_no_category`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsightTransferNoCategoryError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
Status422(models::ValidationErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`insight_transfer_no_tag`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsightTransferNoTagError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
Status422(models::ValidationErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`insight_transfer_tag`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsightTransferTagError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
Status422(models::ValidationErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`insight_transfer_total`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsightTransferTotalError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
Status422(models::ValidationErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`insight_transfers`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InsightTransfersError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
Status422(models::ValidationErrorResponse),
UnknownValue(serde_json::Value),
}
/// This endpoint gives a summary of the expenses made by the user, grouped by asset account.
pub async fn insight_expense_asset(
configuration: &configuration::Configuration,
start: String,
end: String,
x_trace_id: Option<&str>,
accounts_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
) -> Result<Vec<models::InsightGroupEntry>, Error<InsightExpenseAssetError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/insight/expense/asset",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
if let Some(ref local_var_str) = accounts_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("accounts[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"accounts[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = x_trace_id {
local_var_req_builder =
local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<InsightExpenseAssetError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// This endpoint gives a summary of the expenses made by the user, grouped by (any) bill.
pub async fn insight_expense_bill(
configuration: &configuration::Configuration,
start: String,
end: String,
x_trace_id: Option<&str>,
bills_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
accounts_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
) -> Result<Vec<models::InsightGroupEntry>, Error<InsightExpenseBillError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/insight/expense/bill",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
if let Some(ref local_var_str) = bills_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("bills[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"bills[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_str) = accounts_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("accounts[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"accounts[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = x_trace_id {
local_var_req_builder =
local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<InsightExpenseBillError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// This endpoint gives a summary of the expenses made by the user, grouped by (any) budget.
pub async fn insight_expense_budget(
configuration: &configuration::Configuration,
start: String,
end: String,
x_trace_id: Option<&str>,
budgets_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
accounts_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
) -> Result<Vec<models::InsightGroupEntry>, Error<InsightExpenseBudgetError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/insight/expense/budget",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
if let Some(ref local_var_str) = budgets_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("budgets[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"budgets[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_str) = accounts_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("accounts[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"accounts[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = x_trace_id {
local_var_req_builder =
local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<InsightExpenseBudgetError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// This endpoint gives a summary of the expenses made by the user, grouped by (any) category.
pub async fn insight_expense_category(
configuration: &configuration::Configuration,
start: String,
end: String,
x_trace_id: Option<&str>,
categories_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
accounts_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
) -> Result<Vec<models::InsightGroupEntry>, Error<InsightExpenseCategoryError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/insight/expense/category",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
if let Some(ref local_var_str) = categories_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("categories[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"categories[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_str) = accounts_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("accounts[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"accounts[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = x_trace_id {
local_var_req_builder =
local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<InsightExpenseCategoryError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// This endpoint gives a summary of the expenses made by the user, grouped by expense account.
pub async fn insight_expense_expense(
configuration: &configuration::Configuration,
start: String,
end: String,
x_trace_id: Option<&str>,
accounts_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
) -> Result<Vec<models::InsightGroupEntry>, Error<InsightExpenseExpenseError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/insight/expense/expense",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
if let Some(ref local_var_str) = accounts_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("accounts[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"accounts[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = x_trace_id {
local_var_req_builder =
local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<InsightExpenseExpenseError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// This endpoint gives a summary of the expenses made by the user, including only expenses with no bill.
pub async fn insight_expense_no_bill(
configuration: &configuration::Configuration,
start: String,
end: String,
x_trace_id: Option<&str>,
accounts_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
) -> Result<Vec<models::InsightTotalEntry>, Error<InsightExpenseNoBillError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/insight/expense/no-bill",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
if let Some(ref local_var_str) = accounts_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("accounts[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"accounts[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = x_trace_id {
local_var_req_builder =
local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<InsightExpenseNoBillError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// This endpoint gives a summary of the expenses made by the user, including only expenses with no budget.
pub async fn insight_expense_no_budget(
configuration: &configuration::Configuration,
start: String,
end: String,
x_trace_id: Option<&str>,
accounts_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
) -> Result<Vec<models::InsightTotalEntry>, Error<InsightExpenseNoBudgetError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/insight/expense/no-budget",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
if let Some(ref local_var_str) = accounts_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("accounts[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"accounts[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = x_trace_id {
local_var_req_builder =
local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<InsightExpenseNoBudgetError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// This endpoint gives a summary of the expenses made by the user, including only expenses with no category.
pub async fn insight_expense_no_category(
configuration: &configuration::Configuration,
start: String,
end: String,
x_trace_id: Option<&str>,
accounts_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
) -> Result<Vec<models::InsightTotalEntry>, Error<InsightExpenseNoCategoryError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/insight/expense/no-category",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
if let Some(ref local_var_str) = accounts_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("accounts[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"accounts[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = x_trace_id {
local_var_req_builder =
local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<InsightExpenseNoCategoryError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// This endpoint gives a summary of the expenses made by the user, including only expenses with no tag.
pub async fn insight_expense_no_tag(
configuration: &configuration::Configuration,
start: String,
end: String,
x_trace_id: Option<&str>,
accounts_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
) -> Result<Vec<models::InsightTotalEntry>, Error<InsightExpenseNoTagError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/insight/expense/no-tag",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
if let Some(ref local_var_str) = accounts_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("accounts[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"accounts[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = x_trace_id {
local_var_req_builder =
local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<InsightExpenseNoTagError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// This endpoint gives a summary of the expenses made by the user, grouped by (any) tag.
pub async fn insight_expense_tag(
configuration: &configuration::Configuration,
start: String,
end: String,
x_trace_id: Option<&str>,
tags_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
accounts_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
) -> Result<Vec<models::InsightGroupEntry>, Error<InsightExpenseTagError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/insight/expense/tag",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
if let Some(ref local_var_str) = tags_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("tags[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"tags[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_str) = accounts_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("accounts[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"accounts[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = x_trace_id {
local_var_req_builder =
local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<InsightExpenseTagError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// This endpoint gives a sum of the total expenses made by the user.
pub async fn insight_expense_total(
configuration: &configuration::Configuration,
start: String,
end: String,
x_trace_id: Option<&str>,
accounts_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
) -> Result<Vec<models::InsightTotalEntry>, Error<InsightExpenseTotalError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/insight/expense/total",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
if let Some(ref local_var_str) = accounts_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("accounts[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"accounts[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = x_trace_id {
local_var_req_builder =
local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<InsightExpenseTotalError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// This endpoint gives a summary of the income received by the user, grouped by asset account.
pub async fn insight_income_asset(
configuration: &configuration::Configuration,
start: String,
end: String,
x_trace_id: Option<&str>,
accounts_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
) -> Result<Vec<models::InsightGroupEntry>, Error<InsightIncomeAssetError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/insight/income/asset",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
if let Some(ref local_var_str) = accounts_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("accounts[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"accounts[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = x_trace_id {
local_var_req_builder =
local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<InsightIncomeAssetError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// This endpoint gives a summary of the income received by the user, grouped by (any) category.
pub async fn insight_income_category(
configuration: &configuration::Configuration,
start: String,
end: String,
x_trace_id: Option<&str>,
categories_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
accounts_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
) -> Result<Vec<models::InsightGroupEntry>, Error<InsightIncomeCategoryError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/insight/income/category",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
if let Some(ref local_var_str) = categories_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("categories[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"categories[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_str) = accounts_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("accounts[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"accounts[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = x_trace_id {
local_var_req_builder =
local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<InsightIncomeCategoryError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// This endpoint gives a summary of the income received by the user, including only income with no category.
pub async fn insight_income_no_category(
configuration: &configuration::Configuration,
start: String,
end: String,
x_trace_id: Option<&str>,
accounts_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
) -> Result<Vec<models::InsightTotalEntry>, Error<InsightIncomeNoCategoryError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/insight/income/no-category",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
if let Some(ref local_var_str) = accounts_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("accounts[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"accounts[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = x_trace_id {
local_var_req_builder =
local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<InsightIncomeNoCategoryError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// This endpoint gives a summary of the income received by the user, including only income with no tag.
pub async fn insight_income_no_tag(
configuration: &configuration::Configuration,
start: String,
end: String,
x_trace_id: Option<&str>,
accounts_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
) -> Result<Vec<models::InsightTotalEntry>, Error<InsightIncomeNoTagError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/insight/income/no-tag",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
if let Some(ref local_var_str) = accounts_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("accounts[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"accounts[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = x_trace_id {
local_var_req_builder =
local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<InsightIncomeNoTagError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// This endpoint gives a summary of the income received by the user, grouped by revenue account.
pub async fn insight_income_revenue(
configuration: &configuration::Configuration,
start: String,
end: String,
x_trace_id: Option<&str>,
accounts_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
) -> Result<Vec<models::InsightGroupEntry>, Error<InsightIncomeRevenueError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/insight/income/revenue",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
if let Some(ref local_var_str) = accounts_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("accounts[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"accounts[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = x_trace_id {
local_var_req_builder =
local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<InsightIncomeRevenueError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// This endpoint gives a summary of the income received by the user, grouped by (any) tag.
pub async fn insight_income_tag(
configuration: &configuration::Configuration,
start: String,
end: String,
x_trace_id: Option<&str>,
tags_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
accounts_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
) -> Result<Vec<models::InsightGroupEntry>, Error<InsightIncomeTagError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/insight/income/tag",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
if let Some(ref local_var_str) = tags_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("tags[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"tags[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_str) = accounts_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("accounts[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"accounts[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = x_trace_id {
local_var_req_builder =
local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<InsightIncomeTagError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// This endpoint gives a sum of the total income received by the user.
pub async fn insight_income_total(
configuration: &configuration::Configuration,
start: String,
end: String,
x_trace_id: Option<&str>,
accounts_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
) -> Result<Vec<models::InsightTotalEntry>, Error<InsightIncomeTotalError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/insight/income/total",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
if let Some(ref local_var_str) = accounts_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("accounts[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"accounts[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = x_trace_id {
local_var_req_builder =
local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<InsightIncomeTotalError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// This endpoint gives a summary of the transfers made by the user, grouped by (any) category.
pub async fn insight_transfer_category(
configuration: &configuration::Configuration,
start: String,
end: String,
x_trace_id: Option<&str>,
categories_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
accounts_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
) -> Result<Vec<models::InsightGroupEntry>, Error<InsightTransferCategoryError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/insight/transfer/category",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
if let Some(ref local_var_str) = categories_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("categories[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"categories[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_str) = accounts_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("accounts[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"accounts[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = x_trace_id {
local_var_req_builder =
local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<InsightTransferCategoryError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// This endpoint gives a summary of the transfers made by the user, including only transfers with no category.
pub async fn insight_transfer_no_category(
configuration: &configuration::Configuration,
start: String,
end: String,
x_trace_id: Option<&str>,
accounts_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
) -> Result<Vec<models::InsightTotalEntry>, Error<InsightTransferNoCategoryError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/insight/transfer/no-category",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
if let Some(ref local_var_str) = accounts_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("accounts[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"accounts[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = x_trace_id {
local_var_req_builder =
local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<InsightTransferNoCategoryError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// This endpoint gives a summary of the transfers made by the user, including only transfers with no tag.
pub async fn insight_transfer_no_tag(
configuration: &configuration::Configuration,
start: String,
end: String,
x_trace_id: Option<&str>,
accounts_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
) -> Result<Vec<models::InsightTotalEntry>, Error<InsightTransferNoTagError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/insight/transfer/no-tag",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
if let Some(ref local_var_str) = accounts_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("accounts[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"accounts[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = x_trace_id {
local_var_req_builder =
local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<InsightTransferNoTagError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// This endpoint gives a summary of the transfers created by the user, grouped by (any) tag.
pub async fn insight_transfer_tag(
configuration: &configuration::Configuration,
start: String,
end: String,
x_trace_id: Option<&str>,
tags_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
accounts_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
) -> Result<Vec<models::InsightGroupEntry>, Error<InsightTransferTagError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/insight/transfer/tag",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
if let Some(ref local_var_str) = tags_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("tags[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"tags[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_str) = accounts_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("accounts[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"accounts[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = x_trace_id {
local_var_req_builder =
local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<InsightTransferTagError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// This endpoint gives a sum of the total amount transfers made by the user.
pub async fn insight_transfer_total(
configuration: &configuration::Configuration,
start: String,
end: String,
x_trace_id: Option<&str>,
accounts_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
) -> Result<Vec<models::InsightTotalEntry>, Error<InsightTransferTotalError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/insight/transfer/total",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
if let Some(ref local_var_str) = accounts_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("accounts[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"accounts[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = x_trace_id {
local_var_req_builder =
local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<InsightTransferTotalError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
/// This endpoint gives a summary of the transfers made by the user, grouped by asset account or lability.
pub async fn insight_transfers(
configuration: &configuration::Configuration,
start: String,
end: String,
x_trace_id: Option<&str>,
accounts_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
) -> Result<Vec<models::InsightTransferEntry>, Error<InsightTransfersError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/insight/transfer/asset",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
if let Some(ref local_var_str) = accounts_left_square_bracket_right_square_bracket {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("accounts[]".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"accounts[]",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(local_var_param_value) = x_trace_id {
local_var_req_builder =
local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
}
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<InsightTransfersError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}