aboutsummaryrefslogtreecommitdiffstats
path: root/src/models/transaction_summary.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/models/transaction_summary.rs')
-rw-r--r--src/models/transaction_summary.rs47
1 files changed, 37 insertions, 10 deletions
diff --git a/src/models/transaction_summary.rs b/src/models/transaction_summary.rs
index 9bf4cbd..715b233 100644
--- a/src/models/transaction_summary.rs
+++ b/src/models/transaction_summary.rs
@@ -10,6 +10,7 @@
+
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub struct TransactionSummary {
#[serde(rename = "id")]
@@ -24,13 +25,13 @@ pub struct TransactionSummary {
pub memo: Option<String>,
/// The cleared status of the transaction
#[serde(rename = "cleared")]
- pub cleared: String,
+ pub cleared: Cleared,
/// Whether or not the transaction is approved
#[serde(rename = "approved")]
pub approved: bool,
/// The transaction flag
#[serde(rename = "flag_color", skip_serializing_if = "Option::is_none")]
- pub flag_color: Option<String>,
+ pub flag_color: Option<FlagColor>,
#[serde(rename = "account_id")]
pub account_id: String,
#[serde(rename = "payee_id", skip_serializing_if = "Option::is_none")]
@@ -55,25 +56,51 @@ pub struct TransactionSummary {
}
impl TransactionSummary {
- pub fn new(id: String, date: String, amount: i64, cleared: String, approved: bool, account_id: String, deleted: bool) -> TransactionSummary {
+ pub fn new(id: String, date: String, amount: i64, cleared: Cleared, approved: bool, account_id: String, deleted: bool) -> TransactionSummary {
TransactionSummary {
- id: id,
- date: date,
- amount: amount,
+ id,
+ date,
+ amount,
memo: None,
- cleared: cleared,
- approved: approved,
+ cleared,
+ approved,
flag_color: None,
- account_id: account_id,
+ account_id,
payee_id: None,
category_id: None,
transfer_account_id: None,
transfer_transaction_id: None,
matched_transaction_id: None,
import_id: None,
- deleted: deleted,
+ deleted,
}
}
}
+/// The cleared status of the transaction
+#[derive(Debug, PartialEq, Serialize, Deserialize)]
+pub enum Cleared {
+ #[serde(rename = "cleared")]
+ Cleared,
+ #[serde(rename = "uncleared")]
+ Uncleared,
+ #[serde(rename = "reconciled")]
+ Reconciled,
+}
+/// The transaction flag
+#[derive(Debug, PartialEq, Serialize, Deserialize)]
+pub enum FlagColor {
+ #[serde(rename = "red")]
+ Red,
+ #[serde(rename = "orange")]
+ Orange,
+ #[serde(rename = "yellow")]
+ Yellow,
+ #[serde(rename = "green")]
+ Green,
+ #[serde(rename = "blue")]
+ Blue,
+ #[serde(rename = "purple")]
+ Purple,
+}