[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] 07/08: fixing compile errors
From: |
gnunet |
Subject: |
[taler-wallet-core] 07/08: fixing compile errors |
Date: |
Tue, 26 Mar 2024 20:58:54 +0100 |
This is an automated email from the git hooks/post-receive script.
sebasjm pushed a commit to branch master
in repository wallet-core.
commit af633723b3beae2588c55fd94630a42f27b3f2b1
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Mon Mar 25 11:07:13 2024 -0300
fixing compile errors
---
.../src/hooks/instance.test.ts | 2 +-
.../merchant-backoffice-ui/src/hooks/instance.ts | 85 ++--
.../merchant-backoffice-ui/src/hooks/order.test.ts | 22 +-
.../merchant-backoffice-ui/src/hooks/templates.ts | 28 +-
.../src/paths/admin/create/index.tsx | 7 -
.../src/paths/instance/templates/list/index.tsx | 2 +-
.../src/paths/instance/token/index.tsx | 32 +-
packages/taler-util/src/http-client/merchant.ts | 517 +++++++++++++--------
8 files changed, 409 insertions(+), 286 deletions(-)
diff --git a/packages/merchant-backoffice-ui/src/hooks/instance.test.ts
b/packages/merchant-backoffice-ui/src/hooks/instance.test.ts
index f73f07d68..35147d988 100644
--- a/packages/merchant-backoffice-ui/src/hooks/instance.test.ts
+++ b/packages/merchant-backoffice-ui/src/hooks/instance.test.ts
@@ -167,7 +167,7 @@ describe("instance api interaction with details", () => {
},
} as TalerMerchantApi.QueryInstancesResponse,
});
- api.setNewAccessToken(undefined, "secret" as AccessToken);
+ // api.setNewAccessToken(undefined, "secret" as AccessToken);
},
({ query, api }) => {
expect(env.assertJustExpectedRequestWereMade()).deep.eq({
diff --git a/packages/merchant-backoffice-ui/src/hooks/instance.ts
b/packages/merchant-backoffice-ui/src/hooks/instance.ts
index 2da82989b..5f17dbf79 100644
--- a/packages/merchant-backoffice-ui/src/hooks/instance.ts
+++ b/packages/merchant-backoffice-ui/src/hooks/instance.ts
@@ -36,10 +36,10 @@ interface InstanceAPI {
) => Promise<void>;
deleteInstance: () => Promise<void>;
clearAccessToken: (currentToken: AccessToken | undefined) => Promise<void>;
- setNewAccessToken: (
- currentToken: AccessToken | undefined,
- token: AccessToken,
- ) => Promise<void>;
+ // setNewAccessToken: (
+ // currentToken: AccessToken | undefined,
+ // token: AccessToken,
+ // ) => Promise<void>;
}
export function useAdminAPI(): AdminAPI {
@@ -127,30 +127,31 @@ export function useManagementAPI(instanceId: string):
InstanceAPI {
mutateAll(/\/management\/instances/);
};
- const setNewAccessToken = async (
- currentToken: AccessToken | undefined,
- newToken: AccessToken,
- ): Promise<void> => {
- await request(`/management/instances/${instanceId}/auth`, {
- method: "POST",
- token: currentToken,
- data: { method: "token", token: newToken },
- });
+ // const setNewAccessToken = async (
+ // currentToken: AccessToken | undefined,
+ // newToken: AccessToken,
+ // ): Promise<void> => {
- const resp = await requestNewLoginToken(backendUrl, newToken);
- if (resp.valid) {
- logIn({ token: resp.token as AccessToken });
- } else {
- logOut();
- }
+ // await request(`/management/instances/${instanceId}/auth`, {
+ // method: "POST",
+ // token: currentToken,
+ // data: { method: "token", token: newToken },
+ // });
- mutateAll(/\/management\/instances/);
- };
+ // const resp = await requestNewLoginToken(backendUrl, newToken);
+ // if (resp.valid) {
+ // logIn({ token: resp.token as AccessToken });
+ // } else {
+ // logOut();
+ // }
+
+ // mutateAll(/\/management\/instances/);
+ // };
return {
updateInstance,
deleteInstance,
- setNewAccessToken,
+ // setNewAccessToken,
clearAccessToken,
};
}
@@ -205,30 +206,30 @@ export function useInstanceAPI(): InstanceAPI {
mutate([`/private/`], null);
};
- const setNewAccessToken = async (
- currentToken: AccessToken | undefined,
- newToken: AccessToken,
- ): Promise<void> => {
- await request(`/private/auth`, {
- method: "POST",
- token: currentToken,
- data: { method: "token", token: newToken },
- });
-
- const resp = await requestNewLoginToken(backendUrl, newToken);
- if (resp.valid) {
- logIn({ token: resp.token as AccessToken });
- } else {
- logOut();
- }
-
- mutate([`/private/`], null);
- };
+ // const setNewAccessToken = async (
+ // currentToken: AccessToken | undefined,
+ // newToken: AccessToken,
+ // ): Promise<void> => {
+ // await request(`/private/auth`, {
+ // method: "POST",
+ // token: currentToken,
+ // data: { method: "token", token: newToken },
+ // });
+
+ // const resp = await requestNewLoginToken(backendUrl, newToken);
+ // if (resp.valid) {
+ // logIn({ token: resp.token as AccessToken });
+ // } else {
+ // logOut();
+ // }
+
+ // mutate([`/private/`], null);
+ // };
return {
updateInstance,
deleteInstance,
- setNewAccessToken,
+ // setNewAccessToken,
clearAccessToken,
};
}
diff --git a/packages/merchant-backoffice-ui/src/hooks/order.test.ts
b/packages/merchant-backoffice-ui/src/hooks/order.test.ts
index 08fffbcf0..0d4199875 100644
--- a/packages/merchant-backoffice-ui/src/hooks/order.test.ts
+++ b/packages/merchant-backoffice-ui/src/hooks/order.test.ts
@@ -113,11 +113,13 @@ describe("order api interaction with listing", () => {
env.addRequestExpectation(API_LIST_ORDERS, {
qparam: { delta: -20, paid: "yes" },
- response: { orders: [{
- order_id: "1",
- amount: "EUR:12",
- refundable: true,
- } as TalerMerchantApi.OrderHistoryEntry] },
+ response: {
+ orders: [{
+ order_id: "1",
+ amount: "EUR:12",
+ refundable: true,
+ } as TalerMerchantApi.OrderHistoryEntry]
+ },
});
const newDate = (d: Date) => {
@@ -161,14 +163,16 @@ describe("order api interaction with listing", () => {
env.addRequestExpectation(API_LIST_ORDERS, {
qparam: { delta: -20, paid: "yes" },
- response: { orders: [
- { order_id: "1", amount: "EUR:12", refundable: false } as any,
- ] },
+ response: {
+ orders: [
+ { order_id: "1", amount: "EUR:12", refundable: false } as any,
+ ]
+ },
});
api.refundOrder("1", {
reason: "double pay",
- refund: "EUR:1",
+ refund: "EUR:1" as AmountString,
});
},
({ query, api }) => {
diff --git a/packages/merchant-backoffice-ui/src/hooks/templates.ts
b/packages/merchant-backoffice-ui/src/hooks/templates.ts
index cdcc418ef..2e39a0c46 100644
--- a/packages/merchant-backoffice-ui/src/hooks/templates.ts
+++ b/packages/merchant-backoffice-ui/src/hooks/templates.ts
@@ -69,9 +69,9 @@ export function useTemplateAPI(): TemplateAPI {
templateId: string,
data: TalerMerchantApi.UsingTemplateDetails,
): Promise<
- HttpResponseOk<TalerMerchantApi.UsingTemplateResponse>
+ HttpResponseOk<TalerMerchantApi.PostOrderResponse>
> => {
- const res = await request<TalerMerchantApi.UsingTemplateResponse>(
+ const res = await request<TalerMerchantApi.PostOrderResponse>(
`/templates/${templateId}`,
{
method: "POST",
@@ -114,7 +114,7 @@ export interface TemplateAPI {
createOrderFromTemplate: (
id: string,
data: TalerMerchantApi.UsingTemplateDetails,
- ) => Promise<HttpResponseOk<TalerMerchantApi.UsingTemplateResponse>>;
+ ) => Promise<HttpResponseOk<TalerMerchantApi.PostOrderResponse>>;
}
export interface InstanceTemplateFilter {
@@ -190,20 +190,20 @@ export function useInstanceTemplates(
// if the query returns less that we ask, then we have reach the end or
beginning
const isReachingEnd =
- afterData && afterData.data.templates.length < totalAfter;
+ afterData && afterData.data.templates_list.length < totalAfter;
const isReachingStart = args?.position === undefined
||
- (beforeData && beforeData.data.templates.length < totalBefore);
+ (beforeData && beforeData.data.templates_list.length < totalBefore);
const pagination = {
isReachingEnd,
isReachingStart,
loadMore: () => {
if (!afterData || isReachingEnd) return;
- if (afterData.data.templates.length < MAX_RESULT_SIZE) {
+ if (afterData.data.templates_list.length < MAX_RESULT_SIZE) {
setPageAfter(pageAfter + 1);
} else {
- const from =
`${afterData.data.templates[afterData.data.templates.length - 1]
+ const from =
`${afterData.data.templates_list[afterData.data.templates_list.length - 1]
.template_id
}`;
if (from && updatePosition) updatePosition(from);
@@ -211,10 +211,10 @@ export function useInstanceTemplates(
},
loadMorePrev: () => {
if (!beforeData || isReachingStart) return;
- if (beforeData.data.templates.length < MAX_RESULT_SIZE) {
+ if (beforeData.data.templates_list.length < MAX_RESULT_SIZE) {
setPageBefore(pageBefore + 1);
} else if (beforeData) {
- const from =
`${beforeData.data.templates[beforeData.data.templates.length - 1]
+ const from =
`${beforeData.data.templates_list[beforeData.data.templates_list.length - 1]
.template_id
}`;
if (from && updatePosition) updatePosition(from);
@@ -223,17 +223,17 @@ export function useInstanceTemplates(
};
// const templates = !afterData ? [] : (afterData ||
lastAfter).data.templates;
- const templates =
+ const templates_list =
!beforeData || !afterData
? []
- : (beforeData || lastBefore).data.templates
+ : (beforeData || lastBefore).data.templates_list
.slice()
.reverse()
- .concat((afterData || lastAfter).data.templates);
+ .concat((afterData || lastAfter).data.templates_list);
if (loadingAfter || loadingBefore)
- return { loading: true, data: { templates } };
+ return { loading: true, data: { templates_list } };
if (beforeData && afterData) {
- return { ok: true, data: { templates }, ...pagination };
+ return { ok: true, data: { templates_list }, ...pagination };
}
return { loading: true };
}
diff --git a/packages/merchant-backoffice-ui/src/paths/admin/create/index.tsx
b/packages/merchant-backoffice-ui/src/paths/admin/create/index.tsx
index 99e20dcd7..3db38acc3 100644
--- a/packages/merchant-backoffice-ui/src/paths/admin/create/index.tsx
+++ b/packages/merchant-backoffice-ui/src/paths/admin/create/index.tsx
@@ -71,13 +71,6 @@ export default function Create({ onBack, onConfirm, forceId
}: Props): VNode {
const { access_token } = result.body;
logIn({ token: access_token });
}
- // const resp = await requestNewLoginToken(backendURL.href,
d.auth.token as AccessToken)
- // if (resp.valid) {
- // const { token, expiration } = resp
- // updateToken({ token, expiration });
- // } else {
- // updateToken(undefined)
- // }
}
onConfirm();
} catch (ex) {
diff --git
a/packages/merchant-backoffice-ui/src/paths/instance/templates/list/index.tsx
b/packages/merchant-backoffice-ui/src/paths/instance/templates/list/index.tsx
index 40ca6ac98..2138d24a4 100644
---
a/packages/merchant-backoffice-ui/src/paths/instance/templates/list/index.tsx
+++
b/packages/merchant-backoffice-ui/src/paths/instance/templates/list/index.tsx
@@ -92,7 +92,7 @@ export default function ListTemplates({
/>
<ListPage
- templates={result.data.templates}
+ templates={result.data.templates_list}
onLoadMoreBefore={
result.isReachingStart ? result.loadMorePrev : undefined
}
diff --git a/packages/merchant-backoffice-ui/src/paths/instance/token/index.tsx
b/packages/merchant-backoffice-ui/src/paths/instance/token/index.tsx
index 50e7d500d..889ef6f5d 100644
--- a/packages/merchant-backoffice-ui/src/paths/instance/token/index.tsx
+++ b/packages/merchant-backoffice-ui/src/paths/instance/token/index.tsx
@@ -13,8 +13,8 @@
You should have received a copy of the GNU General Public License along with
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import { HttpStatusCode, TalerErrorDetail } from "@gnu-taler/taler-util";
-import { ErrorType, HttpError, useTranslationContext } from
"@gnu-taler/web-util/browser";
+import { AccessToken, HttpStatusCode, TalerErrorDetail } from
"@gnu-taler/taler-util";
+import { ErrorType, HttpError, useMerchantApiContext, useTranslationContext }
from "@gnu-taler/web-util/browser";
import { Fragment, VNode, h } from "preact";
import { useState } from "preact/hooks";
import { Loading } from "../../../components/exception/loading.js";
@@ -22,6 +22,7 @@ import { NotificationCard } from
"../../../components/menu/index.js";
import { useInstanceAPI, useInstanceDetails } from
"../../../hooks/instance.js";
import { Notification } from "../../../utils/types.js";
import { DetailPage } from "./DetailPage.js";
+import { useSessionContext } from "../../../context/session.js";
interface Props {
onUnauthorized: () => VNode;
@@ -39,9 +40,10 @@ export default function Token({
onCancel,
}: Props): VNode {
const { i18n } = useTranslationContext();
-
+ const { lib } = useMerchantApiContext();
+ const { logIn } = useSessionContext();
const [notif, setNotif] = useState<Notification | undefined>(undefined);
- const { clearAccessToken, setNewAccessToken } = useInstanceAPI();
+ const { clearAccessToken } = useInstanceAPI();
const result = useInstanceDetails()
if (result.loading) return <Loading />;
@@ -83,8 +85,26 @@ export default function Token({
}}
onNewToken={async (currentToken, newToken): Promise<void> => {
try {
- await setNewAccessToken(currentToken, newToken);
- onChange();
+ await lib.management.updateInstanceAuthentication(currentToken, {
+ token: newToken,
+ method: "token"
+ })
+ const resp = await
lib.authenticate.createAccessTokenMerchant(newToken, {
+ scope: "write",
+ duration: {
+ d_us: "forever"
+ },
+ refreshable: true,
+ })
+ if (resp.type === "ok") {
+ logIn({ token: resp.body.token })
+ onChange();
+ } else {
+ setNotif({
+ message: i18n.str`Failed to set new token`,
+ type: "ERROR",
+ });
+ }
} catch (error) {
if (error instanceof Error) {
setNotif({
diff --git a/packages/taler-util/src/http-client/merchant.ts
b/packages/taler-util/src/http-client/merchant.ts
index 3a2b7117d..1b1a7b4a8 100644
--- a/packages/taler-util/src/http-client/merchant.ts
+++ b/packages/taler-util/src/http-client/merchant.ts
@@ -110,6 +110,7 @@ export class TalerMerchantInstanceHttpClient {
*/
async getConfig() {
const url = new URL(`config`, this.baseUrl);
+
const resp = await this.httpLib.fetch(url.href, {
method: "GET",
});
@@ -338,17 +339,19 @@ export class TalerMerchantInstanceHttpClient {
*
https://docs.taler.net/core/api-merchant.html#post-[-instances-$INSTANCE]-private-auth
*/
async updateCurrentInstanceAuthentication(
- token: AccessToken,
+ token: AccessToken | undefined,
body: TalerMerchantApi.InstanceAuthConfigurationMessage,
) {
const url = new URL(`private/auth`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "POST",
body,
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
//
@@ -366,17 +369,19 @@ export class TalerMerchantInstanceHttpClient {
*
https://docs.taler.net/core/api-merchant.html#patch-[-instances-$INSTANCE]-private
*/
async updateCurrentInstance(
- token: AccessToken,
+ token: AccessToken | undefined,
body: TalerMerchantApi.InstanceReconfigurationMessage,
) {
const url = new URL(`private`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "PATCH",
body,
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
case HttpStatusCode.Ok:
@@ -395,11 +400,13 @@ export class TalerMerchantInstanceHttpClient {
async getCurrentInstance(token: AccessToken) {
const url = new URL(`private`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "GET",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -413,18 +420,20 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#delete-[-instances-$INSTANCE]-private
*/
- async deleteCurrentInstance(token: AccessToken, params: { purge?: boolean })
{
+ async deleteCurrentInstance(token: AccessToken | undefined, params: {
purge?: boolean }) {
const url = new URL(`private`, this.baseUrl);
if (params.purge) {
url.searchParams.set("purge", "YES");
}
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "DELETE",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -445,7 +454,7 @@ export class TalerMerchantInstanceHttpClient {
*
https://docs.taler.net/core/api-merchant.html#get--instances-$INSTANCE-private-kyc
*/
async getCurrentIntanceKycStatus(
- token: AccessToken,
+ token: AccessToken | undefined,
params: TalerMerchantApi.GetKycStatusRequestParams,
) {
const url = new URL(`private/kyc`, this.baseUrl);
@@ -460,11 +469,13 @@ export class TalerMerchantInstanceHttpClient {
url.searchParams.set("timeout_ms", String(params.timeout));
}
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "GET",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -490,15 +501,17 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#post-[-instances-$INSTANCE]-private-accounts
*/
- async addAccount(token: AccessToken,body:
TalerMerchantApi.AccountAddDetails) {
+ async addAccount(token: AccessToken | undefined, body:
TalerMerchantApi.AccountAddDetails) {
const url = new URL(`private/accounts`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "POST",
body,
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -517,18 +530,20 @@ export class TalerMerchantInstanceHttpClient {
*
https://docs.taler.net/core/api-merchant.html#patch-[-instances-$INSTANCE]-private-accounts-$H_WIRE
*/
async updateAccount(
- token: AccessToken,
+ token: AccessToken | undefined,
wireAccount: string,
body: TalerMerchantApi.AccountPatchDetails,
) {
const url = new URL(`private/accounts/${wireAccount}`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "PATCH",
body,
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
case HttpStatusCode.NoContent:
@@ -546,11 +561,13 @@ export class TalerMerchantInstanceHttpClient {
async listAccounts(token: AccessToken) {
const url = new URL(`private/accounts`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "GET",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -566,14 +583,16 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#get-[-instances-$INSTANCE]-private-accounts-$H_WIRE
*/
- async getAccount(token: AccessToken,wireAccount: string) {
+ async getAccount(token: AccessToken | undefined, wireAccount: string) {
const url = new URL(`private/accounts/${wireAccount}`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "GET",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- },
+ headers,
});
switch (resp.status) {
@@ -589,14 +608,16 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#delete-[-instances-$INSTANCE]-private-accounts-$H_WIRE
*/
- async deleteAccount(token: AccessToken,wireAccount: string) {
+ async deleteAccount(token: AccessToken | undefined, wireAccount: string) {
const url = new URL(`private/accounts/${wireAccount}`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "DELETE",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- },
+ headers,
});
switch (resp.status) {
@@ -616,15 +637,17 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#post-[-instances-$INSTANCE]-private-products
*/
- async addProduct(token: AccessToken,body: TalerMerchantApi.ProductAddDetail)
{
+ async addProduct(token: AccessToken | undefined, body:
TalerMerchantApi.ProductAddDetail) {
const url = new URL(`private/products`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "POST",
body,
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -641,18 +664,20 @@ export class TalerMerchantInstanceHttpClient {
*
https://docs.taler.net/core/api-merchant.html#patch-[-instances-$INSTANCE]-private-products-$PRODUCT_ID
*/
async updateProduct(
- token: AccessToken,
+ token: AccessToken | undefined,
productId: string,
body: TalerMerchantApi.ProductAddDetail,
) {
const url = new URL(`private/products/${productId}`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "PATCH",
body,
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -670,16 +695,18 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#get-[-instances-$INSTANCE]-private-products
*/
- async listProducts(token: AccessToken,params?: PaginationParams) {
+ async listProducts(token: AccessToken | undefined, params?:
PaginationParams) {
const url = new URL(`private/products`, this.baseUrl);
addMerchantPaginationParams(url, params);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "GET",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -695,14 +722,16 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#get-[-instances-$INSTANCE]-private-products-$PRODUCT_ID
*/
- async getProduct(token: AccessToken,productId: string) {
+ async getProduct(token: AccessToken | undefined, productId: string) {
const url = new URL(`private/products/${productId}`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "GET",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -718,15 +747,17 @@ export class TalerMerchantInstanceHttpClient {
/**
* https://docs.taler.net/core/api-merchant.html#reserving-inventory
*/
- async lockProduct(token: AccessToken, productId: string, body:
TalerMerchantApi.LockRequest) {
+ async lockProduct(token: AccessToken | undefined, productId: string, body:
TalerMerchantApi.LockRequest) {
const url = new URL(`private/products/${productId}/lock`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "POST",
body,
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -744,14 +775,16 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#removing-products-from-inventory
*/
- async removeProduct(token: AccessToken,productId: string) {
+ async removeProduct(token: AccessToken | undefined, productId: string) {
const url = new URL(`private/products/${productId}`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "DELETE",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -773,15 +806,17 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#post-[-instances-$INSTANCE]-private-orders
*/
- async createOrder(token: AccessToken,body:
TalerMerchantApi.PostOrderRequest) {
+ async createOrder(token: AccessToken | undefined, body:
TalerMerchantApi.PostOrderRequest) {
const url = new URL(`private/orders`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "POST",
body,
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
return this.procesOrderCreationResponse(resp)
}
@@ -810,7 +845,7 @@ export class TalerMerchantInstanceHttpClient {
/**
* https://docs.taler.net/core/api-merchant.html#inspecting-orders
*/
- async listOrders(token: AccessToken,params:
TalerMerchantApi.ListOrdersRequestParams = {}) {
+ async listOrders(token: AccessToken | undefined, params:
TalerMerchantApi.ListOrdersRequestParams = {}) {
const url = new URL(`private/orders`, this.baseUrl);
if (params.date) {
@@ -836,11 +871,13 @@ export class TalerMerchantInstanceHttpClient {
}
addMerchantPaginationParams(url, params);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "GET",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -855,7 +892,7 @@ export class TalerMerchantInstanceHttpClient {
*
https://docs.taler.net/core/api-merchant.html#get-[-instances-$INSTANCE]-private-orders-$ORDER_ID
*/
async getOrder(
- token: AccessToken,
+ token: AccessToken | undefined,
orderId: string,
params: TalerMerchantApi.GetOrderRequestParams = {},
) {
@@ -871,11 +908,13 @@ export class TalerMerchantInstanceHttpClient {
url.searchParams.set("timeout_ms", String(params.timeout));
}
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "GET",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -902,15 +941,17 @@ export class TalerMerchantInstanceHttpClient {
/**
* https://docs.taler.net/core/api-merchant.html#private-order-data-cleanup
*/
- async forgetOrder(token: AccessToken,orderId: string, body:
TalerMerchantApi.ForgetRequest) {
+ async forgetOrder(token: AccessToken | undefined, orderId: string, body:
TalerMerchantApi.ForgetRequest) {
const url = new URL(`private/orders/${orderId}/forget`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "PATCH",
body,
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -932,14 +973,16 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#delete-[-instances-$INSTANCE]-private-orders-$ORDER_ID
*/
- async deleteOrder(token: AccessToken,orderId: string) {
+ async deleteOrder(token: AccessToken | undefined, orderId: string) {
const url = new URL(`private/orders/${orderId}`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "DELETE",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -961,15 +1004,17 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#post-[-instances-$INSTANCE]-private-orders-$ORDER_ID-refund
*/
- async addRefund(token: AccessToken,orderId: string, body:
TalerMerchantApi.RefundRequest) {
+ async addRefund(token: AccessToken | undefined, orderId: string, body:
TalerMerchantApi.RefundRequest) {
const url = new URL(`private/orders/${orderId}/refund`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "POST",
body,
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -995,15 +1040,17 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#post-[-instances-$INSTANCE]-private-transfers
*/
- async informWireTransfer(token: AccessToken,body:
TalerMerchantApi.TransferInformation) {
+ async informWireTransfer(token: AccessToken | undefined, body:
TalerMerchantApi.TransferInformation) {
const url = new URL(`private/transfers`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "POST",
body,
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -1022,7 +1069,7 @@ export class TalerMerchantInstanceHttpClient {
*
https://docs.taler.net/core/api-merchant.html#get-[-instances-$INSTANCE]-private-transfers
*/
async listWireTransfers(
- token: AccessToken,
+ token: AccessToken | undefined,
params: TalerMerchantApi.ListWireTransferRequestParams = {},
) {
const url = new URL(`private/transfers`, this.baseUrl);
@@ -1041,11 +1088,13 @@ export class TalerMerchantInstanceHttpClient {
}
addMerchantPaginationParams(url, params);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "GET",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -1059,14 +1108,16 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#delete-[-instances-$INSTANCE]-private-transfers-$TID
*/
- async deleteWireTransfer(token: AccessToken,transferId: string) {
+ async deleteWireTransfer(token: AccessToken | undefined, transferId: string)
{
const url = new URL(`private/transfers/${transferId}`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "DELETE",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -1088,15 +1139,17 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#post-[-instances-$INSTANCE]-private-otp-devices
*/
- async addOtpDevice(token: AccessToken,body:
TalerMerchantApi.OtpDeviceAddDetails) {
+ async addOtpDevice(token: AccessToken | undefined, body:
TalerMerchantApi.OtpDeviceAddDetails) {
const url = new URL(`private/otp-devices`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "POST",
body,
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -1113,18 +1166,20 @@ export class TalerMerchantInstanceHttpClient {
*
https://docs.taler.net/core/api-merchant.html#patch-[-instances-$INSTANCE]-private-otp-devices-$DEVICE_ID
*/
async updateOtpDevice(
- token: AccessToken,
+ token: AccessToken | undefined,
deviceId: string,
body: TalerMerchantApi.OtpDevicePatchDetails,
) {
const url = new URL(`private/otp-devices/${deviceId}`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "PATCH",
body,
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
case HttpStatusCode.NoContent:
@@ -1141,14 +1196,16 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#get-[-instances-$INSTANCE]-private-otp-devices
*/
- async listOtpDevices(token: AccessToken,) {
+ async listOtpDevices(token: AccessToken | undefined,) {
const url = new URL(`private/otp-devices`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "GET",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
case HttpStatusCode.Ok:
@@ -1164,7 +1221,7 @@ export class TalerMerchantInstanceHttpClient {
*
https://docs.taler.net/core/api-merchant.html#get-[-instances-$INSTANCE]-private-otp-devices-$DEVICE_ID
*/
async getOtpDevice(
- token: AccessToken,
+ token: AccessToken | undefined,
deviceId: string,
params: TalerMerchantApi.GetOtpDeviceRequestParams = {},
) {
@@ -1176,11 +1233,13 @@ export class TalerMerchantInstanceHttpClient {
if (params.price) {
url.searchParams.set("price", params.price);
}
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "GET",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -1196,14 +1255,16 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#delete-[-instances-$INSTANCE]-private-otp-devices-$DEVICE_ID
*/
- async deleteOtpDevice(token: AccessToken,deviceId: string) {
+ async deleteOtpDevice(token: AccessToken | undefined, deviceId: string) {
const url = new URL(`private/otp-devices/${deviceId}`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "DELETE",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
case HttpStatusCode.NoContent:
@@ -1222,15 +1283,17 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#post-[-instances-$INSTANCE]-private-templates
*/
- async addTemplate(token: AccessToken,body:
TalerMerchantApi.TemplateAddDetails) {
+ async addTemplate(token: AccessToken | undefined, body:
TalerMerchantApi.TemplateAddDetails) {
const url = new URL(`private/templates`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "POST",
body,
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
case HttpStatusCode.NoContent:
@@ -1246,18 +1309,20 @@ export class TalerMerchantInstanceHttpClient {
*
https://docs.taler.net/core/api-merchant.html#patch-[-instances-$INSTANCE]-private-templates-$TEMPLATE_ID
*/
async updateTemplate(
- token: AccessToken,
+ token: AccessToken | undefined,
templateId: string,
body: TalerMerchantApi.TemplatePatchDetails,
) {
const url = new URL(`private/templates/${templateId}`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "PATCH",
body,
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
case HttpStatusCode.NoContent:
@@ -1274,14 +1339,16 @@ export class TalerMerchantInstanceHttpClient {
/**
* https://docs.taler.net/core/api-merchant.html#inspecting-template
*/
- async listTemplates(token: AccessToken,) {
+ async listTemplates(token: AccessToken | undefined,) {
const url = new URL(`private/templates`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "GET",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
case HttpStatusCode.Ok:
@@ -1296,14 +1363,16 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#get-[-instances-$INSTANCE]-private-templates-$TEMPLATE_ID
*/
- async getTemplate(token: AccessToken,templateId: string) {
+ async getTemplate(token: AccessToken | undefined, templateId: string) {
const url = new URL(`private/templates/${templateId}`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "GET",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
case HttpStatusCode.Ok:
@@ -1318,14 +1387,16 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#delete-[-instances-$INSTANCE]-private-templates-$TEMPLATE_ID
*/
- async deleteTemplate(token: AccessToken,templateId: string) {
+ async deleteTemplate(token: AccessToken | undefined, templateId: string) {
const url = new URL(`private/templates/${templateId}`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "DELETE",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
case HttpStatusCode.NoContent:
@@ -1380,15 +1451,17 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#post-[-instances-$INSTANCES]-private-webhooks
*/
- async addWebhook(token: AccessToken,body:
TalerMerchantApi.WebhookAddDetails) {
+ async addWebhook(token: AccessToken | undefined, body:
TalerMerchantApi.WebhookAddDetails) {
const url = new URL(`private/webhooks`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "POST",
body,
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -1405,18 +1478,20 @@ export class TalerMerchantInstanceHttpClient {
*
https://docs.taler.net/core/api-merchant.html#patch-[-instances-$INSTANCES]-private-webhooks-$WEBHOOK_ID
*/
async updateWebhook(
- token: AccessToken,
+ token: AccessToken | undefined,
webhookId: string,
body: TalerMerchantApi.WebhookPatchDetails,
) {
const url = new URL(`private/webhooks/${webhookId}`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "PATCH",
body,
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -1434,14 +1509,16 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#get-[-instances-$INSTANCES]-private-webhooks
*/
- async listWebhooks(token: AccessToken,) {
+ async listWebhooks(token: AccessToken | undefined,) {
const url = new URL(`private/webhooks`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "GET",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -1457,14 +1534,16 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#get-[-instances-$INSTANCES]-private-webhooks-$WEBHOOK_ID
*/
- async getWebhook(token: AccessToken,webhookId: string) {
+ async getWebhook(token: AccessToken | undefined, webhookId: string) {
const url = new URL(`private/webhooks/${webhookId}`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "GET",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
case HttpStatusCode.NoContent:
@@ -1479,14 +1558,16 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#delete-[-instances-$INSTANCES]-private-webhooks-$WEBHOOK_ID
*/
- async removeWebhook(token: AccessToken,webhookId: string) {
+ async removeWebhook(token: AccessToken | undefined, webhookId: string) {
const url = new URL(`private/webhooks/${webhookId}`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "DELETE",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
case HttpStatusCode.NoContent:
@@ -1505,15 +1586,17 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#post-[-instances-$INSTANCES]-private-tokenfamilies
*/
- async createTokenFamily(token: AccessToken,body:
TalerMerchantApi.TokenFamilyCreateRequest) {
+ async createTokenFamily(token: AccessToken | undefined, body:
TalerMerchantApi.TokenFamilyCreateRequest) {
const url = new URL(`private/tokenfamilies`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "POST",
body,
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -1530,18 +1613,20 @@ export class TalerMerchantInstanceHttpClient {
*
https://docs.taler.net/core/api-merchant.html#patch-[-instances-$INSTANCES]-private-tokenfamilies-$TOKEN_FAMILY_SLUG
*/
async updateTokenFamily(
- token: AccessToken,
+ token: AccessToken | undefined,
tokenSlug: string,
body: TalerMerchantApi.TokenFamilyUpdateRequest,
) {
const url = new URL(`private/tokenfamilies/${tokenSlug}`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "POST",
body,
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
case HttpStatusCode.Ok:
@@ -1556,14 +1641,16 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#get-[-instances-$INSTANCES]-private-tokenfamilies
*/
- async listTokenFamilies(token: AccessToken,) {
+ async listTokenFamilies(token: AccessToken | undefined,) {
const url = new URL(`private/tokenfamilies`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "GET",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -1579,14 +1666,16 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#get-[-instances-$INSTANCES]-private-tokenfamilies-$TOKEN_FAMILY_SLUG
*/
- async getTokenFamily(token: AccessToken,tokenSlug: string) {
+ async getTokenFamily(token: AccessToken | undefined, tokenSlug: string) {
const url = new URL(`private/tokenfamilies/${tokenSlug}`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "GET",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -1602,14 +1691,16 @@ export class TalerMerchantInstanceHttpClient {
/**
*
https://docs.taler.net/core/api-merchant.html#delete-[-instances-$INSTANCES]-private-tokenfamilies-$TOKEN_FAMILY_SLUG
*/
- async deleteTokenFamily(token: AccessToken,tokenSlug: string) {
+ async deleteTokenFamily(token: AccessToken | undefined, tokenSlug: string) {
const url = new URL(`private/tokenfamilies/${tokenSlug}`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "DELETE",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
case HttpStatusCode.NoContent:
@@ -1656,15 +1747,17 @@ export class TalerMerchantManagementHttpClient extends
TalerMerchantInstanceHttp
/**
* https://docs.taler.net/core/api-merchant.html#post--management-instances
*/
- async createInstance(token: AccessToken,body:
TalerMerchantApi.InstanceConfigurationMessage) {
+ async createInstance(token: AccessToken | undefined, body:
TalerMerchantApi.InstanceConfigurationMessage) {
const url = new URL(`management/instances`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "POST",
body,
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
@@ -1684,17 +1777,19 @@ export class TalerMerchantManagementHttpClient extends
TalerMerchantInstanceHttp
*
https://docs.taler.net/core/api-merchant.html#post--management-instances-$INSTANCE-auth
*/
async updateInstanceAuthentication(
- token: AccessToken,
+ token: AccessToken | undefined,
body: TalerMerchantApi.InstanceAuthConfigurationMessage,
) {
const url = new URL(`management/instances`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "POST",
body,
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -1711,18 +1806,20 @@ export class TalerMerchantManagementHttpClient extends
TalerMerchantInstanceHttp
*
https://docs.taler.net/core/api-merchant.html#patch--management-instances-$INSTANCE
*/
async updateInstance(
- token: AccessToken,
+ token: AccessToken | undefined,
instanceId: string,
body: TalerMerchantApi.InstanceReconfigurationMessage,
) {
const url = new URL(`management/instances/${instanceId}`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "PATCH",
body,
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
case HttpStatusCode.NoContent:
@@ -1737,14 +1834,16 @@ export class TalerMerchantManagementHttpClient extends
TalerMerchantInstanceHttp
/**
* https://docs.taler.net/core/api-merchant.html#get--management-instances
*/
- async listInstances(token: AccessToken,) {
+ async listInstances(token: AccessToken | undefined,) {
const url = new URL(`management/instances`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "GET",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -1759,14 +1858,16 @@ export class TalerMerchantManagementHttpClient extends
TalerMerchantInstanceHttp
*
https://docs.taler.net/core/api-merchant.html#get--management-instances-$INSTANCE
*
*/
- async getInstance(token: AccessToken,instanceId: string) {
+ async getInstance(token: AccessToken | undefined, instanceId: string) {
const url = new URL(`management/instances/${instanceId}`, this.baseUrl);
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "GET",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
@@ -1780,18 +1881,20 @@ export class TalerMerchantManagementHttpClient extends
TalerMerchantInstanceHttp
/**
*
https://docs.taler.net/core/api-merchant.html#delete--management-instances-$INSTANCE
*/
- async deleteInstance(token: AccessToken,instanceId: string, params: {
purge?: boolean } = {}) {
+ async deleteInstance(token: AccessToken | undefined, instanceId: string,
params: { purge?: boolean } = {}) {
const url = new URL(`management/instances/${instanceId}`, this.baseUrl);
if (params.purge) {
url.searchParams.set("purge", "YES");
}
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "DELETE",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
case HttpStatusCode.NoContent:
@@ -1811,7 +1914,7 @@ export class TalerMerchantManagementHttpClient extends
TalerMerchantInstanceHttp
*
https://docs.taler.net/core/api-merchant.html#get--management-instances-$INSTANCE-kyc
*/
async getIntanceKycStatus(
- token: AccessToken,
+ token: AccessToken | undefined,
instanceId: string,
params: TalerMerchantApi.GetKycStatusRequestParams,
) {
@@ -1827,11 +1930,13 @@ export class TalerMerchantManagementHttpClient extends
TalerMerchantInstanceHttp
url.searchParams.set("timeout_ms", String(params.timeout));
}
+ const headers: Record<string, string> = {}
+ if (token) {
+ headers.Authorization = makeBearerTokenAuthHeader(token)
+ }
const resp = await this.httpLib.fetch(url.href, {
method: "GET",
- headers: {
- Authorization: makeBearerTokenAuthHeader(token),
- }
+ headers,
});
switch (resp.status) {
case HttpStatusCode.Accepted:
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-wallet-core] branch master updated (5a1f528d8 -> dd5aa2145), gnunet, 2024/03/26
- [taler-wallet-core] 03/08: wip, gnunet, 2024/03/26
- [taler-wallet-core] 02/08: wip, gnunet, 2024/03/26
- [taler-wallet-core] 05/08: work in progress, new api being used. merchant now should move into using the full API, gnunet, 2024/03/26
- [taler-wallet-core] 06/08: wip, doesn't compile. now merchant doesn't have it's own definition of types... it uses the one defined by taler-util, gnunet, 2024/03/26
- [taler-wallet-core] 04/08: how to do a prebuilt, gnunet, 2024/03/26
- [taler-wallet-core] 01/08: wip, gnunet, 2024/03/26
- [taler-wallet-core] 08/08: fix #8660, gnunet, 2024/03/26
- [taler-wallet-core] 07/08: fixing compile errors,
gnunet <=