aboutsummaryrefslogtreecommitdiffstats
path: root/ynab-api/src/models/hybrid_transaction.rs
blob: 802813b2584bd5cda3f10bef2abfb05e3cd730d8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
 * 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 HybridTransaction {
    #[serde(rename = "id")]
    pub id: String,
    /// The transaction date in ISO format (e.g. 2016-12-01)
    #[serde(rename = "date")]
    pub date: String,
    /// The transaction amount in milliunits format
    #[serde(rename = "amount")]
    pub amount: i64,
    #[serde(rename = "memo", skip_serializing_if = "Option::is_none")]
    pub memo: Option<String>,
    /// The cleared status of the transaction
    #[serde(rename = "cleared")]
    pub cleared: String,
    /// 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>,
    #[serde(rename = "account_id")]
    pub account_id: String,
    #[serde(rename = "payee_id", skip_serializing_if = "Option::is_none")]
    pub payee_id: Option<String>,
    #[serde(rename = "category_id", skip_serializing_if = "Option::is_none")]
    pub category_id: Option<String>,
    /// If a transfer transaction, the account to which it transfers
    #[serde(rename = "transfer_account_id", skip_serializing_if = "Option::is_none")]
    pub transfer_account_id: Option<String>,
    /// If a transfer transaction, the id of transaction on the other side of the transfer
    #[serde(rename = "transfer_transaction_id", skip_serializing_if = "Option::is_none")]
    pub transfer_transaction_id: Option<String>,
    /// If transaction is matched, the id of the matched transaction
    #[serde(rename = "matched_transaction_id", skip_serializing_if = "Option::is_none")]
    pub matched_transaction_id: Option<String>,
    /// 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'.
    #[serde(rename = "import_id", skip_serializing_if = "Option::is_none")]
    pub import_id: Option<String>,
    /// Whether or not the transaction has been deleted.  Deleted transactions will only be included in delta requests.
    #[serde(rename = "deleted")]
    pub deleted: bool,
    /// Whether the hybrid transaction represents a regular transaction or a subtransaction
    #[serde(rename = "type")]
    pub _type: String,
    /// For subtransaction types, this is the id of the pararent transaction.  For transaction types, this id will be always be null.
    #[serde(rename = "parent_transaction_id", skip_serializing_if = "Option::is_none")]
    pub parent_transaction_id: Option<String>,
    #[serde(rename = "account_name")]
    pub account_name: String,
    #[serde(rename = "payee_name", skip_serializing_if = "Option::is_none")]
    pub payee_name: Option<String>,
    #[serde(rename = "category_name")]
    pub category_name: String,
}

impl HybridTransaction {
    pub fn new(id: String, date: String, amount: i64, cleared: String, approved: bool, account_id: String, deleted: bool, _type: String, account_name: String, category_name: String) -> HybridTransaction {
        HybridTransaction {
            id: id,
            date: date,
            amount: amount,
            memo: None,
            cleared: cleared,
            approved: approved,
            flag_color: None,
            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,
            _type: _type,
            parent_transaction_id: None,
            account_name: account_name,
            payee_name: None,
            category_name: category_name,
        }
    }
}

/// 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,
}
/// Whether the hybrid transaction represents a regular transaction or a subtransaction
#[derive(Debug, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "transaction")]
    Transaction,
    #[serde(rename = "subtransaction")]
    Subtransaction,
}