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 RecurrenceStore {
    #[serde(rename = "type")]
    pub r#type: models::RecurrenceTransactionType,
    #[serde(rename = "title")]
    pub title: String,
    /// Not to be confused with the description of the actual transaction(s) being created.
    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    /// First time the recurring transaction will fire. Must be after today.
    #[serde(rename = "first_date")]
    pub first_date: String,
    /// Date until the recurring transaction can fire. Use either this field or repetitions.
    #[serde(rename = "repeat_until")]
    pub repeat_until: Option<String>,
    /// Max number of created transactions. Use either this field or repeat_until.
    #[serde(rename = "nr_of_repetitions", skip_serializing_if = "Option::is_none")]
    pub nr_of_repetitions: Option<i32>,
    /// Whether or not to fire the rules after the creation of a transaction.
    #[serde(rename = "apply_rules", skip_serializing_if = "Option::is_none")]
    pub apply_rules: Option<bool>,
    /// If the recurrence is even active.
    #[serde(rename = "active", skip_serializing_if = "Option::is_none")]
    pub active: Option<bool>,
    #[serde(rename = "notes", skip_serializing_if = "Option::is_none")]
    pub notes: Option<String>,
    #[serde(rename = "repetitions")]
    pub repetitions: Vec<models::RecurrenceRepetitionStore>,
    #[serde(rename = "transactions")]
    pub transactions: Vec<models::RecurrenceTransactionStore>,
}

impl RecurrenceStore {
    pub fn new(
        r#type: models::RecurrenceTransactionType,
        title: String,
        first_date: String,
        repeat_until: Option<String>,
        repetitions: Vec<models::RecurrenceRepetitionStore>,
        transactions: Vec<models::RecurrenceTransactionStore>,
    ) -> RecurrenceStore {
        RecurrenceStore {
            r#type,
            title,
            description: None,
            first_date,
            repeat_until,
            nr_of_repetitions: None,
            apply_rules: None,
            active: None,
            notes: None,
            repetitions,
            transactions,
        }
    }
}

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