aboutsummaryrefslogtreecommitdiffstats
path: root/src/models/update_transaction.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/models/update_transaction.rs')
-rw-r--r--src/models/update_transaction.rs98
1 files changed, 98 insertions, 0 deletions
diff --git a/src/models/update_transaction.rs b/src/models/update_transaction.rs
new file mode 100644
index 0000000..5e93837
--- /dev/null
+++ b/src/models/update_transaction.rs
@@ -0,0 +1,98 @@
+/*
+ * 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 UpdateTransaction {
+ #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
+ pub id: Option<String>,
+ #[serde(rename = "account_id")]
+ pub account_id: String,
+ /// The transaction date in ISO format (e.g. 2016-12-01). Future dates (scheduled transactions) are not permitted. Split transaction dates cannot be changed and if a different date is supplied it will be ignored.
+ #[serde(rename = "date")]
+ pub date: String,
+ /// The transaction amount in milliunits format. Split transaction amounts cannot be changed and if a different amount is supplied it will be ignored.
+ #[serde(rename = "amount")]
+ pub amount: i64,
+ /// The payee for the transaction
+ #[serde(rename = "payee_id", skip_serializing_if = "Option::is_none")]
+ pub payee_id: Option<String>,
+ /// The payee name. If a payee_name value is provided and payee_id has a null value, the payee_name value will be used to resolve the payee by either (1) a matching payee rename rule (only if import_id is also specified) or (2) a payee with the same name or (3) creation of a new payee.
+ #[serde(rename = "payee_name", skip_serializing_if = "Option::is_none")]
+ pub payee_name: Option<String>,
+ /// The category for the transaction. Split and Credit Card Payment categories are not permitted and will be ignored if supplied. If an existing transaction has a Split category it cannot be changed.
+ #[serde(rename = "category_id", skip_serializing_if = "Option::is_none")]
+ pub category_id: Option<String>,
+ #[serde(rename = "memo", skip_serializing_if = "Option::is_none")]
+ pub memo: Option<String>,
+ /// The cleared status of the transaction
+ #[serde(rename = "cleared", skip_serializing_if = "Option::is_none")]
+ pub cleared: Option<String>,
+ /// Whether or not the transaction is approved. If not supplied, transaction will be unapproved by default.
+ #[serde(rename = "approved", skip_serializing_if = "Option::is_none")]
+ pub approved: Option<bool>,
+ /// The transaction flag
+ #[serde(rename = "flag_color", skip_serializing_if = "Option::is_none")]
+ pub flag_color: Option<String>,
+ /// If specified, the new transaction will be assigned this import_id and considered \"imported\". *At the time of import* we will attempt to match \"imported\" transactions with non-imported (i.e. \"user-entered\") transactions.<br><br>Transactions imported through File Based Import or Direct Import (not through the API) are assigned an import_id in the format: 'YNAB:[milliunit_amount]:[iso_date]:[occurrence]'. For example, a transaction dated 2015-12-30 in the amount of -$294.23 USD would have an import_id of 'YNAB:-294230:2015-12-30:1'. If a second transaction on the same account was imported and had the same date and same amount, its import_id would be 'YNAB:-294230:2015-12-30:2'. Using a consistent format will prevent duplicates through Direct Import and File Based Import.<br><br>If import_id is omitted or specified as null, the transaction will be treated as a \"user-entered\" transaction. As such, it will be eligible to be matched against transactions later being imported (via DI, FBI, or API).
+ #[serde(rename = "import_id", skip_serializing_if = "Option::is_none")]
+ pub import_id: Option<String>,
+}
+
+impl UpdateTransaction {
+ pub fn new(account_id: String, date: String, amount: i64) -> UpdateTransaction {
+ UpdateTransaction {
+ id: None,
+ account_id: account_id,
+ date: date,
+ amount: amount,
+ payee_id: None,
+ payee_name: None,
+ category_id: None,
+ memo: None,
+ cleared: None,
+ approved: None,
+ flag_color: None,
+ import_id: None,
+ }
+ }
+}
+
+/// The cleared status of the transaction
+#[derive(Debug, Serialize, Deserialize)]
+pub enum Cleared {
+ #[serde(rename = "cleared")]
+ Cleared,
+ #[serde(rename = "uncleared")]
+ Uncleared,
+ #[serde(rename = "reconciled")]
+ Reconciled,
+}
+/// The transaction flag
+#[derive(Debug, 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,
+}
+