diff options
Diffstat (limited to 'packages/taler-util/src')
-rw-r--r-- | packages/taler-util/src/http-client/bank-revenue.ts | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/packages/taler-util/src/http-client/bank-revenue.ts b/packages/taler-util/src/http-client/bank-revenue.ts index b195e8c8f..34afe7d86 100644 --- a/packages/taler-util/src/http-client/bank-revenue.ts +++ b/packages/taler-util/src/http-client/bank-revenue.ts @@ -44,6 +44,10 @@ export type TalerBankRevenueErrorsByMethod< prop extends keyof TalerRevenueHttpClient, > = FailCasesByMethod<TalerRevenueHttpClient, prop>; +type UsernameAndPassword = { + username: string; + password: string; +}; /** * The API is used by the merchant (or other parties) to query * for incoming transactions to their account. @@ -69,33 +73,34 @@ export class TalerRevenueHttpClient { * https://docs.taler.net/core/api-bank-revenue.html#get--config * */ - async getConfig() { + async getConfig(auth?: UsernameAndPassword) { const url = new URL(`config`, this.baseUrl); const resp = await this.httpLib.fetch(url.href, { method: "GET", + headers: { + Authorization: auth + ? makeBasicAuthHeader(auth.username, auth.password) + : undefined, + }, }); switch (resp.status) { case HttpStatusCode.Ok: return opSuccessFromHttp(resp, codecForRevenueConfig()); + case HttpStatusCode.Unauthorized: + return opKnownHttpFailure(resp.status, resp); case HttpStatusCode.NotFound: return opKnownHttpFailure(resp.status, resp); default: return opUnknownFailure(resp, await readTalerErrorResponse(resp)); } } - /** * https://docs.taler.net/core/api-bank-revenue.html#get--history * * @returns */ async getHistory( - auth: - | { - username: string; - password: string; - } - | undefined, + auth?: UsernameAndPassword, params?: PaginationParams & LongPollParams, ) { const url = new URL(`history`, this.baseUrl); |