ynab_api_async_fork/models/
category.rs

1/*
2 * YNAB API Endpoints
3 *
4 * Our API uses a REST based design, leverages the JSON data format, and relies upon HTTPS for transport. We respond with meaningful HTTP response codes and if an error occurs, we include error details in the response body.  API Documentation is at https://api.ynab.com
5 *
6 * The version of the OpenAPI document: 1.72.1
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12
13
14#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
15pub struct Category {
16    #[serde(rename = "id")]
17    pub id: String,
18    #[serde(rename = "category_group_id")]
19    pub category_group_id: String,
20    #[serde(rename = "category_group_name", skip_serializing_if = "Option::is_none")]
21    pub category_group_name: Option<String>,
22    #[serde(rename = "name")]
23    pub name: String,
24    /// Whether or not the category is hidden
25    #[serde(rename = "hidden")]
26    pub hidden: bool,
27    /// DEPRECATED: No longer used.  Value will always be null.
28    #[serde(rename = "original_category_group_id", skip_serializing_if = "Option::is_none")]
29    pub original_category_group_id: Option<String>,
30    #[serde(rename = "note", skip_serializing_if = "Option::is_none")]
31    pub note: Option<String>,
32    /// Budgeted amount in milliunits format
33    #[serde(rename = "budgeted")]
34    pub budgeted: i64,
35    /// Activity amount in milliunits format
36    #[serde(rename = "activity")]
37    pub activity: i64,
38    /// Balance in milliunits format
39    #[serde(rename = "balance")]
40    pub balance: i64,
41    /// The type of goal, if the category has a goal (TB='Target Category Balance', TBD='Target Category Balance by Date', MF='Monthly Funding', NEED='Plan Your Spending')
42    #[serde(rename = "goal_type", skip_serializing_if = "Option::is_none")]
43    pub goal_type: Option<GoalType>,
44    /// Indicates the monthly rollover behavior for \"NEED\"-type goals. When \"true\", the goal will always ask for the target amount in the new month (\"Set Aside\"). When \"false\", previous month category funding is used (\"Refill\"). For other goal types, this field will be null.
45    #[serde(rename = "goal_needs_whole_amount", skip_serializing_if = "Option::is_none")]
46    pub goal_needs_whole_amount: Option<bool>,
47    /// A day offset modifier for the goal's due date. When goal_cadence is 2 (Weekly), this value specifies which day of the week the goal is due (0 = Sunday, 6 = Saturday). Otherwise, this value specifies which day of the month the goal is due (1 = 1st, 31 = 31st, null = Last day of Month).
48    #[serde(rename = "goal_day", skip_serializing_if = "Option::is_none")]
49    pub goal_day: Option<i32>,
50    /// The goal cadence. Value in range 0-14. There are two subsets of these values which behave differently. For values 0, 1, 2, and 13, the goal's due date repeats every goal_cadence * goal_cadence_frequency, where 0 = None, 1 = Monthly, 2 = Weekly, and 13 = Yearly. For example, goal_cadence 1 with goal_cadence_frequency 2 means the goal is due every other month. For values 3-12 and 14, goal_cadence_frequency is ignored and the goal's due date repeats every goal_cadence, where 3 = Every 2 Months, 4 = Every 3 Months, ..., 12 = Every 11 Months, and 14 = Every 2 Years.
51    #[serde(rename = "goal_cadence", skip_serializing_if = "Option::is_none")]
52    pub goal_cadence: Option<i32>,
53    /// The goal cadence frequency. When goal_cadence is 0, 1, 2, or 13, a goal's due date repeats every goal_cadence * goal_cadence_frequency. For example, goal_cadence 1 with goal_cadence_frequency 2 means the goal is due every other month.  When goal_cadence is 3-12 or 14, goal_cadence_frequency is ignored.
54    #[serde(rename = "goal_cadence_frequency", skip_serializing_if = "Option::is_none")]
55    pub goal_cadence_frequency: Option<i32>,
56    /// The month a goal was created
57    #[serde(rename = "goal_creation_month", skip_serializing_if = "Option::is_none")]
58    pub goal_creation_month: Option<String>,
59    /// The goal target amount in milliunits
60    #[serde(rename = "goal_target", skip_serializing_if = "Option::is_none")]
61    pub goal_target: Option<i64>,
62    /// The original target month for the goal to be completed.  Only some goal types specify this date.
63    #[serde(rename = "goal_target_month", skip_serializing_if = "Option::is_none")]
64    pub goal_target_month: Option<String>,
65    /// The percentage completion of the goal
66    #[serde(rename = "goal_percentage_complete", skip_serializing_if = "Option::is_none")]
67    pub goal_percentage_complete: Option<i32>,
68    /// The number of months, including the current month, left in the current goal period.
69    #[serde(rename = "goal_months_to_budget", skip_serializing_if = "Option::is_none")]
70    pub goal_months_to_budget: Option<i32>,
71    /// The amount of funding still needed in the current month to stay on track towards completing the goal within the current goal period. This amount will generally correspond to the 'Underfunded' amount in the web and mobile clients except when viewing a category with a Needed for Spending Goal in a future month.  The web and mobile clients will ignore any funding from a prior goal period when viewing category with a Needed for Spending Goal in a future month.
72    #[serde(rename = "goal_under_funded", skip_serializing_if = "Option::is_none")]
73    pub goal_under_funded: Option<i64>,
74    /// The total amount funded towards the goal within the current goal period.
75    #[serde(rename = "goal_overall_funded", skip_serializing_if = "Option::is_none")]
76    pub goal_overall_funded: Option<i64>,
77    /// The amount of funding still needed to complete the goal within the current goal period.
78    #[serde(rename = "goal_overall_left", skip_serializing_if = "Option::is_none")]
79    pub goal_overall_left: Option<i64>,
80    /// Whether or not the category has been deleted.  Deleted categories will only be included in delta requests.
81    #[serde(rename = "deleted")]
82    pub deleted: bool,
83}
84
85impl Category {
86    pub fn new(id: String, category_group_id: String, name: String, hidden: bool, budgeted: i64, activity: i64, balance: i64, deleted: bool) -> Category {
87        Category {
88            id,
89            category_group_id,
90            category_group_name: None,
91            name,
92            hidden,
93            original_category_group_id: None,
94            note: None,
95            budgeted,
96            activity,
97            balance,
98            goal_type: None,
99            goal_needs_whole_amount: None,
100            goal_day: None,
101            goal_cadence: None,
102            goal_cadence_frequency: None,
103            goal_creation_month: None,
104            goal_target: None,
105            goal_target_month: None,
106            goal_percentage_complete: None,
107            goal_months_to_budget: None,
108            goal_under_funded: None,
109            goal_overall_funded: None,
110            goal_overall_left: None,
111            deleted,
112        }
113    }
114}
115
116/// The type of goal, if the category has a goal (TB='Target Category Balance', TBD='Target Category Balance by Date', MF='Monthly Funding', NEED='Plan Your Spending')
117#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
118pub enum GoalType {
119    #[serde(rename = "TB")]
120    TB,
121    #[serde(rename = "TBD")]
122    TBD,
123    #[serde(rename = "MF")]
124    MF,
125    #[serde(rename = "NEED")]
126    NEED,
127    #[serde(rename = "DEBT")]
128    DEBT,
129    #[serde(rename = "null")]
130    Null,
131}
132