aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/bank-api-client.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-04-22 22:17:08 +0200
committerFlorian Dold <florian@dold.me>2023-04-22 22:17:08 +0200
commit321252040efdb0712a38b3488297a7a802c5cb59 (patch)
tree0ef4933afe3e8502246183a2e5bcf8c9a1e7c909 /packages/taler-wallet-core/src/bank-api-client.ts
parent15a1b8d0966783033947588cdb27850fe6811405 (diff)
downloadwallet-core-321252040efdb0712a38b3488297a7a802c5cb59.tar.xz
-fix test-exchange-deposit
Diffstat (limited to 'packages/taler-wallet-core/src/bank-api-client.ts')
-rw-r--r--packages/taler-wallet-core/src/bank-api-client.ts77
1 files changed, 46 insertions, 31 deletions
diff --git a/packages/taler-wallet-core/src/bank-api-client.ts b/packages/taler-wallet-core/src/bank-api-client.ts
index 33f12172b..94ca2271b 100644
--- a/packages/taler-wallet-core/src/bank-api-client.ts
+++ b/packages/taler-wallet-core/src/bank-api-client.ts
@@ -37,6 +37,7 @@ import {
TalerErrorCode,
} from "@gnu-taler/taler-util";
import {
+ checkSuccessResponseOrThrow,
createPlatformHttpLib,
HttpRequestLibrary,
readSuccessResponseJsonOrThrow,
@@ -97,6 +98,9 @@ const codecForWithdrawalOperationInfo = (): Codec<WithdrawalOperationInfo> =>
.property("taler_withdraw_uri", codecForString())
.build("WithdrawalOperationInfo");
+/**
+ * @deprecated Use BankAccessApiClient or WireGatewayApi
+ */
export namespace BankApi {
// FIXME: Move to BankAccessApi?!
export async function registerAccount(
@@ -142,37 +146,6 @@ export namespace BankApi {
return await registerAccount(bank, username, password);
}
- export async function adminAddIncoming(
- bank: BankServiceHandle,
- params: {
- exchangeBankAccount: HarnessExchangeBankAccount;
- amount: string;
- reservePub: string;
- debitAccountPayto: string;
- },
- ) {
- let url = new URL(
- `taler-wire-gateway/${params.exchangeBankAccount.accountName}/admin/add-incoming`,
- bank.bankAccessApiBaseUrl,
- );
- await bank.http.postJson(
- url.href,
- {
- amount: params.amount,
- reserve_pub: params.reservePub,
- debit_account: params.debitAccountPayto,
- },
- {
- headers: {
- Authorization: makeBasicAuthHeader(
- params.exchangeBankAccount.accountName,
- params.exchangeBankAccount.accountPassword,
- ),
- },
- },
- );
- }
-
export async function confirmWithdrawalOperation(
bank: BankServiceHandle,
bankUser: BankUser,
@@ -227,6 +200,9 @@ export namespace BankApi {
}
}
+/**
+ * @deprecated use BankAccessApiClient
+ */
export namespace BankAccessApi {
export async function getAccountBalance(
bank: BankServiceHandle,
@@ -288,6 +264,45 @@ export interface BankAccessApiCreateTransactionRequest {
paytoUri: string;
}
+export class WireGatewayApiClientArgs {
+ accountName: string;
+ accountPassword: string;
+ wireGatewayApiBaseUrl: string;
+}
+
+export class WireGatewayApiClient {
+ httpLib = createPlatformHttpLib();
+
+ constructor(private args: WireGatewayApiClientArgs) {}
+
+ async adminAddIncoming(params: {
+ amount: string;
+ reservePub: string;
+ debitAccountPayto: string;
+ }): Promise<void> {
+ let url = new URL(
+ `admin/add-incoming`,
+ this.args.wireGatewayApiBaseUrl,
+ );
+ const resp = await this.httpLib.fetch(url.href, {
+ method: "POST",
+ body: {
+ amount: params.amount,
+ reserve_pub: params.reservePub,
+ debit_account: params.debitAccountPayto,
+ },
+ headers: {
+ Authorization: makeBasicAuthHeader(
+ this.args.accountName,
+ this.args.accountPassword,
+ ),
+ },
+ });
+ logger.info(`add-incoming response status: ${resp.status}`);
+ await checkSuccessResponseOrThrow(resp);
+ }
+}
+
export class BankAccessApiClient {
httpLib = createPlatformHttpLib();