From 80849a9eefabdfb9c0aff81b8c3b942380773836 Mon Sep 17 00:00:00 2001 From: Jacob Kiers Date: Fri, 4 Oct 2024 20:34:27 +0200 Subject: [PATCH] Fix bug in official Gocardless API definition The official Gocardless API definition indicates that transactions are directly output to an array. Instead, they are wrapped in a transactions key. This made the code fail to retrieve transactions, because they could not be correctly serialized. This is now fixed in the API definition, and the API code is also regenerated. Signed-off-by: Jacob Kiers --- .../.openapi-generator/FILES | 2 ++ gocardless-bankaccount-data-api/README.md | 1 + .../docs/AccountsApi.md | 4 +-- .../docs/BankTransactions.md | 11 +++++++ .../src/apis/accounts_api.rs | 2 +- .../src/models/bank_transactions.rs | 30 +++++++++++++++++++ .../src/models/mod.rs | 2 ++ gocardless_bank_account_data_api_v2.json | 30 ++++++++++++++----- 8 files changed, 71 insertions(+), 11 deletions(-) create mode 100644 gocardless-bankaccount-data-api/docs/BankTransactions.md create mode 100644 gocardless-bankaccount-data-api/src/models/bank_transactions.rs diff --git a/gocardless-bankaccount-data-api/.openapi-generator/FILES b/gocardless-bankaccount-data-api/.openapi-generator/FILES index 43a998c..8f60dc5 100644 --- a/gocardless-bankaccount-data-api/.openapi-generator/FILES +++ b/gocardless-bankaccount-data-api/.openapi-generator/FILES @@ -12,6 +12,7 @@ docs/AgreementsApi.md docs/BalanceAmountSchema.md docs/BalanceSchema.md docs/BankTransaction.md +docs/BankTransactions.md docs/CurrencyExchangeSchema.md docs/DetailSchema.md docs/EndUserAgreement.md @@ -52,6 +53,7 @@ src/models/account_schema.rs src/models/balance_amount_schema.rs src/models/balance_schema.rs src/models/bank_transaction.rs +src/models/bank_transactions.rs src/models/currency_exchange_schema.rs src/models/detail_schema.rs src/models/end_user_agreement.rs diff --git a/gocardless-bankaccount-data-api/README.md b/gocardless-bankaccount-data-api/README.md index c2dc6c0..f965b6a 100644 --- a/gocardless-bankaccount-data-api/README.md +++ b/gocardless-bankaccount-data-api/README.md @@ -54,6 +54,7 @@ Class | Method | HTTP request | Description - [BalanceAmountSchema](docs/BalanceAmountSchema.md) - [BalanceSchema](docs/BalanceSchema.md) - [BankTransaction](docs/BankTransaction.md) + - [BankTransactions](docs/BankTransactions.md) - [CurrencyExchangeSchema](docs/CurrencyExchangeSchema.md) - [DetailSchema](docs/DetailSchema.md) - [EndUserAgreement](docs/EndUserAgreement.md) diff --git a/gocardless-bankaccount-data-api/docs/AccountsApi.md b/gocardless-bankaccount-data-api/docs/AccountsApi.md index 72a915d..9cd3186 100644 --- a/gocardless-bankaccount-data-api/docs/AccountsApi.md +++ b/gocardless-bankaccount-data-api/docs/AccountsApi.md @@ -103,7 +103,7 @@ Name | Type | Description | Required | Notes ## retrieve_account_transactions -> models::BankTransaction retrieve_account_transactions(id, date_from, date_to) +> models::BankTransactions retrieve_account_transactions(id, date_from, date_to) Access account transactions. Transactions will be returned in Berlin Group PSD2 format. @@ -119,7 +119,7 @@ Name | Type | Description | Required | Notes ### Return type -[**models::BankTransaction**](BankTransaction.md) +[**models::BankTransactions**](BankTransactions.md) ### Authorization diff --git a/gocardless-bankaccount-data-api/docs/BankTransactions.md b/gocardless-bankaccount-data-api/docs/BankTransactions.md new file mode 100644 index 0000000..785b8f9 --- /dev/null +++ b/gocardless-bankaccount-data-api/docs/BankTransactions.md @@ -0,0 +1,11 @@ +# BankTransactions + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**transactions** | Option<[**models::BankTransaction**](BankTransaction.md)> | BankTransaction | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/gocardless-bankaccount-data-api/src/apis/accounts_api.rs b/gocardless-bankaccount-data-api/src/apis/accounts_api.rs index 4fe7feb..b8470ee 100644 --- a/gocardless-bankaccount-data-api/src/apis/accounts_api.rs +++ b/gocardless-bankaccount-data-api/src/apis/accounts_api.rs @@ -166,7 +166,7 @@ pub async fn retrieve_account_metadata(configuration: &configuration::Configurat } /// Access account transactions. Transactions will be returned in Berlin Group PSD2 format. -pub async fn retrieve_account_transactions(configuration: &configuration::Configuration, id: &str, date_from: Option, date_to: Option) -> Result> { +pub async fn retrieve_account_transactions(configuration: &configuration::Configuration, id: &str, date_from: Option, date_to: Option) -> Result> { let local_var_configuration = configuration; let local_var_client = &local_var_configuration.client; diff --git a/gocardless-bankaccount-data-api/src/models/bank_transactions.rs b/gocardless-bankaccount-data-api/src/models/bank_transactions.rs new file mode 100644 index 0000000..860daee --- /dev/null +++ b/gocardless-bankaccount-data-api/src/models/bank_transactions.rs @@ -0,0 +1,30 @@ +/* + * GoCardless Bank Account Data API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 2.0 (v2) + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// BankTransactions : BankTransactions. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct BankTransactions { + /// BankTransaction + #[serde(rename = "transactions", skip_serializing_if = "Option::is_none")] + pub transactions: Option, +} + +impl BankTransactions { + /// BankTransactions. + pub fn new() -> BankTransactions { + BankTransactions { + transactions: None, + } + } +} + diff --git a/gocardless-bankaccount-data-api/src/models/mod.rs b/gocardless-bankaccount-data-api/src/models/mod.rs index 4c967c9..0624a01 100644 --- a/gocardless-bankaccount-data-api/src/models/mod.rs +++ b/gocardless-bankaccount-data-api/src/models/mod.rs @@ -12,6 +12,8 @@ pub mod balance_schema; pub use self::balance_schema::BalanceSchema; pub mod bank_transaction; pub use self::bank_transaction::BankTransaction; +pub mod bank_transactions; +pub use self::bank_transactions::BankTransactions; pub mod currency_exchange_schema; pub use self::currency_exchange_schema::CurrencyExchangeSchema; pub mod detail_schema; diff --git a/gocardless_bank_account_data_api_v2.json b/gocardless_bank_account_data_api_v2.json index 47219f1..7ed8e7f 100644 --- a/gocardless_bank_account_data_api_v2.json +++ b/gocardless_bank_account_data_api_v2.json @@ -396,8 +396,8 @@ "AccountStateError": { "value": { "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", - "created": "2024-10-04 18:06:13.681544+00:00", - "last_accessed": "2024-10-04 18:06:13.681558+00:00", + "created": "2024-10-04 17:15:14.926423+00:00", + "last_accessed": "2024-10-04 17:15:14.926442+00:00", "iban": "string", "aspsp_identifier": "string", "status": "ERROR" @@ -703,8 +703,8 @@ "AccountStateError": { "value": { "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", - "created": "2024-10-04 18:06:13.681544+00:00", - "last_accessed": "2024-10-04 18:06:13.681558+00:00", + "created": "2024-10-04 17:15:14.926423+00:00", + "last_accessed": "2024-10-04 17:15:14.926442+00:00", "iban": "string", "aspsp_identifier": "string", "status": "ERROR" @@ -804,7 +804,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/BankTransaction" + "$ref": "#/components/schemas/BankTransactions" }, "examples": { "RetrieveAccountTransactions": { @@ -1080,8 +1080,8 @@ "AccountStateError": { "value": { "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", - "created": "2024-10-04 18:06:13.681544+00:00", - "last_accessed": "2024-10-04 18:06:13.681558+00:00", + "created": "2024-10-04 17:15:14.926423+00:00", + "last_accessed": "2024-10-04 17:15:14.926442+00:00", "iban": "string", "aspsp_identifier": "string", "status": "ERROR" @@ -1329,7 +1329,7 @@ }, { "summary": "Unsupported access scope selected.", - "detail": "The access scopes supported by the institution are ['transactions']. The following scopes are not supported: ['details', 'balances']" + "detail": "The access scopes supported by the institution are ['transactions']. The following scopes are not supported: ['balances', 'details']" }, { "summary": "Field 'access_scope' may not be an empty list.", @@ -3684,6 +3684,20 @@ "balanceType" ] }, + "BankTransactions": { + "type": "object", + "description": "BankTransactions.", + "properties": { + "transactions": { + "allOf": [ + { + "$ref": "#/components/schemas/BankTransaction" + } + ], + "description": "BankTransaction" + } + } + }, "BankTransaction": { "type": "object", "description": "BankTransactionSerializer.",