aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-util/src/http-client/bank-revenue.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-util/src/http-client/bank-revenue.ts')
-rw-r--r--packages/taler-util/src/http-client/bank-revenue.ts32
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