ynab_api_async_fork/models/
hybrid_transaction.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 HybridTransaction {
16    #[serde(rename = "id")]
17    pub id: String,
18    /// The transaction date in ISO format (e.g. 2016-12-01)
19    #[serde(rename = "date")]
20    pub date: String,
21    /// The transaction amount in milliunits format
22    #[serde(rename = "amount")]
23    pub amount: i64,
24    #[serde(rename = "memo", skip_serializing_if = "Option::is_none")]
25    pub memo: Option<String>,
26    #[serde(rename = "cleared")]
27    pub cleared: crate::models::TransactionClearedStatus,
28    /// Whether or not the transaction is approved
29    #[serde(rename = "approved")]
30    pub approved: bool,
31    #[serde(rename = "flag_color", skip_serializing_if = "Option::is_none")]
32    pub flag_color: Option<crate::models::TransactionFlagColor>,
33    /// The customized name of a transaction flag
34    #[serde(rename = "flag_name", skip_serializing_if = "Option::is_none")]
35    pub flag_name: Option<String>,
36    #[serde(rename = "account_id")]
37    pub account_id: String,
38    #[serde(rename = "payee_id", skip_serializing_if = "Option::is_none")]
39    pub payee_id: Option<String>,
40    #[serde(rename = "category_id", skip_serializing_if = "Option::is_none")]
41    pub category_id: Option<String>,
42    /// If a transfer transaction, the account to which it transfers
43    #[serde(rename = "transfer_account_id", skip_serializing_if = "Option::is_none")]
44    pub transfer_account_id: Option<String>,
45    /// If a transfer transaction, the id of transaction on the other side of the transfer
46    #[serde(rename = "transfer_transaction_id", skip_serializing_if = "Option::is_none")]
47    pub transfer_transaction_id: Option<String>,
48    /// If transaction is matched, the id of the matched transaction
49    #[serde(rename = "matched_transaction_id", skip_serializing_if = "Option::is_none")]
50    pub matched_transaction_id: Option<String>,
51    /// If the transaction was imported, this field is a unique (by account) import identifier.  If this transaction was imported through File Based Import or Direct Import and not through the API, the import_id will have 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'.
52    #[serde(rename = "import_id", skip_serializing_if = "Option::is_none")]
53    pub import_id: Option<String>,
54    /// If the transaction was imported, the payee name that was used when importing and before applying any payee rename rules
55    #[serde(rename = "import_payee_name", skip_serializing_if = "Option::is_none")]
56    pub import_payee_name: Option<String>,
57    /// If the transaction was imported, the original payee name as it appeared on the statement
58    #[serde(rename = "import_payee_name_original", skip_serializing_if = "Option::is_none")]
59    pub import_payee_name_original: Option<String>,
60    /// If the transaction is a debt/loan account transaction, the type of transaction
61    #[serde(rename = "debt_transaction_type", skip_serializing_if = "Option::is_none")]
62    pub debt_transaction_type: Option<DebtTransactionType>,
63    /// Whether or not the transaction has been deleted.  Deleted transactions will only be included in delta requests.
64    #[serde(rename = "deleted")]
65    pub deleted: bool,
66    /// Whether the hybrid transaction represents a regular transaction or a subtransaction
67    #[serde(rename = "type")]
68    pub _type: Type,
69    /// For subtransaction types, this is the id of the parent transaction.  For transaction types, this id will be always be null.
70    #[serde(rename = "parent_transaction_id", skip_serializing_if = "Option::is_none")]
71    pub parent_transaction_id: Option<String>,
72    #[serde(rename = "account_name")]
73    pub account_name: String,
74    #[serde(rename = "payee_name", skip_serializing_if = "Option::is_none")]
75    pub payee_name: Option<String>,
76    /// The name of the category.  If a split transaction, this will be 'Split'.
77    #[serde(rename = "category_name", skip_serializing_if = "Option::is_none")]
78    pub category_name: Option<String>,
79}
80
81impl HybridTransaction {
82    pub fn new(id: String, date: String, amount: i64, cleared: crate::models::TransactionClearedStatus, approved: bool, account_id: String, deleted: bool, _type: Type, account_name: String) -> HybridTransaction {
83        HybridTransaction {
84            id,
85            date,
86            amount,
87            memo: None,
88            cleared,
89            approved,
90            flag_color: None,
91            flag_name: None,
92            account_id,
93            payee_id: None,
94            category_id: None,
95            transfer_account_id: None,
96            transfer_transaction_id: None,
97            matched_transaction_id: None,
98            import_id: None,
99            import_payee_name: None,
100            import_payee_name_original: None,
101            debt_transaction_type: None,
102            deleted,
103            _type,
104            parent_transaction_id: None,
105            account_name,
106            payee_name: None,
107            category_name: None,
108        }
109    }
110}
111
112/// If the transaction is a debt/loan account transaction, the type of transaction
113#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
114pub enum DebtTransactionType {
115    #[serde(rename = "payment")]
116    Payment,
117    #[serde(rename = "refund")]
118    Refund,
119    #[serde(rename = "fee")]
120    Fee,
121    #[serde(rename = "interest")]
122    Interest,
123    #[serde(rename = "escrow")]
124    Escrow,
125    #[serde(rename = "balanceAdjustment")]
126    BalanceAdjustment,
127    #[serde(rename = "credit")]
128    Credit,
129    #[serde(rename = "charge")]
130    Charge,
131    #[serde(rename = "null")]
132    Null,
133}
134/// Whether the hybrid transaction represents a regular transaction or a subtransaction
135#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
136pub enum Type {
137    #[serde(rename = "transaction")]
138    Transaction,
139    #[serde(rename = "subtransaction")]
140    Subtransaction,
141}
142