diff options
author | Florian Dold <florian@dold.me> | 2023-02-23 00:52:10 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-02-23 00:52:17 +0100 |
commit | 7985b0a33ffc3e258da5d73f4056384c38e626fe (patch) | |
tree | 68908cb8ac2d49551f22bb4745bdf541156b8be5 /packages/taler-harness/src/harness/harness.ts | |
parent | 7879efcff70ea73935e139f4522aedadfe755c04 (diff) | |
download | wallet-core-7985b0a33ffc3e258da5d73f4056384c38e626fe.tar.xz |
taler-harness: deployment tooling for tipping
Diffstat (limited to 'packages/taler-harness/src/harness/harness.ts')
-rw-r--r-- | packages/taler-harness/src/harness/harness.ts | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/packages/taler-harness/src/harness/harness.ts b/packages/taler-harness/src/harness/harness.ts index 6168ea0b7..5733e776b 100644 --- a/packages/taler-harness/src/harness/harness.ts +++ b/packages/taler-harness/src/harness/harness.ts @@ -1436,12 +1436,20 @@ export interface MerchantServiceInterface { readonly name: string; } +export interface DeleteTippingReserveArgs { + reservePub: string; + purge?: boolean; +} + export class MerchantApiClient { constructor( private baseUrl: string, public readonly auth: MerchantAuthConfiguration, ) {} + // FIXME: Migrate everything to this in favor of axios + http = createPlatformHttpLib(); + async changeAuth(auth: MerchantAuthConfiguration): Promise<void> { const url = new URL("private/auth", this.baseUrl); await axios.post(url.href, auth, { @@ -1449,6 +1457,51 @@ export class MerchantApiClient { }); } + async deleteTippingReserve(req: DeleteTippingReserveArgs): Promise<void> { + const url = new URL(`private/reserves/${req.reservePub}`, this.baseUrl); + if (req.purge) { + url.searchParams.set("purge", "YES"); + } + const resp = await axios.delete(url.href, { + headers: this.makeAuthHeader(), + }); + logger.info(`delete status: ${resp.status}`); + return; + } + + async createTippingReserve( + req: CreateMerchantTippingReserveRequest, + ): Promise<CreateMerchantTippingReserveConfirmation> { + const url = new URL("private/reserves", this.baseUrl); + const resp = await axios.post(url.href, req, { + headers: this.makeAuthHeader(), + }); + // FIXME: validate + return resp.data; + } + + async getPrivateInstanceInfo(): Promise<any> { + console.log(this.makeAuthHeader()); + const url = new URL("private", this.baseUrl); + logger.info(`request url ${url.href}`); + const resp = await this.http.fetch(url.href, { + method: "GET", + headers: this.makeAuthHeader(), + }); + return await resp.json(); + } + + async getPrivateTipReserves(): Promise<TippingReserveStatus> { + console.log(this.makeAuthHeader()); + const url = new URL("private/reserves", this.baseUrl); + const resp = await this.http.fetch(url.href, { + method: "GET", + headers: this.makeAuthHeader(), + }); + // FIXME: Validate! + return await resp.json(); + } + async deleteInstance(instanceId: string) { const url = new URL(`management/instances/${instanceId}`, this.baseUrl); await axios.delete(url.href, { @@ -1578,6 +1631,7 @@ export namespace MerchantPrivateApi { `private/reserves`, merchantService.makeInstanceBaseUrl(instance), ); + // FIXME: Don't use axios! const resp = await axios.post(reqUrl.href, req); // FIXME: validate return resp.data; |