From dbbafc284f61561d62092db595f1e9eb38b9fdd6 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 13 May 2024 09:19:36 -0300 Subject: fix v15 --- packages/taler-util/src/http-client/merchant.ts | 29 ++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'packages/taler-util/src/http-client/merchant.ts') diff --git a/packages/taler-util/src/http-client/merchant.ts b/packages/taler-util/src/http-client/merchant.ts index d682dcfa0..cad2c839e 100644 --- a/packages/taler-util/src/http-client/merchant.ts +++ b/packages/taler-util/src/http-client/merchant.ts @@ -32,6 +32,7 @@ import { codecForInventorySummaryResponse, codecForMerchantConfig, codecForMerchantOrderPrivateStatusResponse, + codecForMerchantPosProductDetail, codecForMerchantRefundResponse, codecForOrderHistory, codecForOtpDeviceDetails, @@ -122,7 +123,7 @@ export enum TalerMerchantManagementCacheEviction { * Uses libtool's current:revision:age versioning. */ export class TalerMerchantInstanceHttpClient { - public readonly PROTOCOL_VERSION = "10:0:6"; + public readonly PROTOCOL_VERSION = "15:0:0"; readonly httpLib: HttpRequestLibrary; readonly cacheEvictor: CacheEvictor; @@ -858,6 +859,32 @@ export class TalerMerchantInstanceHttpClient { } } + /** + * https://docs.taler.net/core/api-merchant.html#get-[-instances-$INSTANCE]-private-pos + */ + async getPointOfSaleInventory(token: AccessToken | undefined) { + const url = new URL(`private/pos`, this.baseUrl); + + const headers: Record = {}; + if (token) { + headers.Authorization = makeBearerTokenAuthHeader(token); + } + const resp = await this.httpLib.fetch(url.href, { + method: "GET", + headers, + }); + + switch (resp.status) { + case HttpStatusCode.Ok: + return opSuccessFromHttp(resp, codecForMerchantPosProductDetail()); + case HttpStatusCode.NotFound: + return opKnownHttpFailure(resp.status, resp); + default: + return opUnknownFailure(resp, await readTalerErrorResponse(resp)); + } + + } + /** * https://docs.taler.net/core/api-merchant.html#get-[-instances-$INSTANCE]-private-products-$PRODUCT_ID */ -- cgit v1.2.3