aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-util/src/http-client
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-05-16 13:19:17 +0200
committerFlorian Dold <florian@dold.me>2024-05-16 13:19:23 +0200
commitf0decd3521440d6119ad9333949ce67653d8b2c2 (patch)
tree7e14203552b811448136802fb00eeccadc04071e /packages/taler-util/src/http-client
parent98c188c1b14f73a6b81f41a0cacd6195bb53208e (diff)
downloadwallet-core-f0decd3521440d6119ad9333949ce67653d8b2c2.tar.xz
wallet-core: query templates, refactor API declarations
Diffstat (limited to 'packages/taler-util/src/http-client')
-rw-r--r--packages/taler-util/src/http-client/types.ts96
1 files changed, 87 insertions, 9 deletions
diff --git a/packages/taler-util/src/http-client/types.ts b/packages/taler-util/src/http-client/types.ts
index fe8a2ff51..dd95709f9 100644
--- a/packages/taler-util/src/http-client/types.ts
+++ b/packages/taler-util/src/http-client/types.ts
@@ -1,4 +1,3 @@
-import { deprecate } from "util";
import { codecForAmountString } from "../amounts.js";
import {
Codec,
@@ -18,7 +17,9 @@ import {
import { PaytoString, codecForPaytoString } from "../payto.js";
import {
AmountString,
+ ExchangeWireAccount,
InternationalizedString,
+ codecForExchangeWireAccount,
codecForInternationalizedString,
codecForLocation,
} from "../taler-types.js";
@@ -27,7 +28,6 @@ import {
AbsoluteTime,
TalerProtocolDuration,
TalerProtocolTimestamp,
- codecForAbsoluteTime,
codecForDuration,
codecForTimestamp,
} from "../time.js";
@@ -925,7 +925,6 @@ export const codecForTemplateContractDetailsDefaults =
.property("currency", codecOptional(codecForString()))
.property("amount", codecOptional(codecForAmountString()))
.property("minimum_age", codecOptional(codecForNumber()))
- .property("pay_duration", codecOptional(codecForDuration))
.build("TalerMerchantApi.TemplateContractDetailsDefaults");
export const codecForWalletTemplateDetails =
@@ -1618,6 +1617,21 @@ export const codecForChallengerInfoResponse =
.property("expires", codecForTimestamp)
.build("ChallengerApi.ChallengerInfoResponse");
+export const codecForTemplateEditableDetails =
+ (): Codec<TalerMerchantApi.TemplateEditableDetails> =>
+ buildCodecForObject<TalerMerchantApi.TemplateEditableDetails>()
+ .property("summary", codecOptional(codecForString()))
+ .property("currency", codecOptional(codecForString()))
+ .property("amount", codecOptional(codecForAmountString()))
+ .build("TemplateEditableDetails");
+
+export const codecForMerchantReserveCreateConfirmation =
+ (): Codec<TalerMerchantApi.MerchantReserveCreateConfirmation> =>
+ buildCodecForObject<TalerMerchantApi.MerchantReserveCreateConfirmation>()
+ .property("accounts", codecForList(codecForExchangeWireAccount()))
+ .property("reserve_pub", codecForString())
+ .build("MerchantReserveCreateConfirmation");
+
type EmailAddress = string;
type PhoneNumber = string;
type EddsaSignature = string;
@@ -4258,9 +4272,9 @@ export namespace TalerMerchantApi {
otp_id?: string;
}
- type Order = MinimalOrderDetail | ContractTerms;
+ export type Order = MinimalOrderDetail & Partial<ContractTerms>;
- interface MinimalOrderDetail {
+ export interface MinimalOrderDetail {
// Amount to be paid by the customer.
amount: AmountString;
@@ -4279,7 +4293,7 @@ export namespace TalerMerchantApi {
fulfillment_message?: string;
}
- interface MinimalInventoryProduct {
+ export interface MinimalInventoryProduct {
// Which product is requested (here mandatory!).
product_id: string;
@@ -4719,12 +4733,14 @@ export namespace TalerMerchantApi {
currency?: string;
- amount?: AmountString;
+ /**
+ * Amount *or* a plain currency string.
+ */
+ amount?: string;
minimum_age?: Integer;
-
- pay_duration?: RelativeTime;
}
+
export interface TemplatePatchDetails {
// Human-readable description for the template.
template_description: string;
@@ -5250,6 +5266,68 @@ export namespace TalerMerchantApi {
// Master public key of the exchange.
master_pub: EddsaPublicKey;
}
+
+ export interface MerchantReserveCreateConfirmation {
+ // Public key identifying the reserve.
+ reserve_pub: EddsaPublicKey;
+
+ // Wire accounts of the exchange where to transfer the funds.
+ accounts: ExchangeWireAccount[];
+ }
+
+ export interface TemplateEditableDetails {
+ // Human-readable summary for the template.
+ summary?: string;
+
+ // Required currency for payments to the template.
+ // The user may specify any amount, but it must be
+ // in this currency.
+ // This parameter is optional and should not be present
+ // if "amount" is given.
+ currency?: string;
+
+ // The price is imposed by the merchant and cannot be changed by the customer.
+ // This parameter is optional.
+ amount?: AmountString;
+ }
+
+ export interface MerchantTemplateContractDetails {
+ // Human-readable summary for the template.
+ summary?: string;
+
+ // The price is imposed by the merchant and cannot be changed by the customer.
+ // This parameter is optional.
+ amount?: string;
+
+ // Minimum age buyer must have (in years). Default is 0.
+ minimum_age: number;
+
+ // The time the customer need to pay before his order will be deleted.
+ // It is deleted if the customer did not pay and if the duration is over.
+ pay_duration: TalerProtocolDuration;
+ }
+
+ export interface MerchantTemplateAddDetails {
+ // Template ID to use.
+ template_id: string;
+
+ // Human-readable description for the template.
+ template_description: string;
+
+ // A base64-encoded image selected by the merchant.
+ // This parameter is optional.
+ // We are not sure about it.
+ image?: string;
+
+ editable_defaults?: TemplateEditableDetails;
+
+ // Additional information in a separate template.
+ template_contract: MerchantTemplateContractDetails;
+
+ // OTP device ID.
+ // This parameter is optional.
+ otp_id?: string;
+ }
}
export namespace ChallengerApi {