diff options
author | Özgür Kesim <oec-taler@kesim.org> | 2023-10-17 12:04:44 +0200 |
---|---|---|
committer | Özgür Kesim <oec-taler@kesim.org> | 2023-10-17 12:04:44 +0200 |
commit | fba664f9a3c35dfeb5bc5ac28f0baea09ff9b8a0 (patch) | |
tree | 6d069afdecade1b13914f4d13020d0331c2f4036 /packages/taler-util/src/http-client/bank-revenue.ts | |
parent | def5ecda6fc4015417779af0a829d3f8aad4dd83 (diff) | |
parent | aca3bc9423f15354913d0114cafbd4bd1782d801 (diff) |
Merge branch 'master' into age-withdrawHEADage-withdraw
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 |