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 RecurrenceTransaction {
    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,
    #[serde(rename = "description")]
    pub description: String,
    /// Indicates whether the object has a currency setting. If false, the object uses the administration's primary currency.
    #[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>,
    /// Amount of the transaction.
    #[serde(rename = "amount")]
    pub amount: String,
    /// Amount of the transaction in primary currency.
    #[serde(rename = "pc_amount", skip_serializing_if = "Option::is_none")]
    pub pc_amount: Option<String>,
    /// Foreign amount of the transaction.
    #[serde(rename = "foreign_amount", skip_serializing_if = "Option::is_none")]
    pub foreign_amount: Option<String>,
    /// Foreign amount of the transaction.
    #[serde(rename = "pc_foreign_amount", skip_serializing_if = "Option::is_none")]
    pub pc_foreign_amount: Option<String>,
    #[serde(
        rename = "foreign_currency_id",
        skip_serializing_if = "Option::is_none"
    )]
    pub foreign_currency_id: Option<String>,
    #[serde(
        rename = "foreign_currency_name",
        skip_serializing_if = "Option::is_none"
    )]
    pub foreign_currency_name: Option<String>,
    #[serde(
        rename = "foreign_currency_code",
        skip_serializing_if = "Option::is_none"
    )]
    pub foreign_currency_code: Option<String>,
    #[serde(
        rename = "foreign_currency_symbol",
        skip_serializing_if = "Option::is_none"
    )]
    pub foreign_currency_symbol: Option<String>,
    /// Number of decimals in the currency
    #[serde(
        rename = "foreign_currency_decimal_places",
        skip_serializing_if = "Option::is_none"
    )]
    pub foreign_currency_decimal_places: Option<i32>,
    /// The budget ID for this transaction.
    #[serde(rename = "budget_id", skip_serializing_if = "Option::is_none")]
    pub budget_id: Option<String>,
    /// The name of the budget to be used. If the budget name is unknown, the ID will be used or the value will be ignored.
    #[serde(rename = "budget_name", skip_serializing_if = "Option::is_none")]
    pub budget_name: Option<String>,
    /// Category ID for this transaction.
    #[serde(rename = "category_id", skip_serializing_if = "Option::is_none")]
    pub category_id: Option<String>,
    /// Category name for this transaction.
    #[serde(rename = "category_name", skip_serializing_if = "Option::is_none")]
    pub category_name: Option<String>,
    /// ID of the source account. Submit either this or source_name.
    #[serde(rename = "source_id", skip_serializing_if = "Option::is_none")]
    pub source_id: Option<String>,
    /// Name of the source account. Submit either this or source_id.
    #[serde(rename = "source_name", skip_serializing_if = "Option::is_none")]
    pub source_name: Option<String>,
    #[serde(rename = "source_iban", skip_serializing_if = "Option::is_none")]
    pub source_iban: Option<String>,
    #[serde(rename = "source_type", skip_serializing_if = "Option::is_none")]
    pub source_type: Option<models::AccountTypeProperty>,
    /// ID of the destination account. Submit either this or destination_name.
    #[serde(rename = "destination_id", skip_serializing_if = "Option::is_none")]
    pub destination_id: Option<String>,
    /// Name of the destination account. Submit either this or destination_id.
    #[serde(rename = "destination_name", skip_serializing_if = "Option::is_none")]
    pub destination_name: Option<String>,
    #[serde(rename = "destination_iban", skip_serializing_if = "Option::is_none")]
    pub destination_iban: Option<String>,
    #[serde(rename = "destination_type", skip_serializing_if = "Option::is_none")]
    pub destination_type: Option<models::AccountTypeProperty>,
    /// Array of tags.
    #[serde(rename = "tags", skip_serializing_if = "Option::is_none")]
    pub tags: Option<Vec<String>>,
    #[serde(rename = "piggy_bank_id", skip_serializing_if = "Option::is_none")]
    pub piggy_bank_id: Option<String>,
    #[serde(rename = "piggy_bank_name", skip_serializing_if = "Option::is_none")]
    pub piggy_bank_name: Option<String>,
    #[serde(rename = "subscription_id", skip_serializing_if = "Option::is_none")]
    pub subscription_id: Option<String>,
    #[serde(rename = "subscription_name", skip_serializing_if = "Option::is_none")]
    pub subscription_name: Option<String>,
}

impl RecurrenceTransaction {
    pub fn new(description: String, amount: String) -> RecurrenceTransaction {
        RecurrenceTransaction {
            id: None,
            description,
            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,
            amount,
            pc_amount: None,
            foreign_amount: None,
            pc_foreign_amount: None,
            foreign_currency_id: None,
            foreign_currency_name: None,
            foreign_currency_code: None,
            foreign_currency_symbol: None,
            foreign_currency_decimal_places: None,
            budget_id: None,
            budget_name: None,
            category_id: None,
            category_name: None,
            source_id: None,
            source_name: None,
            source_iban: None,
            source_type: None,
            destination_id: None,
            destination_name: None,
            destination_iban: None,
            destination_type: None,
            tags: None,
            piggy_bank_id: None,
            piggy_bank_name: None,
            subscription_id: None,
            subscription_name: None,
        }
    }
}

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