From ef0c483ee7942fa1ddd84e52bb296c70fa2bc133 Mon Sep 17 00:00:00 2001 From: Jacob Kiers Date: Thu, 27 Nov 2025 22:28:27 +0100 Subject: [PATCH] feat: Add full account representations Having all details available is useful. For Firefly III some fields like current balance are left out, because they are not strictly account metadata, but are a result of the transactions in the account. --- firefly-client/src/models.rs | 36 +++++++++++++++++++++++++++++++++ gocardless-client/src/client.rs | 11 +++++++++- gocardless-client/src/models.rs | 27 +++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 1 deletion(-) diff --git a/firefly-client/src/models.rs b/firefly-client/src/models.rs index 7c81819..6cffa0a 100644 --- a/firefly-client/src/models.rs +++ b/firefly-client/src/models.rs @@ -13,6 +13,42 @@ pub struct Account { #[serde(rename = "type")] pub account_type: String, pub active: Option, + pub order: Option, + pub created_at: Option, + pub updated_at: Option, + pub account_role: Option, + pub object_group_id: Option, + pub object_group_title: Option, + pub object_group_order: Option, + pub currency_id: Option, + pub currency_name: Option, + pub currency_code: Option, + pub currency_symbol: Option, + pub currency_decimal_places: Option, + pub primary_currency_id: Option, + pub primary_currency_name: Option, + pub primary_currency_code: Option, + pub primary_currency_symbol: Option, + pub primary_currency_decimal_places: Option, + pub opening_balance: Option, + pub pc_opening_balance: Option, + pub debt_amount: Option, + pub pc_debt_amount: Option, + pub notes: Option, + pub monthly_payment_date: Option, + pub credit_card_type: Option, + pub account_number: Option, + pub bic: Option, + pub opening_balance_date: Option, + pub liability_type: Option, + pub liability_direction: Option, + pub interest: Option, + pub interest_period: Option, + pub include_net_worth: Option, + pub longitude: Option, + pub latitude: Option, + pub zoom_level: Option, + pub last_activity: Option, } #[derive(Debug, Clone, Serialize, Deserialize)] diff --git a/gocardless-client/src/client.rs b/gocardless-client/src/client.rs index d01d09e..ca6765c 100644 --- a/gocardless-client/src/client.rs +++ b/gocardless-client/src/client.rs @@ -1,5 +1,6 @@ use crate::models::{ - Account, EndUserAgreement, PaginatedResponse, Requisition, TokenResponse, TransactionsResponse, + Account, AccountDetail, EndUserAgreement, PaginatedResponse, Requisition, TokenResponse, + TransactionsResponse, }; use reqwest::Url; use reqwest_middleware::ClientWithMiddleware; @@ -147,6 +148,14 @@ impl GoCardlessClient { self.get_authenticated(url).await } + #[instrument(skip(self))] + pub async fn get_account_details(&self, id: &str) -> Result { + let url = self + .base_url + .join(&format!("/api/v2/accounts/{}/details/", id))?; + self.get_authenticated(url).await + } + #[instrument(skip(self))] pub async fn get_transactions( &self, diff --git a/gocardless-client/src/models.rs b/gocardless-client/src/models.rs index 391f613..fc5e064 100644 --- a/gocardless-client/src/models.rs +++ b/gocardless-client/src/models.rs @@ -42,6 +42,33 @@ pub struct Account { pub iban: Option, pub institution_id: Option, pub status: Option, + pub owner_name: Option, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct AccountDetail { + pub account: DetailSchema, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct DetailSchema { + pub resource_id: Option, + pub iban: Option, + pub bban: Option, + pub pan: Option, + pub masked_pan: Option, + pub msisdn: Option, + pub currency: Option, + pub owner_name: Option, + pub name: Option, + pub display_name: Option, + pub product: Option, + pub cash_account_type: Option, + pub status: Option, + pub bic: Option, + pub linked_accounts: Option, + pub usage: Option, + pub details: Option, } #[derive(Debug, Clone, Serialize, Deserialize)]