Skip to main content

firefly_iii/apis/
about_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_about`]
20#[derive(Debug, Clone, Serialize, Deserialize)]
21#[serde(untagged)]
22pub enum GetAboutError {
23    Status401(models::UnauthenticatedResponse),
24    Status404(models::NotFoundResponse),
25    Status400(models::BadRequestResponse),
26    Status500(models::InternalExceptionResponse),
27    UnknownValue(serde_json::Value),
28}
29
30/// struct for typed errors of method [`get_cron`]
31#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum GetCronError {
34    Status401(models::UnauthenticatedResponse),
35    Status404(models::NotFoundResponse),
36    Status422(models::ValidationErrorResponse),
37    Status400(models::BadRequestResponse),
38    Status500(models::InternalExceptionResponse),
39    UnknownValue(serde_json::Value),
40}
41
42/// struct for typed errors of method [`get_current_user`]
43#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum GetCurrentUserError {
46    Status401(models::UnauthenticatedResponse),
47    Status404(models::NotFoundResponse),
48    Status400(models::BadRequestResponse),
49    Status500(models::InternalExceptionResponse),
50    UnknownValue(serde_json::Value),
51}
52
53/// Returns general system information and versions of the (supporting) software.
54pub async fn get_about(
55    configuration: &configuration::Configuration,
56    x_trace_id: Option<&str>,
57) -> Result<models::SystemInfo, Error<GetAboutError>> {
58    let local_var_configuration = configuration;
59
60    let local_var_client = &local_var_configuration.client;
61
62    let local_var_uri_str = format!("{}/v1/about", local_var_configuration.base_path);
63    let mut local_var_req_builder =
64        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
65
66    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
67        local_var_req_builder =
68            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
69    }
70    if let Some(local_var_param_value) = x_trace_id {
71        local_var_req_builder =
72            local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
73    }
74    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
75        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
76    };
77    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
78        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
79    };
80
81    let local_var_req = local_var_req_builder.build()?;
82    let local_var_resp = local_var_client.execute(local_var_req).await?;
83
84    let local_var_status = local_var_resp.status();
85    let local_var_content = local_var_resp.text().await?;
86
87    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
88        serde_json::from_str(&local_var_content).map_err(Error::from)
89    } else {
90        let local_var_entity: Option<GetAboutError> = serde_json::from_str(&local_var_content).ok();
91        let local_var_error = ResponseContent {
92            status: local_var_status,
93            content: local_var_content,
94            entity: local_var_entity,
95        };
96        Err(Error::ResponseError(local_var_error))
97    }
98}
99
100/// Firefly III has one endpoint for its various cron related tasks. Send a GET to this endpoint to run the cron. The cron requires the CLI token to be present. The cron job will fire for all users.
101pub async fn get_cron(
102    configuration: &configuration::Configuration,
103    cli_token: &str,
104    x_trace_id: Option<&str>,
105    date: Option<String>,
106    force: Option<bool>,
107) -> Result<models::CronResult, Error<GetCronError>> {
108    let local_var_configuration = configuration;
109
110    let local_var_client = &local_var_configuration.client;
111
112    let local_var_uri_str = format!(
113        "{}/v1/cron/{cliToken}",
114        local_var_configuration.base_path,
115        cliToken = crate::apis::urlencode(cli_token)
116    );
117    let mut local_var_req_builder =
118        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
119
120    if let Some(ref local_var_str) = date {
121        local_var_req_builder =
122            local_var_req_builder.query(&[("date", &local_var_str.to_string())]);
123    }
124    if let Some(ref local_var_str) = force {
125        local_var_req_builder =
126            local_var_req_builder.query(&[("force", &local_var_str.to_string())]);
127    }
128    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
129        local_var_req_builder =
130            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
131    }
132    if let Some(local_var_param_value) = x_trace_id {
133        local_var_req_builder =
134            local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
135    }
136    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
137        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
138    };
139    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
140        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
141    };
142
143    let local_var_req = local_var_req_builder.build()?;
144    let local_var_resp = local_var_client.execute(local_var_req).await?;
145
146    let local_var_status = local_var_resp.status();
147    let local_var_content = local_var_resp.text().await?;
148
149    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
150        serde_json::from_str(&local_var_content).map_err(Error::from)
151    } else {
152        let local_var_entity: Option<GetCronError> = serde_json::from_str(&local_var_content).ok();
153        let local_var_error = ResponseContent {
154            status: local_var_status,
155            content: local_var_content,
156            entity: local_var_entity,
157        };
158        Err(Error::ResponseError(local_var_error))
159    }
160}
161
162/// Returns the currently authenticated user.
163pub async fn get_current_user(
164    configuration: &configuration::Configuration,
165    x_trace_id: Option<&str>,
166) -> Result<models::UserSingle, Error<GetCurrentUserError>> {
167    let local_var_configuration = configuration;
168
169    let local_var_client = &local_var_configuration.client;
170
171    let local_var_uri_str = format!("{}/v1/about/user", local_var_configuration.base_path);
172    let mut local_var_req_builder =
173        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
174
175    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
176        local_var_req_builder =
177            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
178    }
179    if let Some(local_var_param_value) = x_trace_id {
180        local_var_req_builder =
181            local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
182    }
183    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
184        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
185    };
186    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
187        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
188    };
189
190    let local_var_req = local_var_req_builder.build()?;
191    let local_var_resp = local_var_client.execute(local_var_req).await?;
192
193    let local_var_status = local_var_resp.status();
194    let local_var_content = local_var_resp.text().await?;
195
196    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
197        serde_json::from_str(&local_var_content).map_err(Error::from)
198    } else {
199        let local_var_entity: Option<GetCurrentUserError> =
200            serde_json::from_str(&local_var_content).ok();
201        let local_var_error = ResponseContent {
202            status: local_var_status,
203            content: local_var_content,
204            entity: local_var_entity,
205        };
206        Err(Error::ResponseError(local_var_error))
207    }
208}