gocardless_unofficial/
model.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Deserialize, Clone)]
4#[serde(rename_all = "camelCase")]
5pub struct CreateTokenResponse {
6    pub access: String,
7    #[serde(rename = "access_expires")]
8    pub access_expires: i32,
9    pub refresh: String,
10    #[serde(rename = "refresh_expires")]
11    pub refresh_expires: i32,
12}
13
14#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
15#[serde(rename_all = "camelCase")]
16pub struct Institution {
17    pub id: String,
18    pub name: String,
19    pub bic: String,
20    #[serde(rename = "transaction_total_days")]
21    pub transaction_total_days: String,
22    pub countries: Vec<String>,
23    pub logo: String,
24}
25
26#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
27#[serde(rename_all = "camelCase")]
28pub struct EndUserAgreement {
29    pub id: String,
30    pub created: String,
31    #[serde(rename = "institution_id")]
32    pub institution_id: String,
33    #[serde(rename = "max_historical_days")]
34    pub max_historical_days: i64,
35    #[serde(rename = "access_valid_for_days")]
36    pub access_valid_for_days: i64,
37    #[serde(rename = "access_scope")]
38    pub access_scope: Vec<String>,
39}
40
41#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
42#[serde(rename_all = "camelCase")]
43pub struct ListRequisitionsResponse {
44    pub count: i64,
45    // pub next: Value,
46    // pub previous: Value,
47    pub results: Vec<Requisition>,
48}
49
50#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
51#[serde(rename_all = "camelCase")]
52pub struct Requisition {
53    pub id: String,
54    pub created: String,
55    pub redirect: String,
56    pub status: RequisitionStatus,
57    #[serde(rename = "institution_id")]
58    pub institution_id: String,
59    pub agreement: String,
60    pub reference: String,
61    pub accounts: Vec<String>,
62    #[serde(rename = "user_language")]
63    pub user_language: String,
64    pub link: String,
65    // pub ssn: Value,
66    #[serde(rename = "account_selection")]
67    pub account_selection: bool,
68    #[serde(rename = "redirect_immediate")]
69    pub redirect_immediate: bool,
70}
71
72#[derive(Default, Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
73pub enum RequisitionStatus {
74    #[default]
75    #[serde(rename = "CR")]
76    Created,
77    #[serde(rename = "GC")]
78    GivingConsent,
79    #[serde(rename = "UA")]
80    UndergoingAuthentication,
81    #[serde(rename = "RJ")]
82    Rejected,
83    #[serde(rename = "SA")]
84    SelectingAccounts,
85    #[serde(rename = "GA")]
86    GrantingAccess,
87    #[serde(rename = "LN")]
88    Linked,
89    #[serde(rename = "EX")]
90    Expired,
91}
92
93#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
94#[serde(rename_all = "camelCase")]
95pub struct ListTransactionsResponse {
96    #[serde(default)]
97    pub transactions: Transactions,
98}
99
100#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
101#[serde(rename_all = "camelCase")]
102pub struct Transactions {
103    pub booked: Vec<Transaction>,
104    pub pending: Vec<Transaction>,
105}
106
107#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
108#[serde(rename_all = "camelCase")]
109pub struct Transaction {
110    pub transaction_id: String,
111    pub booking_date: String,
112    pub value_date: Option<String>,
113    pub booking_date_time: String,
114    pub value_date_time: Option<String>,
115    pub transaction_amount: TransactionAmount,
116    pub creditor_name: Option<String>,
117    pub remittance_information_unstructured: Option<String>,
118    pub proprietary_bank_transaction_code: Option<String>,
119    pub internal_transaction_id: Option<String>,
120    pub debtor_name: Option<String>,
121    pub creditor_account: Option<CreditorAccount>,
122    // TODO: this field is either an array of objects or just a single object.
123    //       perhaps there is a way in serde to default to array of just 1 object?
124    // pub currency_exchange: Vec<CurrencyExchange>,
125}
126
127#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
128#[serde(rename_all = "camelCase")]
129pub struct TransactionAmount {
130    pub amount: String,
131    pub currency: String,
132}
133
134#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
135#[serde(rename_all = "camelCase")]
136pub struct CreditorAccount {
137    pub bban: String,
138}
139
140#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
141#[serde(rename_all = "camelCase")]
142pub struct CurrencyExchange {
143    pub source_currency: String,
144    pub exchange_rate: String,
145    pub unit_currency: String,
146    pub target_currency: String,
147}
148
149#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
150#[serde(rename_all = "camelCase")]
151pub struct ListBalancesResponse {
152    #[serde(default)]
153    pub balances: Vec<Balance>,
154}
155
156#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
157#[serde(rename_all = "camelCase")]
158pub struct Balance {
159    pub balance_amount: BalanceAmount,
160    pub balance_type: String,
161    pub reference_date: String,
162}
163
164#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
165#[serde(rename_all = "camelCase")]
166pub struct BalanceAmount {
167    pub amount: String,
168    pub currency: String,
169}
170
171#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
172#[serde(rename_all = "camelCase")]
173pub struct AccountDetailsResponse {
174    #[serde(default)]
175    pub account: Option<Account>,
176}
177
178#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
179#[serde(rename_all = "camelCase")]
180pub struct Account {
181    /// The account id of the given account in the financial institution
182    pub resource_id: String,
183    pub iban: Option<String>,
184    /// This data element is used for payment accounts which have no IBAN
185    pub bban: Option<String>,
186    /// The BIC associated to the account
187    pub bic: Option<String>,
188    /// An alias to a payment account via a registered mobile phone number
189    pub msisdn: Option<String>,
190    /// Account currency
191    pub currency: String,
192    /// Name of the legal account owner. If there is more than one owner, then e.g. two names might be noted here. For a corporate account, the corporate name is used for this attribute
193    pub owner_name: Option<String>,
194    /// Address of the legal account owner
195    pub owner_address_unstructured: Option<String>,
196    /// Name of the account, as assigned by the financial institution
197    pub name: Option<String>,
198    /// Name of the account as defined by the end user within online channels
199    pub display_name: Option<String>,
200    /// Specifications that might be provided by the financial institution - characteristics of the account - characteristics of the relevant card
201    pub details: Option<String>,
202    /// Product Name of the Bank for this account, proprietary definition
203    pub product: Option<String>,
204    /// ExternalCashAccountType1Code from ISO 20022
205    pub cash_account_type: Option<String>,
206    /// Account status, if this field is None, then the account is available in the sense of the specification
207    pub status: Option<AccountStatus>,
208    /// This data attribute is a field, where an financial institution can name a cash account associated to pending card transactions
209    pub linked_accounts: Option<String>,
210    /// Specifies the usage of the account
211    pub usage: Option<AccountUsage>,
212}
213
214#[derive(Default, Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
215pub enum AccountStatus {
216    #[default]
217    #[serde(rename = "enabled")]
218    /// Account is available
219    Enabled,
220    #[serde(rename = "deleted")]
221    /// Account is terminated
222    Deleted,
223    #[serde(rename = "blocked")]
224    /// Account is blocked e.g. for legal reasons
225    Blocked,
226}
227
228#[derive(Default, Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
229pub enum AccountUsage {
230    #[default]
231    #[serde(rename = "PRIV")]
232    /// Private personal account
233    Private,
234    #[serde(rename = "ORGA")]
235    /// Professional account
236    Professional,
237}