diff options
author | Sebastian <sebasjm@gmail.com> | 2023-10-14 01:19:30 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-10-14 01:19:30 -0300 |
commit | 592ecda944bf5b32e86f6c42ee8e1f17d9c86451 (patch) | |
tree | b4befbbe407f6e8c53bbf4307bcd412a918eb6c9 /packages/taler-util/src/http-client/bank-revenue.ts | |
parent | 617ab78264bb3ef200e3568bb6cf9b60ddf5687a (diff) | |
download | wallet-core-592ecda944bf5b32e86f6c42ee8e1f17d9c86451.tar.gz wallet-core-592ecda944bf5b32e86f6c42ee8e1f17d9c86451.tar.bz2 wallet-core-592ecda944bf5b32e86f6c42ee8e1f17d9c86451.zip |
complet bank api
Diffstat (limited to 'packages/taler-util/src/http-client/bank-revenue.ts')
-rw-r--r-- | packages/taler-util/src/http-client/bank-revenue.ts | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/packages/taler-util/src/http-client/bank-revenue.ts b/packages/taler-util/src/http-client/bank-revenue.ts new file mode 100644 index 000000000..99ff71457 --- /dev/null +++ b/packages/taler-util/src/http-client/bank-revenue.ts @@ -0,0 +1,32 @@ +import { HttpRequestLibrary, makeBasicAuthHeader, readSuccessResponseJsonOrThrow } from "../http-common.js"; +import { createPlatformHttpLib } from "../http.js"; +import { TalerRevenueApi, codecForMerchantIncomingHistory } from "./types.js"; +import { UserAndPassword } from "./utils.js"; + +export class TalerRevenueHttpClient { + httpLib: HttpRequestLibrary; + + constructor( + private baseUrl: string, + private username: string, + httpClient?: HttpRequestLibrary, + ) { + this.httpLib = httpClient ?? createPlatformHttpLib(); + } + + /** + * https://docs.taler.net/core/api-bank-revenue.html#get-$BASE_URL-history + * + * @returns + */ + async getHistory(auth: string): Promise<TalerRevenueApi.MerchantIncomingHistory> { + const url = new URL(`history`, this.baseUrl); + const resp = await this.httpLib.fetch(url.href, { + method: "GET", + headers: { + Authorization: makeBasicAuthHeader(this.username, auth), + } + }); + return readSuccessResponseJsonOrThrow(resp, codecForMerchantIncomingHistory()); + } +}
\ No newline at end of file |