plaid/model/
asset_report_transaction.rs

1use serde::{Serialize, Deserialize};
2use super::{AssetReportTransactionType, CreditCategory, Location, PaymentMeta};
3///A transaction on the asset report
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct AssetReportTransaction {
6    ///The ID of the account in which this transaction occurred.
7    pub account_id: String,
8    ///The name of the account owner. This field is not typically populated and only relevant when dealing with sub-accounts.
9    #[serde(default, skip_serializing_if = "Option::is_none")]
10    pub account_owner: Option<String>,
11    ///The settled value of the transaction, denominated in the transaction's currency, as stated in `iso_currency_code` or `unofficial_currency_code`. Positive values when money moves out of the account; negative values when money moves in. For example, debit card purchases are positive; credit card payments, direct deposits, and refunds are negative.
12    pub amount: f64,
13    /**A hierarchical array of the categories to which this transaction belongs. For a full list of categories, see [`/categories/get`](https://plaid.com/docs/api/products/transactions/#categoriesget).
14
15This field will only appear in an Asset Report with Insights.*/
16    #[serde(default, skip_serializing_if = "Option::is_none")]
17    pub category: Option<Vec<String>>,
18    /**The ID of the category to which this transaction belongs. For a full list of categories, see [`/categories/get`](https://plaid.com/docs/api/products/transactions/#categoriesget).
19
20This field will only appear in an Asset Report with Insights.*/
21    #[serde(default, skip_serializing_if = "Option::is_none")]
22    pub category_id: Option<String>,
23    ///The check number of the transaction. This field is only populated for check transactions.
24    #[serde(default, skip_serializing_if = "Option::is_none")]
25    pub check_number: Option<String>,
26    /**Information describing the intent of the transaction. Most relevant for credit use cases, but not limited to such use cases.
27
28See the [`taxonomy csv file`](https://plaid.com/documents/credit-category-taxonomy.csv) for a full list of credit categories.*/
29    #[serde(default, skip_serializing_if = "Option::is_none")]
30    pub credit_category: Option<CreditCategory>,
31    ///For pending transactions, the date that the transaction occurred; for posted transactions, the date that the transaction posted. Both dates are returned in an [ISO 8601](https://wikipedia.org/wiki/ISO_8601) format ( `YYYY-MM-DD` ).
32    pub date: chrono::NaiveDate,
33    ///The date on which the transaction took place, in IS0 8601 format.
34    #[serde(default, skip_serializing_if = "Option::is_none")]
35    pub date_transacted: Option<String>,
36    ///A unique identifier for an income source.
37    #[serde(default, skip_serializing_if = "Option::is_none")]
38    pub income_source_id: Option<String>,
39    ///The ISO-4217 currency code of the transaction. Always `null` if `unofficial_currency_code` is non-null.
40    #[serde(default, skip_serializing_if = "Option::is_none")]
41    pub iso_currency_code: Option<String>,
42    ///A representation of where a transaction took place
43    #[serde(default, skip_serializing_if = "Option::is_none")]
44    pub location: Option<Location>,
45    ///The merchant name, as enriched by Plaid from the `name` field. This is typically a more human-readable version of the merchant counterparty in the transaction. For some bank transactions (such as checks or account transfers) where there is no meaningful merchant name, this value will be `null`.
46    #[serde(default, skip_serializing_if = "Option::is_none")]
47    pub merchant_name: Option<String>,
48    /**The merchant name or transaction description.
49
50This field will only appear in an Asset Report with Insights.*/
51    #[serde(default, skip_serializing_if = "Option::is_none")]
52    pub name: Option<String>,
53    ///The string returned by the financial institution to describe the transaction.
54    #[serde(default, skip_serializing_if = "Option::is_none")]
55    pub original_description: Option<String>,
56    /**Transaction information specific to inter-bank transfers. If the transaction was not an inter-bank transfer, all fields will be `null`.
57
58If the `transactions` object was returned by a Transactions endpoint such as `/transactions/sync` or `/transactions/get`, the `payment_meta` key will always appear, but no data elements are guaranteed. If the `transactions` object was returned by an Assets endpoint such as `/asset_report/get/` or `/asset_report/pdf/get`, this field will only appear in an Asset Report with Insights.*/
59    #[serde(default, skip_serializing_if = "Option::is_none")]
60    pub payment_meta: Option<PaymentMeta>,
61    ///When `true`, identifies the transaction as pending or unsettled. Pending transaction details (name, type, amount, category ID) may change before they are settled.
62    pub pending: bool,
63    ///The ID of a posted transaction's associated pending transaction, where applicable.
64    #[serde(default, skip_serializing_if = "Option::is_none")]
65    pub pending_transaction_id: Option<String>,
66    ///The unique ID of the transaction. Like all Plaid identifiers, the `transaction_id` is case sensitive.
67    pub transaction_id: String,
68    /**`digital:` transactions that took place online.
69
70`place:` transactions that were made at a physical location.
71
72`special:` transactions that relate to banks, e.g. fees or deposits.
73
74`unresolved:` transactions that do not fit into the other three types.*/
75    #[serde(default, skip_serializing_if = "Option::is_none")]
76    pub transaction_type: Option<AssetReportTransactionType>,
77    /**The unofficial currency code associated with the transaction. Always `null` if `iso_currency_code` is non-`null`. Unofficial currency codes are used for currencies that do not have official ISO currency codes, such as cryptocurrencies and the currencies of certain countries.
78
79See the [currency code schema](https://plaid.com/docs/api/accounts#currency-code-schema) for a full listing of supported `unofficial_currency_code`s.*/
80    #[serde(default, skip_serializing_if = "Option::is_none")]
81    pub unofficial_currency_code: Option<String>,
82}
83impl std::fmt::Display for AssetReportTransaction {
84    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
85        write!(f, "{}", serde_json::to_string(self).unwrap())
86    }
87}