commit abee8126c9f52b8b5b600cbf14a6bcef9ace8a25
parent d9d7af03f8e51df3b562fd8e2d11f070cf795793
Author: Antoine A <>
Date: Wed, 19 Mar 2025 15:33:12 +0100
common: add Wire Gateway Account API support and set correct API versions
Diffstat:
7 files changed, 65 insertions(+), 9 deletions(-)
diff --git a/common/taler-api/src/api/wire.rs b/common/taler-api/src/api/wire.rs
@@ -24,18 +24,18 @@ use axum::{
routing::{get, post},
};
use taler_common::{
- api_params::{History, HistoryParams, Page, TransferParams},
+ api_params::{AccountParams, History, HistoryParams, Page, TransferParams},
api_wire::{
- AddIncomingRequest, AddIncomingResponse, AddKycauthRequest, AddKycauthResponse,
- IncomingHistory, OutgoingHistory, TransferList, TransferRequest, TransferResponse,
- TransferState, TransferStatus, WireConfig,
+ AccountInfo, AddIncomingRequest, AddIncomingResponse, AddKycauthRequest,
+ AddKycauthResponse, IncomingHistory, OutgoingHistory, TransferList, TransferRequest,
+ TransferResponse, TransferState, TransferStatus, WireConfig,
},
error_code::ErrorCode,
};
use crate::{
constants::{MAX_PAGE_SIZE, MAX_TIMEOUT_MS, WIRE_GATEWAY_API_VERSION},
- error::{ApiResult, failure},
+ error::{ApiResult, failure, failure_code, failure_status},
json::Req,
};
@@ -71,6 +71,21 @@ pub trait WireGateway: TalerApi {
&self,
req: AddKycauthRequest,
) -> impl std::future::Future<Output = ApiResult<AddKycauthResponse>> + Send;
+
+ fn support_account_check(&self) -> bool;
+
+ fn account_check(
+ &self,
+ _params: AccountParams,
+ ) -> impl std::future::Future<Output = ApiResult<Option<AccountInfo>>> + Send {
+ async {
+ Err(failure_status(
+ ErrorCode::END,
+ "API not implemented",
+ StatusCode::NOT_IMPLEMENTED,
+ ))
+ }
+ }
}
pub fn router<I: WireGateway>(state: Arc<I>) -> Router {
@@ -83,6 +98,7 @@ pub fn router<I: WireGateway>(state: Arc<I>) -> Router {
version: WIRE_GATEWAY_API_VERSION,
currency: state.currency(),
implementation: state.implementation(),
+ support_account_check: state.support_account_check(),
})
.into_response()
}),
@@ -170,5 +186,16 @@ pub fn router<I: WireGateway>(state: Arc<I>) -> Router {
},
),
)
+ .route(
+ "/account/check",
+ get(
+ |State(state): State<Arc<I>>, Query(params): Query<AccountParams>| async move {
+ match state.account_check(params).await? {
+ Some(it) => Ok(Json(it)),
+ None => Err(failure_code(ErrorCode::BANK_UNKNOWN_ACCOUNT)),
+ }
+ },
+ ),
+ )
.with_state(state)
}
diff --git a/common/taler-api/src/constants.rs b/common/taler-api/src/constants.rs
@@ -14,8 +14,8 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-pub const WIRE_GATEWAY_API_VERSION: &str = "0:0:0"; // TODO update
-pub const REVENUE_API_VERSION: &str = "0:0:0"; // TODO update
+pub const WIRE_GATEWAY_API_VERSION: &str = "4:0:0";
+pub const REVENUE_API_VERSION: &str = "1:0:0";
pub const MAX_PAGE_SIZE: i64 = 1024;
pub const MAX_TIMEOUT_MS: u64 = 60 * 60 * 10; // 1H
pub const MAX_BODY_LENGTH: usize = 4 * 1024; // 4kB
diff --git a/common/taler-api/tests/api.rs b/common/taler-api/tests/api.rs
@@ -14,6 +14,7 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
+use axum::http::StatusCode;
use common::test_api;
use sqlx::PgPool;
use taler_common::{
@@ -114,3 +115,13 @@ async fn revenue() {
let (server, _) = setup().await;
revenue_routine(&server, &payto("payto://test")).await;
}
+
+#[tokio::test]
+async fn account_check() {
+ let (server, _) = setup().await;
+ server
+ .get("/taler-wire-gateway/account/check")
+ .add_query_param("account", "payto://test")
+ .await
+ .assert_status(StatusCode::NOT_IMPLEMENTED);
+}
diff --git a/common/taler-api/tests/common/mod.rs b/common/taler-api/tests/common/mod.rs
@@ -158,6 +158,10 @@ impl WireGateway for TestApi {
)),
}
}
+
+ fn support_account_check(&self) -> bool {
+ false
+ }
}
impl Revenue for TestApi {
diff --git a/common/taler-common/src/api_params.rs b/common/taler-common/src/api_params.rs
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2024 Taler Systems SA
+ Copyright (C) 2024-2025 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
@@ -17,7 +17,7 @@
use serde::Deserialize;
use serde_with::{DisplayFromStr, serde_as};
-use crate::api_wire::TransferState;
+use crate::{api_wire::TransferState, types::payto::PaytoURI};
#[derive(Debug, thiserror::Error)]
#[error("Param '{param}' {reason}")]
@@ -121,3 +121,8 @@ pub struct TransferParams {
pub pagination: PageParams,
pub status: Option<TransferState>,
}
+
+#[derive(Debug, Clone, Deserialize)]
+pub struct AccountParams {
+ pub account: PaytoURI,
+}
diff --git a/common/taler-common/src/api_wire.rs b/common/taler-common/src/api_wire.rs
@@ -30,6 +30,7 @@ pub struct WireConfig<'a> {
pub version: &'a str,
pub currency: &'a str,
pub implementation: Option<&'a str>,
+ pub support_account_check: bool
}
/// <https://docs.taler.net/core/api-bank-wire.html#tsref-type-TransferResponse>
@@ -156,6 +157,10 @@ pub struct AddKycauthRequest {
pub debit_account: PaytoURI,
}
+/// <https://docs.taler.net/core/api-bank-wire.html#tsref-type-AccountInfo>
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct AccountInfo {}
+
/// <https://docs.taler.net/core/api-bank-wire.html#tsref-type-AddKycauthResponse>
pub type AddKycauthResponse = AddIncomingResponse;
diff --git a/taler-magnet-bank/src/adapter.rs b/taler-magnet-bank/src/adapter.rs
@@ -194,6 +194,10 @@ impl WireGateway for MagnetApi {
)),
}
}
+
+ fn support_account_check(&self) -> bool {
+ false
+ }
}
impl Revenue for MagnetApi {