firefly-iii 0.3.0

Rust API client for firefly-iii
Documentation
/*
 * 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 crate::models::{self, *};
use std::fmt;

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
pub struct AccountProperties {
    #[serde(rename = "created_at", skip_serializing_if = "Option::is_none")]
    pub created_at: Option<String>,
    #[serde(rename = "updated_at", skip_serializing_if = "Option::is_none")]
    pub updated_at: Option<String>,
    #[serde(rename = "active", skip_serializing_if = "Option::is_none")]
    pub active: Option<bool>,
    /// Order of the account. Is NULL if account is not asset or liability.
    #[serde(rename = "order", skip_serializing_if = "Option::is_none")]
    pub order: Option<i32>,
    #[serde(rename = "name")]
    pub name: String,
    #[serde(rename = "type")]
    pub r#type: models::ShortAccountTypeProperty,
    #[serde(rename = "account_role", skip_serializing_if = "Option::is_none")]
    pub account_role: Option<models::AccountRoleProperty>,
    /// The group ID of the group this object is part of. NULL if no group.
    #[serde(rename = "object_group_id", skip_serializing_if = "Option::is_none")]
    pub object_group_id: Option<String>,
    /// The order of the group. At least 1, for the highest sorting.
    #[serde(rename = "object_group_order", skip_serializing_if = "Option::is_none")]
    pub object_group_order: Option<i32>,
    /// The name of the group. NULL if no group.
    #[serde(rename = "object_group_title", skip_serializing_if = "Option::is_none")]
    pub object_group_title: Option<String>,
    /// Indicates whether the account has a currency setting. If false, the account uses the administration's primary currency. Asset accounts and liability accounts always have a currency setting, while expense and revenue accounts do not.
    #[serde(
        rename = "object_has_currency_setting",
        skip_serializing_if = "Option::is_none"
    )]
    pub object_has_currency_setting: Option<bool>,
    /// The currency ID of the currency associated with this object.
    #[serde(rename = "currency_id", skip_serializing_if = "Option::is_none")]
    pub currency_id: Option<String>,
    /// The currency name of the currency associated with this object.
    #[serde(rename = "currency_name", skip_serializing_if = "Option::is_none")]
    pub currency_name: Option<String>,
    /// The currency code of the currency associated with this object.
    #[serde(rename = "currency_code", skip_serializing_if = "Option::is_none")]
    pub currency_code: Option<String>,
    #[serde(rename = "currency_symbol", skip_serializing_if = "Option::is_none")]
    pub currency_symbol: Option<String>,
    #[serde(
        rename = "currency_decimal_places",
        skip_serializing_if = "Option::is_none"
    )]
    pub currency_decimal_places: Option<i32>,
    /// The currency ID of the administration's primary currency.
    #[serde(
        rename = "primary_currency_id",
        skip_serializing_if = "Option::is_none"
    )]
    pub primary_currency_id: Option<String>,
    /// The currency name of the administration's primary currency.
    #[serde(
        rename = "primary_currency_name",
        skip_serializing_if = "Option::is_none"
    )]
    pub primary_currency_name: Option<String>,
    /// The currency code of the administration's primary currency.
    #[serde(
        rename = "primary_currency_code",
        skip_serializing_if = "Option::is_none"
    )]
    pub primary_currency_code: Option<String>,
    /// The currency symbol of the administration's primary currency.
    #[serde(
        rename = "primary_currency_symbol",
        skip_serializing_if = "Option::is_none"
    )]
    pub primary_currency_symbol: Option<String>,
    /// The currency decimal places of the administration's primary currency.
    #[serde(
        rename = "primary_currency_decimal_places",
        skip_serializing_if = "Option::is_none"
    )]
    pub primary_currency_decimal_places: Option<i32>,
    /// The current balance of the account in the account's currency. If the account has no currency, this is the balance in the administration's primary currency. Either way, the `currency_*` fields reflect the currency used.
    #[serde(rename = "current_balance", skip_serializing_if = "Option::is_none")]
    pub current_balance: Option<String>,
    /// The current balance of the account in the administration's primary currency. The `primary_currency_*` fields reflect the currency used. This field is NULL if the user does have 'convert to primary' set to true in their settings.
    #[serde(rename = "pc_current_balance", skip_serializing_if = "Option::is_none")]
    pub pc_current_balance: Option<String>,
    /// If you submit a start AND end date, this will be the difference between those two moments.
    #[serde(rename = "balance_difference", skip_serializing_if = "Option::is_none")]
    pub balance_difference: Option<String>,
    /// If you submit a start AND end date, this will be the difference in the currency of the account or the administration's primary currency between those two moments.
    #[serde(
        rename = "pc_balance_difference",
        skip_serializing_if = "Option::is_none"
    )]
    pub pc_balance_difference: Option<String>,
    /// Represents the opening balance, the initial amount this account holds in the currency of the account or the administration's primary currency if the account has no currency. Either way, the `currency_*` fields reflect the currency used.
    #[serde(rename = "opening_balance", skip_serializing_if = "Option::is_none")]
    pub opening_balance: Option<String>,
    /// The opening balance of the account in the administration's primary currency (pc). The `primary_currency_*` fields reflect the currency used. This field is NULL if the user does have 'convert to primary' set to true in their settings.
    #[serde(rename = "pc_opening_balance", skip_serializing_if = "Option::is_none")]
    pub pc_opening_balance: Option<String>,
    /// The virtual balance of the account in the account's currency or the administration's primary currency if the account has no currency.
    #[serde(rename = "virtual_balance", skip_serializing_if = "Option::is_none")]
    pub virtual_balance: Option<String>,
    /// The virtual balance of the account in the administration's primary currency (pc). The `primary_currency_*` fields reflect the currency used. This field is NULL if the user does have 'convert to primary' set to true in their settings.
    #[serde(rename = "pc_virtual_balance", skip_serializing_if = "Option::is_none")]
    pub pc_virtual_balance: Option<String>,
    /// In liability accounts (loans, debts and mortgages), this is the amount of debt in the account's currency (see the `currency_*` fields). In asset accounts, this is NULL.
    #[serde(rename = "debt_amount", skip_serializing_if = "Option::is_none")]
    pub debt_amount: Option<String>,
    /// In liability accounts (loans, debts and mortgages), this is the amount of debt in the administration's primary currency (see the `currency_*` fields. In asset accounts, this is NULL.
    #[serde(rename = "pc_debt_amount", skip_serializing_if = "Option::is_none")]
    pub pc_debt_amount: Option<String>,
    /// The timestamp for this date is always 23:59:59, to indicate it's the balance at the very END of that particular day.
    #[serde(
        rename = "current_balance_date",
        skip_serializing_if = "Option::is_none"
    )]
    pub current_balance_date: Option<String>,
    #[serde(rename = "notes", skip_serializing_if = "Option::is_none")]
    pub notes: Option<String>,
    /// Mandatory when the account_role is ccAsset. Moment at which CC payment installments are asked for by the bank.
    #[serde(
        rename = "monthly_payment_date",
        skip_serializing_if = "Option::is_none"
    )]
    pub monthly_payment_date: Option<String>,
    #[serde(rename = "credit_card_type", skip_serializing_if = "Option::is_none")]
    pub credit_card_type: Option<models::CreditCardTypeProperty>,
    #[serde(rename = "account_number", skip_serializing_if = "Option::is_none")]
    pub account_number: Option<String>,
    #[serde(rename = "iban", skip_serializing_if = "Option::is_none")]
    pub iban: Option<String>,
    #[serde(rename = "bic", skip_serializing_if = "Option::is_none")]
    pub bic: Option<String>,
    /// Represents the date of the opening balance.
    #[serde(
        rename = "opening_balance_date",
        skip_serializing_if = "Option::is_none"
    )]
    pub opening_balance_date: Option<String>,
    #[serde(rename = "liability_type", skip_serializing_if = "Option::is_none")]
    pub liability_type: Option<models::LiabilityTypeProperty>,
    #[serde(
        rename = "liability_direction",
        skip_serializing_if = "Option::is_none"
    )]
    pub liability_direction: Option<models::LiabilityDirectionProperty>,
    /// Mandatory when type is liability. Interest percentage.
    #[serde(rename = "interest", skip_serializing_if = "Option::is_none")]
    pub interest: Option<String>,
    #[serde(rename = "interest_period", skip_serializing_if = "Option::is_none")]
    pub interest_period: Option<models::InterestPeriodProperty>,
    #[serde(rename = "include_net_worth", skip_serializing_if = "Option::is_none")]
    pub include_net_worth: Option<bool>,
    /// Latitude of the accounts's location, if applicable. Can be used to draw a map.
    #[serde(rename = "longitude", skip_serializing_if = "Option::is_none")]
    pub longitude: Option<f64>,
    /// Latitude of the accounts's location, if applicable. Can be used to draw a map.
    #[serde(rename = "latitude", skip_serializing_if = "Option::is_none")]
    pub latitude: Option<f64>,
    /// Zoom level for the map, if drawn. This to set the box right. Unfortunately this is a proprietary value because each map provider has different zoom levels.
    #[serde(rename = "zoom_level", skip_serializing_if = "Option::is_none")]
    pub zoom_level: Option<i32>,
    /// Last activity of the account.
    #[serde(rename = "last_activity", skip_serializing_if = "Option::is_none")]
    pub last_activity: Option<String>,
}

impl AccountProperties {
    pub fn new(name: String, r#type: models::ShortAccountTypeProperty) -> AccountProperties {
        AccountProperties {
            created_at: None,
            updated_at: None,
            active: None,
            order: None,
            name,
            r#type,
            account_role: None,
            object_group_id: None,
            object_group_order: None,
            object_group_title: None,
            object_has_currency_setting: None,
            currency_id: None,
            currency_name: None,
            currency_code: None,
            currency_symbol: None,
            currency_decimal_places: None,
            primary_currency_id: None,
            primary_currency_name: None,
            primary_currency_code: None,
            primary_currency_symbol: None,
            primary_currency_decimal_places: None,
            current_balance: None,
            pc_current_balance: None,
            balance_difference: None,
            pc_balance_difference: None,
            opening_balance: None,
            pc_opening_balance: None,
            virtual_balance: None,
            pc_virtual_balance: None,
            debt_amount: None,
            pc_debt_amount: None,
            current_balance_date: None,
            notes: None,
            monthly_payment_date: None,
            credit_card_type: None,
            account_number: None,
            iban: None,
            bic: None,
            opening_balance_date: None,
            liability_type: None,
            liability_direction: None,
            interest: None,
            interest_period: None,
            include_net_worth: None,
            longitude: None,
            latitude: None,
            zoom_level: None,
            last_activity: None,
        }
    }
}

impl fmt::Display for AccountProperties {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match serde_json::to_string(self) {
            Ok(json) => write!(f, "{}", json),
            Err(_) => write!(f, "{{{{}}}}"),
        }
    }
}