aboutsummaryrefslogtreecommitdiffstats
path: root/src/models/category.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/models/category.rs')
-rw-r--r--src/models/category.rs93
1 files changed, 93 insertions, 0 deletions
diff --git a/src/models/category.rs b/src/models/category.rs
new file mode 100644
index 0000000..1a62c6a
--- /dev/null
+++ b/src/models/category.rs
@@ -0,0 +1,93 @@
+/*
+ * YNAB API Endpoints
+ *
+ * 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.youneedabudget.com
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ * Generated by: https://openapi-generator.tech
+ */
+
+
+#[allow(unused_imports)]
+use serde_json::Value;
+
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct Category {
+ #[serde(rename = "id")]
+ pub id: String,
+ #[serde(rename = "category_group_id")]
+ pub category_group_id: String,
+ #[serde(rename = "name")]
+ pub name: String,
+ /// Whether or not the category is hidden
+ #[serde(rename = "hidden")]
+ pub hidden: bool,
+ /// If category is hidden this is the id of the category group it originally belonged to before it was hidden.
+ #[serde(rename = "original_category_group_id", skip_serializing_if = "Option::is_none")]
+ pub original_category_group_id: Option<String>,
+ #[serde(rename = "note", skip_serializing_if = "Option::is_none")]
+ pub note: Option<String>,
+ /// Budgeted amount in milliunits format
+ #[serde(rename = "budgeted")]
+ pub budgeted: i64,
+ /// Activity amount in milliunits format
+ #[serde(rename = "activity")]
+ pub activity: i64,
+ /// Balance in milliunits format
+ #[serde(rename = "balance")]
+ pub balance: i64,
+ /// The type of goal, if the cagegory has a goal (TB=Target Category Balance, TBD=Target Category Balance by Date, MF=Monthly Funding)
+ #[serde(rename = "goal_type", skip_serializing_if = "Option::is_none")]
+ pub goal_type: Option<String>,
+ /// The month a goal was created
+ #[serde(rename = "goal_creation_month", skip_serializing_if = "Option::is_none")]
+ pub goal_creation_month: Option<String>,
+ /// The goal target amount in milliunits
+ #[serde(rename = "goal_target")]
+ pub goal_target: i64,
+ /// If the goal type is 'TBD' (Target Category Balance by Date), this is the target month for the goal to be completed
+ #[serde(rename = "goal_target_month", skip_serializing_if = "Option::is_none")]
+ pub goal_target_month: Option<String>,
+ /// The percentage completion of the goal
+ #[serde(rename = "goal_percentage_complete", skip_serializing_if = "Option::is_none")]
+ pub goal_percentage_complete: Option<i32>,
+ /// Whether or not the category has been deleted. Deleted categories will only be included in delta requests.
+ #[serde(rename = "deleted")]
+ pub deleted: bool,
+}
+
+impl Category {
+ pub fn new(id: String, category_group_id: String, name: String, hidden: bool, budgeted: i64, activity: i64, balance: i64, goal_target: i64, deleted: bool) -> Category {
+ Category {
+ id: id,
+ category_group_id: category_group_id,
+ name: name,
+ hidden: hidden,
+ original_category_group_id: None,
+ note: None,
+ budgeted: budgeted,
+ activity: activity,
+ balance: balance,
+ goal_type: None,
+ goal_creation_month: None,
+ goal_target: goal_target,
+ goal_target_month: None,
+ goal_percentage_complete: None,
+ deleted: deleted,
+ }
+ }
+}
+
+/// The type of goal, if the cagegory has a goal (TB=Target Category Balance, TBD=Target Category Balance by Date, MF=Monthly Funding)
+#[derive(Debug, Serialize, Deserialize)]
+pub enum GoalType {
+ #[serde(rename = "TB")]
+ TB,
+ #[serde(rename = "TBD")]
+ TBD,
+ #[serde(rename = "MF")]
+ MF,
+}
+