Skip to main content

firefly_iii/apis/
summary_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_basic_summary`]
20#[derive(Debug, Clone, Serialize, Deserialize)]
21#[serde(untagged)]
22pub enum GetBasicSummaryError {
23    Status401(models::UnauthenticatedResponse),
24    Status404(models::NotFoundResponse),
25    Status400(models::BadRequestResponse),
26    Status500(models::InternalExceptionResponse),
27    UnknownValue(serde_json::Value),
28}
29
30/// Returns basic sums of the users data, like the net worth, spent and earned amounts. It is multi-currency, and is used in Firefly III to populate the dashboard.
31pub async fn get_basic_summary(
32    configuration: &configuration::Configuration,
33    start: String,
34    end: String,
35    x_trace_id: Option<&str>,
36    currency_code: Option<&str>,
37) -> Result<std::collections::HashMap<String, models::BasicSummaryEntry>, Error<GetBasicSummaryError>>
38{
39    let local_var_configuration = configuration;
40
41    let local_var_client = &local_var_configuration.client;
42
43    let local_var_uri_str = format!("{}/v1/summary/basic", local_var_configuration.base_path);
44    let mut local_var_req_builder =
45        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
46
47    local_var_req_builder = local_var_req_builder.query(&[("start", &start.to_string())]);
48    local_var_req_builder = local_var_req_builder.query(&[("end", &end.to_string())]);
49    if let Some(ref local_var_str) = currency_code {
50        local_var_req_builder =
51            local_var_req_builder.query(&[("currency_code", &local_var_str.to_string())]);
52    }
53    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
54        local_var_req_builder =
55            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
56    }
57    if let Some(local_var_param_value) = x_trace_id {
58        local_var_req_builder =
59            local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
60    }
61    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
62        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
63    };
64    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
65        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
66    };
67
68    let local_var_req = local_var_req_builder.build()?;
69    let local_var_resp = local_var_client.execute(local_var_req).await?;
70
71    let local_var_status = local_var_resp.status();
72    let local_var_content = local_var_resp.text().await?;
73
74    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
75        serde_json::from_str(&local_var_content).map_err(Error::from)
76    } else {
77        let local_var_entity: Option<GetBasicSummaryError> =
78            serde_json::from_str(&local_var_content).ok();
79        let local_var_error = ResponseContent {
80            status: local_var_status,
81            content: local_var_content,
82            entity: local_var_entity,
83        };
84        Err(Error::ResponseError(local_var_error))
85    }
86}