Skip to main content

firefly_iii/apis/
charts_api.rs

1/*
2 * Firefly III API v6.4.14
3 *
4 * 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>
5 *
6 * The version of the OpenAPI document: v6.4.14
7 * Contact: james@firefly-iii.org
8 * Generated by: https://openapi-generator.tech
9 */
10
11#![allow(unused_imports)]
12
13use reqwest;
14
15use super::{configuration, Error};
16use crate::apis::ResponseContent;
17use crate::models::{self, *};
18
19/// struct for typed errors of method [`get_chart_account_overview`]
20#[derive(Debug, Clone, Serialize, Deserialize)]
21#[serde(untagged)]
22pub enum GetChartAccountOverviewError {
23    Status401(models::UnauthenticatedResponse),
24    Status404(models::NotFoundResponse),
25    Status400(models::BadRequestResponse),
26    Status422(models::ValidationErrorResponse),
27    Status500(models::InternalExceptionResponse),
28    UnknownValue(serde_json::Value),
29}
30
31/// struct for typed errors of method [`get_chart_balance`]
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum GetChartBalanceError {
35    Status401(models::UnauthenticatedResponse),
36    Status404(models::NotFoundResponse),
37    Status400(models::BadRequestResponse),
38    Status422(models::ValidationErrorResponse),
39    Status500(models::InternalExceptionResponse),
40    UnknownValue(serde_json::Value),
41}
42
43/// struct for typed errors of method [`get_chart_budget_overview`]
44#[derive(Debug, Clone, Serialize, Deserialize)]
45#[serde(untagged)]
46pub enum GetChartBudgetOverviewError {
47    Status401(models::UnauthenticatedResponse),
48    Status404(models::NotFoundResponse),
49    Status400(models::BadRequestResponse),
50    Status422(models::ValidationErrorResponse),
51    Status500(models::InternalExceptionResponse),
52    UnknownValue(serde_json::Value),
53}
54
55/// struct for typed errors of method [`get_chart_category_overview`]
56#[derive(Debug, Clone, Serialize, Deserialize)]
57#[serde(untagged)]
58pub enum GetChartCategoryOverviewError {
59    Status401(models::UnauthenticatedResponse),
60    Status404(models::NotFoundResponse),
61    Status400(models::BadRequestResponse),
62    Status422(models::ValidationErrorResponse),
63    Status500(models::InternalExceptionResponse),
64    UnknownValue(serde_json::Value),
65}
66
67/// This endpoint returns the data required to generate a chart with basic asset account balance information. This is used on the dashboard.
68pub async fn get_chart_account_overview(
69    configuration: &configuration::Configuration,
70    start: String,
71    end: String,
72    x_trace_id: Option<&str>,
73    period: Option<&str>,
74    preselected: Option<&str>,
75) -> Result<Vec<models::ChartDataSet>, Error<GetChartAccountOverviewError>> {
76    let local_var_configuration = configuration;
77
78    let local_var_client = &local_var_configuration.client;
79
80    let local_var_uri_str = format!(
81        "{}/v1/chart/account/overview",
82        local_var_configuration.base_path
83    );
84    let mut local_var_req_builder =
85        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
86
87    local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
88    local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
89    if let Some(ref local_var_str) = period {
90        local_var_req_builder =
91            local_var_req_builder.query(&[("period", &local_var_str.to_string())]);
92    }
93    if let Some(ref local_var_str) = preselected {
94        local_var_req_builder =
95            local_var_req_builder.query(&[("preselected", &local_var_str.to_string())]);
96    }
97    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
98        local_var_req_builder =
99            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
100    }
101    if let Some(local_var_param_value) = x_trace_id {
102        local_var_req_builder =
103            local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
104    }
105    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
106        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
107    };
108    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
109        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
110    };
111
112    let local_var_req = local_var_req_builder.build()?;
113    let local_var_resp = local_var_client.execute(local_var_req).await?;
114
115    let local_var_status = local_var_resp.status();
116    let local_var_content = local_var_resp.text().await?;
117
118    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
119        serde_json::from_str(&local_var_content).map_err(Error::from)
120    } else {
121        let local_var_entity: Option<GetChartAccountOverviewError> =
122            serde_json::from_str(&local_var_content).ok();
123        let local_var_error = ResponseContent {
124            status: local_var_status,
125            content: local_var_content,
126            entity: local_var_entity,
127        };
128        Err(Error::ResponseError(local_var_error))
129    }
130}
131
132/// This endpoint returns the data required to generate a chart with balance information.
133pub async fn get_chart_balance(
134    configuration: &configuration::Configuration,
135    start: String,
136    end: String,
137    x_trace_id: Option<&str>,
138    period: Option<&str>,
139    preselected: Option<&str>,
140    accounts_left_square_bracket_right_square_bracket: Option<Vec<i64>>,
141) -> Result<Vec<models::ChartDataSet>, Error<GetChartBalanceError>> {
142    let local_var_configuration = configuration;
143
144    let local_var_client = &local_var_configuration.client;
145
146    let local_var_uri_str = format!(
147        "{}/v1/chart/balance/balance",
148        local_var_configuration.base_path
149    );
150    let mut local_var_req_builder =
151        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
152
153    local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
154    local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
155    if let Some(ref local_var_str) = period {
156        local_var_req_builder =
157            local_var_req_builder.query(&[("period", &local_var_str.to_string())]);
158    }
159    if let Some(ref local_var_str) = preselected {
160        local_var_req_builder =
161            local_var_req_builder.query(&[("preselected", &local_var_str.to_string())]);
162    }
163    if let Some(ref local_var_str) = accounts_left_square_bracket_right_square_bracket {
164        local_var_req_builder = match "multi" {
165            "multi" => local_var_req_builder.query(
166                &local_var_str
167                    .into_iter()
168                    .map(|p| ("accounts[]".to_owned(), p.to_string()))
169                    .collect::<Vec<(std::string::String, std::string::String)>>(),
170            ),
171            _ => local_var_req_builder.query(&[(
172                "accounts[]",
173                &local_var_str
174                    .into_iter()
175                    .map(|p| p.to_string())
176                    .collect::<Vec<String>>()
177                    .join(",")
178                    .to_string(),
179            )]),
180        };
181    }
182    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
183        local_var_req_builder =
184            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
185    }
186    if let Some(local_var_param_value) = x_trace_id {
187        local_var_req_builder =
188            local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
189    }
190    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
191        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
192    };
193    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
194        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
195    };
196
197    let local_var_req = local_var_req_builder.build()?;
198    let local_var_resp = local_var_client.execute(local_var_req).await?;
199
200    let local_var_status = local_var_resp.status();
201    let local_var_content = local_var_resp.text().await?;
202
203    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
204        serde_json::from_str(&local_var_content).map_err(Error::from)
205    } else {
206        let local_var_entity: Option<GetChartBalanceError> =
207            serde_json::from_str(&local_var_content).ok();
208        let local_var_error = ResponseContent {
209            status: local_var_status,
210            content: local_var_content,
211            entity: local_var_entity,
212        };
213        Err(Error::ResponseError(local_var_error))
214    }
215}
216
217/// This endpoint returns the data required to generate a chart with basic budget information.
218pub async fn get_chart_budget_overview(
219    configuration: &configuration::Configuration,
220    start: String,
221    end: String,
222    x_trace_id: Option<&str>,
223) -> Result<Vec<models::ChartDataSet>, Error<GetChartBudgetOverviewError>> {
224    let local_var_configuration = configuration;
225
226    let local_var_client = &local_var_configuration.client;
227
228    let local_var_uri_str = format!(
229        "{}/v1/chart/budget/overview",
230        local_var_configuration.base_path
231    );
232    let mut local_var_req_builder =
233        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
234
235    local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
236    local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
237    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
238        local_var_req_builder =
239            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
240    }
241    if let Some(local_var_param_value) = x_trace_id {
242        local_var_req_builder =
243            local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
244    }
245    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
246        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
247    };
248    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
249        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
250    };
251
252    let local_var_req = local_var_req_builder.build()?;
253    let local_var_resp = local_var_client.execute(local_var_req).await?;
254
255    let local_var_status = local_var_resp.status();
256    let local_var_content = local_var_resp.text().await?;
257
258    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
259        serde_json::from_str(&local_var_content).map_err(Error::from)
260    } else {
261        let local_var_entity: Option<GetChartBudgetOverviewError> =
262            serde_json::from_str(&local_var_content).ok();
263        let local_var_error = ResponseContent {
264            status: local_var_status,
265            content: local_var_content,
266            entity: local_var_entity,
267        };
268        Err(Error::ResponseError(local_var_error))
269    }
270}
271
272/// This endpoint returns the data required to generate a chart with basic category information.
273pub async fn get_chart_category_overview(
274    configuration: &configuration::Configuration,
275    start: String,
276    end: String,
277    x_trace_id: Option<&str>,
278) -> Result<Vec<models::ChartDataSet>, Error<GetChartCategoryOverviewError>> {
279    let local_var_configuration = configuration;
280
281    let local_var_client = &local_var_configuration.client;
282
283    let local_var_uri_str = format!(
284        "{}/v1/chart/category/overview",
285        local_var_configuration.base_path
286    );
287    let mut local_var_req_builder =
288        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
289
290    local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
291    local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
292    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
293        local_var_req_builder =
294            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
295    }
296    if let Some(local_var_param_value) = x_trace_id {
297        local_var_req_builder =
298            local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
299    }
300    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
301        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
302    };
303    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
304        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
305    };
306
307    let local_var_req = local_var_req_builder.build()?;
308    let local_var_resp = local_var_client.execute(local_var_req).await?;
309
310    let local_var_status = local_var_resp.status();
311    let local_var_content = local_var_resp.text().await?;
312
313    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
314        serde_json::from_str(&local_var_content).map_err(Error::from)
315    } else {
316        let local_var_entity: Option<GetChartCategoryOverviewError> =
317            serde_json::from_str(&local_var_content).ok();
318        let local_var_error = ResponseContent {
319            status: local_var_status,
320            content: local_var_content,
321            entity: local_var_entity,
322        };
323        Err(Error::ResponseError(local_var_error))
324    }
325}