/*
* 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 [`delete_budget`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteBudgetError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_budget_limit`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteBudgetLimitError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_budget`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBudgetError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_budget_limit`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBudgetLimitError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_attachment_by_budget`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAttachmentByBudgetError {
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 [`list_budget`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListBudgetError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_budget_limit`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListBudgetLimitError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_budget_limit_by_budget`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListBudgetLimitByBudgetError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_transaction_by_budget`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListTransactionByBudgetError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_transaction_by_budget_limit`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListTransactionByBudgetLimitError {
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_transaction_without_budget`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListTransactionWithoutBudgetError {
Status401(models::UnauthenticatedResponse),
Status422(models::ValidationErrorResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`store_budget`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum StoreBudgetError {
Status422(models::ValidationErrorResponse),
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`store_budget_limit`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum StoreBudgetLimitError {
Status422(models::ValidationErrorResponse),
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_budget`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateBudgetError {
Status422(models::ValidationErrorResponse),
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_budget_limit`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateBudgetLimitError {
Status422(models::ValidationErrorResponse),
Status401(models::UnauthenticatedResponse),
Status404(models::NotFoundResponse),
Status400(models::BadRequestResponse),
Status500(models::InternalExceptionResponse),
UnknownValue(serde_json::Value),
}
/// Delete a budget. Transactions will not be deleted.
pub async fn delete_budget(
configuration: &configuration::Configuration,
id: &str,
x_trace_id: Option<&str>,
) -> Result<(), Error<DeleteBudgetError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/budgets/{id}",
local_var_configuration.base_path,
id = crate::apis::urlencode(id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
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() {
Ok(())
} else {
let local_var_entity: Option<DeleteBudgetError> =
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))
}
}
/// Delete a budget limit.
pub async fn delete_budget_limit(
configuration: &configuration::Configuration,
id: &str,
limit_id: &str,
x_trace_id: Option<&str>,
) -> Result<(), Error<DeleteBudgetLimitError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/budgets/{id}/limits/{limitId}",
local_var_configuration.base_path,
id = crate::apis::urlencode(id),
limitId = crate::apis::urlencode(limit_id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
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() {
Ok(())
} else {
let local_var_entity: Option<DeleteBudgetLimitError> =
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))
}
}
/// Get a single budget. If the start date and end date are submitted as well, the \"spent\" array will be updated accordingly.
pub async fn get_budget(
configuration: &configuration::Configuration,
id: &str,
x_trace_id: Option<&str>,
start: Option<String>,
end: Option<String>,
) -> Result<models::BudgetSingle, Error<GetBudgetError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/budgets/{id}",
local_var_configuration.base_path,
id = crate::apis::urlencode(id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = start {
local_var_req_builder =
local_var_req_builder.query(&[("start", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = end {
local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.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<GetBudgetError> =
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))
}
}
pub async fn get_budget_limit(
configuration: &configuration::Configuration,
id: &str,
limit_id: i32,
x_trace_id: Option<&str>,
) -> Result<models::BudgetLimitSingle, Error<GetBudgetLimitError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/budgets/{id}/limits/{limitId}",
local_var_configuration.base_path,
id = crate::apis::urlencode(id),
limitId = limit_id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
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<GetBudgetLimitError> =
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))
}
}
/// Lists all attachments.
pub async fn list_attachment_by_budget(
configuration: &configuration::Configuration,
id: &str,
x_trace_id: Option<&str>,
limit: Option<i32>,
page: Option<i32>,
) -> Result<models::AttachmentArray, Error<ListAttachmentByBudgetError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/budgets/{id}/attachments",
local_var_configuration.base_path,
id = crate::apis::urlencode(id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = limit {
local_var_req_builder =
local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = page {
local_var_req_builder =
local_var_req_builder.query(&[("page", &local_var_str.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<ListAttachmentByBudgetError> =
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))
}
}
/// List all the budgets the user has made. If the start date and end date are submitted as well, the \"spent\" array will be updated accordingly.
pub async fn list_budget(
configuration: &configuration::Configuration,
x_trace_id: Option<&str>,
limit: Option<i32>,
page: Option<i32>,
start: Option<String>,
end: Option<String>,
) -> Result<models::BudgetArray, Error<ListBudgetError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/v1/budgets", local_var_configuration.base_path);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = limit {
local_var_req_builder =
local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = page {
local_var_req_builder =
local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = start {
local_var_req_builder =
local_var_req_builder.query(&[("start", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = end {
local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.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<ListBudgetError> =
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))
}
}
/// Get all budget limits for for this date range.
pub async fn list_budget_limit(
configuration: &configuration::Configuration,
start: String,
end: String,
x_trace_id: Option<&str>,
) -> Result<models::BudgetLimitArray, Error<ListBudgetLimitError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/v1/budget-limits", 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_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<ListBudgetLimitError> =
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))
}
}
/// Get all budget limits for this budget and the money spent, and money left. You can limit the list by submitting a date range as well. The \"spent\" array for each budget limit is NOT influenced by the start and end date of your query, but by the start and end date of the budget limit itself.
pub async fn list_budget_limit_by_budget(
configuration: &configuration::Configuration,
id: &str,
x_trace_id: Option<&str>,
start: Option<String>,
end: Option<String>,
) -> Result<models::BudgetLimitArray, Error<ListBudgetLimitByBudgetError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/budgets/{id}/limits",
local_var_configuration.base_path,
id = crate::apis::urlencode(id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = start {
local_var_req_builder =
local_var_req_builder.query(&[("start", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = end {
local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.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<ListBudgetLimitByBudgetError> =
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))
}
}
/// Get all transactions linked to a budget, possibly limited by start and end
pub async fn list_transaction_by_budget(
configuration: &configuration::Configuration,
id: &str,
x_trace_id: Option<&str>,
limit: Option<i32>,
page: Option<i32>,
start: Option<String>,
end: Option<String>,
r#type: Option<TransactionTypeFilter>,
) -> Result<models::TransactionArray, Error<ListTransactionByBudgetError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/budgets/{id}/transactions",
local_var_configuration.base_path,
id = crate::apis::urlencode(id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = limit {
local_var_req_builder =
local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = page {
local_var_req_builder =
local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = start {
local_var_req_builder =
local_var_req_builder.query(&[("start", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = end {
local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = r#type {
local_var_req_builder =
local_var_req_builder.query(&[("type", &local_var_str.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<ListTransactionByBudgetError> =
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))
}
}
/// List all the transactions within one budget limit. The start and end date are dictated by the budget limit.
pub async fn list_transaction_by_budget_limit(
configuration: &configuration::Configuration,
id: &str,
limit_id: &str,
x_trace_id: Option<&str>,
limit: Option<i32>,
page: Option<i32>,
r#type: Option<TransactionTypeFilter>,
) -> Result<models::TransactionArray, Error<ListTransactionByBudgetLimitError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/budgets/{id}/limits/{limitId}/transactions",
local_var_configuration.base_path,
id = crate::apis::urlencode(id),
limitId = crate::apis::urlencode(limit_id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = limit {
local_var_req_builder =
local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = page {
local_var_req_builder =
local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = r#type {
local_var_req_builder =
local_var_req_builder.query(&[("type", &local_var_str.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<ListTransactionByBudgetLimitError> =
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))
}
}
/// Get all transactions NOT linked to a budget, possibly limited by start and end
pub async fn list_transaction_without_budget(
configuration: &configuration::Configuration,
x_trace_id: Option<&str>,
limit: Option<i32>,
page: Option<i32>,
start: Option<String>,
end: Option<String>,
) -> Result<models::TransactionArray, Error<ListTransactionWithoutBudgetError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/budgets/transactions-without-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());
if let Some(ref local_var_str) = limit {
local_var_req_builder =
local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = page {
local_var_req_builder =
local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = start {
local_var_req_builder =
local_var_req_builder.query(&[("start", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = end {
local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.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<ListTransactionWithoutBudgetError> =
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))
}
}
/// Creates a new budget. The data required can be submitted as a JSON body or as a list of parameters.
pub async fn store_budget(
configuration: &configuration::Configuration,
budget_store: BudgetStore,
x_trace_id: Option<&str>,
) -> Result<models::BudgetSingle, Error<StoreBudgetError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/v1/budgets", local_var_configuration.base_path);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
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());
};
local_var_req_builder = local_var_req_builder.json(&budget_store);
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<StoreBudgetError> =
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))
}
}
/// Store a new budget limit under this budget.
pub async fn store_budget_limit(
configuration: &configuration::Configuration,
id: &str,
budget_limit_store: BudgetLimitStore,
x_trace_id: Option<&str>,
) -> Result<models::BudgetLimitSingle, Error<StoreBudgetLimitError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/budgets/{id}/limits",
local_var_configuration.base_path,
id = crate::apis::urlencode(id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
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());
};
local_var_req_builder = local_var_req_builder.json(&budget_limit_store);
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<StoreBudgetLimitError> =
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))
}
}
/// Update existing budget. This endpoint cannot be used to set budget amount limits.
pub async fn update_budget(
configuration: &configuration::Configuration,
id: &str,
budget_update: BudgetUpdate,
x_trace_id: Option<&str>,
) -> Result<models::BudgetSingle, Error<UpdateBudgetError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/budgets/{id}",
local_var_configuration.base_path,
id = crate::apis::urlencode(id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
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());
};
local_var_req_builder = local_var_req_builder.json(&budget_update);
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<UpdateBudgetError> =
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))
}
}
/// Update existing budget limit.
pub async fn update_budget_limit(
configuration: &configuration::Configuration,
id: &str,
limit_id: &str,
budget_limit_update: BudgetLimitUpdate,
x_trace_id: Option<&str>,
) -> Result<models::BudgetLimitSingle, Error<UpdateBudgetLimitError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}/v1/budgets/{id}/limits/{limitId}",
local_var_configuration.base_path,
id = crate::apis::urlencode(id),
limitId = crate::apis::urlencode(limit_id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
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());
};
local_var_req_builder = local_var_req_builder.json(&budget_limit_update);
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<UpdateBudgetLimitError> =
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))
}
}