ynab_api_async_fork/models/
transaction_summary.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 TransactionSummary {
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}
67
68impl TransactionSummary {
69    pub fn new(id: String, date: String, amount: i64, cleared: crate::models::TransactionClearedStatus, approved: bool, account_id: String, deleted: bool) -> TransactionSummary {
70        TransactionSummary {
71            id,
72            date,
73            amount,
74            memo: None,
75            cleared,
76            approved,
77            flag_color: None,
78            flag_name: None,
79            account_id,
80            payee_id: None,
81            category_id: None,
82            transfer_account_id: None,
83            transfer_transaction_id: None,
84            matched_transaction_id: None,
85            import_id: None,
86            import_payee_name: None,
87            import_payee_name_original: None,
88            debt_transaction_type: None,
89            deleted,
90        }
91    }
92}
93
94/// If the transaction is a debt/loan account transaction, the type of transaction
95#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
96pub enum DebtTransactionType {
97    #[serde(rename = "payment")]
98    Payment,
99    #[serde(rename = "refund")]
100    Refund,
101    #[serde(rename = "fee")]
102    Fee,
103    #[serde(rename = "interest")]
104    Interest,
105    #[serde(rename = "escrow")]
106    Escrow,
107    #[serde(rename = "balanceAdjustment")]
108    BalanceAdjustment,
109    #[serde(rename = "credit")]
110    Credit,
111    #[serde(rename = "charge")]
112    Charge,
113    #[serde(rename = "null")]
114    Null,
115}
116