134 lines
3.8 KiB
Rust
134 lines
3.8 KiB
Rust
// src/api/models.rs
|
|
// This file contains all the data structures for the banking API.
|
|
// These are the "nouns" of our API interaction.
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
use chrono::{DateTime, Utc, NaiveDate};
|
|
|
|
// --- Generic API Wrappers ---
|
|
#[derive(Debug, Deserialize, Serialize, Clone)] // Added Serialize here
|
|
pub struct ApiResponse<T> {
|
|
pub data: T,
|
|
pub links: Links,
|
|
pub meta: Meta,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone)] // Added Serialize here
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct Links {
|
|
#[serde(rename = "self")]
|
|
pub self_link: String,
|
|
pub next: Option<String>,
|
|
pub prev: Option<String>,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone)] // Added Serialize here
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct Meta {
|
|
pub total_pages: Option<i32>,
|
|
pub total_records: Option<i32>,
|
|
pub current_page: Option<i32>,
|
|
pub page_size: Option<i32>,
|
|
}
|
|
|
|
// --- Consent Models ---
|
|
#[derive(Debug, Serialize, Clone)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub struct ConsentRequestBody {
|
|
pub client_id: String,
|
|
pub permissions: Vec<String>,
|
|
pub reason: String,
|
|
pub requesting_bank: String,
|
|
pub requesting_bank_name: String,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone)] // Added Serialize here
|
|
#[serde(rename_all = "snake_case")]
|
|
pub struct ConsentResponse {
|
|
pub request_id: String,
|
|
pub consent_id: String,
|
|
pub status: String,
|
|
pub message: String,
|
|
pub created_at: String,
|
|
pub auto_approved: bool,
|
|
}
|
|
|
|
// --- Account & Transaction Models ---
|
|
#[derive(Debug, Deserialize, Serialize, Clone)] // Added Serialize here
|
|
pub struct AccountData {
|
|
pub account: Vec<Account>,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone)] // Added Serialize here
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct Account {
|
|
pub account_id: String,
|
|
pub status: Option<String>,
|
|
pub currency: String,
|
|
pub account_type: String,
|
|
pub account_sub_type: Option<String>,
|
|
pub description: Option<String>,
|
|
pub nickname: String,
|
|
pub opening_date: Option<NaiveDate>,
|
|
pub account: Option<Vec<AccountIdentification>>,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone)] // Added Serialize here
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct AccountIdentification {
|
|
pub scheme_name: String,
|
|
pub identification: String,
|
|
pub name: String,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone)]
|
|
pub struct BalanceResponse {
|
|
pub data: BalanceData,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone)] // Added Serialize here
|
|
pub struct BalanceData {
|
|
pub balance: Vec<Balance>,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone)] // Added Serialize here
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct Balance {
|
|
pub account_id: String,
|
|
#[serde(rename = "type")]
|
|
pub balance_type: String,
|
|
pub date_time: DateTime<Utc>,
|
|
pub amount: Amount,
|
|
pub credit_debit_indicator: String,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone)] // Added Serialize here
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct TransactionData {
|
|
pub transaction: Vec<Transaction>,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone)] // Added Serialize here
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct Transaction {
|
|
pub account_id: String,
|
|
pub transaction_id: String,
|
|
pub amount: Amount,
|
|
pub credit_debit_indicator: String,
|
|
pub status: String,
|
|
pub booking_date_time: DateTime<Utc>,
|
|
pub value_date_time: Option<DateTime<Utc>>,
|
|
pub transaction_information: String,
|
|
pub bank_transaction_code: Option<BankTransactionCode>,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone)] // Added Serialize here
|
|
pub struct Amount {
|
|
pub amount: String,
|
|
pub currency: String,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone)] // Added Serialize here
|
|
pub struct BankTransactionCode {
|
|
pub code: String,
|
|
}
|