/
rorikstr
/
multiberry-backend
Обзор
Документация
Войти
/
rorikstr
/
multiberry-backend
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
develop
src/api/models.rs
132 строки
3 KB
Rorik Star Platinum
finish 30% lol
09 ноя 2025, 21:03
09 ноя 2025, 21:03
ea863ad
Код
Авторство
О чём код?
// src/api/models.rs use serde::{Deserialize, Serialize}; use chrono::{DateTime, Utc, NaiveDate}; // --- Generic API Wrappers --- #[derive(Debug, Deserialize, Serialize, Clone)] pub struct ApiResponse<T> { pub data: T, pub links: Links, pub meta: Meta, } #[derive(Debug, Deserialize, Serialize, Clone)] #[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)] #[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)] #[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)] pub struct AccountData { pub account: Vec<Account>, } #[derive(Debug, Deserialize, Serialize, Clone)] #[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)] #[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)] pub struct BalanceData { pub balance: Vec<Balance>, } #[derive(Debug, Deserialize, Serialize, Clone)] #[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)] #[serde(rename_all = "camelCase")] pub struct TransactionData { pub transaction: Vec<Transaction>, } #[derive(Debug, Deserialize, Serialize, Clone)] #[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)] pub struct Amount { pub amount: String, pub currency: String, } #[derive(Debug, Deserialize, Serialize, Clone)] pub struct BankTransactionCode { pub code: String, }