diff options
author | Sebastian <sebasjm@gmail.com> | 2024-03-20 00:19:29 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-03-20 00:19:29 -0300 |
commit | 62d5a5ef7b1ff9f9c63d9a4eba21620aa8a2fad9 (patch) | |
tree | 263bb9db784a64bd77a1c7538407e164c704cb01 /packages/taler-util/src/http-client/types.ts | |
parent | c09caa5fdca91fb6ded6b2ce8caf1620c0273b80 (diff) | |
download | wallet-core-62d5a5ef7b1ff9f9c63d9a4eba21620aa8a2fad9.tar.gz wallet-core-62d5a5ef7b1ff9f9c63d9a4eba21620aa8a2fad9.tar.bz2 wallet-core-62d5a5ef7b1ff9f9c63d9a4eba21620aa8a2fad9.zip |
wip, MerchantRefundResponse is deprecateddev/sebasjm/merchant-api
Diffstat (limited to 'packages/taler-util/src/http-client/types.ts')
-rw-r--r-- | packages/taler-util/src/http-client/types.ts | 248 |
1 files changed, 213 insertions, 35 deletions
diff --git a/packages/taler-util/src/http-client/types.ts b/packages/taler-util/src/http-client/types.ts index 67719ddd9..5fa3d0e7a 100644 --- a/packages/taler-util/src/http-client/types.ts +++ b/packages/taler-util/src/http-client/types.ts @@ -21,7 +21,7 @@ import { codecForInternationalizedString, codecForLocation, } from "../taler-types.js"; -import { TalerActionString, codecForTalerActionString } from "../taleruri.js"; +import { TalerUriString, codecForTalerUriString } from "../taleruri.js"; import { AbsoluteTime, TalerProtocolDuration, @@ -68,7 +68,7 @@ export type PaginationParams = { /** * order */ - order: "asc" | "dec"; + order?: "asc" | "dec"; }; export type LongPollParams = { @@ -355,7 +355,7 @@ export const codecForStatusStatusUnpaid = .property("type", codecForConstString("unpaid")) .property("already_paid_order_id", codecOptional(codecForString())) .property("fulfillment_url", codecOptional(codecForString())) - .property("taler_pay_uri", codecForString()) + .property("taler_pay_uri", codecForTalerUriString()) .build("TalerMerchantApi.PaymentResponse"); export const codecForPaidRefundStatusResponse = @@ -679,7 +679,7 @@ export const codecForCheckPaymentUnpaidResponse = (): Codec<TalerMerchantApi.CheckPaymentUnpaidResponse> => buildCodecForObject<TalerMerchantApi.CheckPaymentUnpaidResponse>() .property("order_status", codecForConstString("unpaid")) - .property("taler_pay_uri", codecForString()) + .property("taler_pay_uri", codecForTalerUriString()) .property("creation_time", codecForTimestamp) .property("summary", codecForString()) .property("total_amount", codecForAmountString()) @@ -735,6 +735,175 @@ export const codecForTransactionWireReport = .property("coin_pub", codecForString()) .build("TalerMerchantApi.TransactionWireReport"); +export const codecForMerchantRefundResponse = + (): Codec<TalerMerchantApi.MerchantRefundResponse> => + buildCodecForObject<TalerMerchantApi.MerchantRefundResponse>() + .property("taler_refund_uri", codecForTalerUriString()) + .property("h_contract", codecForString()) + .build("TalerMerchantApi.MerchantRefundResponse"); + +export const codecForTansferList = + (): Codec<TalerMerchantApi.TransferList> => + buildCodecForObject<TalerMerchantApi.TransferList>() + .property("transfers", codecForList(codecForTransferDetails())) + .build("TalerMerchantApi.TransferList"); + +export const codecForTransferDetails = + (): Codec<TalerMerchantApi.TransferDetails> => + buildCodecForObject<TalerMerchantApi.TransferDetails>() + .property("credit_amount", codecForAmountString()) + .property("wtid", codecForString()) + .property("payto_uri", codecForPaytoString()) + .property("exchange_url", codecForURL()) + .property("transfer_serial_id", codecForNumber()) + .property("execution_time", codecForTimestamp) + .property("verified", codecOptional(codecForBoolean())) + .property("confirmed", codecOptional(codecForBoolean())) + .build("TalerMerchantApi.TransferDetails"); + +export const codecForOtpDeviceSummaryResponse = + (): Codec<TalerMerchantApi.OtpDeviceSummaryResponse> => + buildCodecForObject<TalerMerchantApi.OtpDeviceSummaryResponse>() + .property("otp_devices", codecForList(codecForOtpDeviceEntry())) + .build("TalerMerchantApi.OtpDeviceSummaryResponse"); + +export const codecForOtpDeviceEntry = + (): Codec<TalerMerchantApi.OtpDeviceEntry> => + buildCodecForObject<TalerMerchantApi.OtpDeviceEntry>() + .property("otp_device_id", codecForString()) + .property("device_description", codecForString()) + .build("TalerMerchantApi.OtpDeviceEntry"); + +export const codecForOtpDeviceDetails = + (): Codec<TalerMerchantApi.OtpDeviceDetails> => + buildCodecForObject<TalerMerchantApi.OtpDeviceDetails>() + .property("device_description", codecForString()) + .property("otp_algorithm", codecForNumber()) + .property("otp_ctr", codecOptional(codecForNumber())) + .property("otp_timestamp", codecForNumber()) + .property("otp_code", codecOptional(codecForString())) + .build("TalerMerchantApi.OtpDeviceDetails"); + + +export const codecForTemplateSummaryResponse = + (): Codec<TalerMerchantApi.TemplateSummaryResponse> => + buildCodecForObject<TalerMerchantApi.TemplateSummaryResponse>() + .property("templates_list", codecForList(codecForTemplateEntry())) + .build("TalerMerchantApi.TemplateSummaryResponse"); + +export const codecForTemplateEntry = + (): Codec<TalerMerchantApi.TemplateEntry> => + buildCodecForObject<TalerMerchantApi.TemplateEntry>() + .property("template_id", codecForString()) + .property("template_description", codecForString()) + .build("TalerMerchantApi.TemplateEntry"); + +export const codecForTemplateDetails = + (): Codec<TalerMerchantApi.TemplateDetails> => + buildCodecForObject<TalerMerchantApi.TemplateDetails>() + .property("template_description", codecForString()) + .property("otp_id", codecOptional(codecForString())) + .property("template_contract", codecForTemplateContractDetails()) + .build("TalerMerchantApi.TemplateDetails"); + +export const codecForTemplateContractDetails = + (): Codec<TalerMerchantApi.TemplateContractDetails> => + buildCodecForObject<TalerMerchantApi.TemplateContractDetails>() + .property("summary", codecOptional(codecForString())) + .property("currency", codecOptional(codecForString())) + .property("amount", codecOptional(codecForAmountString())) + .property("minimum_age", codecForNumber()) + .property("pay_duration", codecForDuration) + .build("TalerMerchantApi.TemplateContractDetails"); + +export const codecForWalletTemplateDetails = + (): Codec<TalerMerchantApi.WalletTemplateDetails> => + buildCodecForObject<TalerMerchantApi.WalletTemplateDetails>() + .property("template_contract", codecForTemplateContractDetails()) + .build("TalerMerchantApi.WalletTemplateDetails"); + + +export const codecForWebhookSummaryResponse = + (): Codec<TalerMerchantApi.WebhookSummaryResponse> => + buildCodecForObject<TalerMerchantApi.WebhookSummaryResponse>() + .property("webhooks", codecForList(codecForWebhookEntry())) + .build("TalerMerchantApi.WebhookSummaryResponse"); + +export const codecForWebhookEntry = + (): Codec<TalerMerchantApi.WebhookEntry> => + buildCodecForObject<TalerMerchantApi.WebhookEntry>() + .property("webhook_id", codecForString()) + .property("event_type", codecForString()) + .build("TalerMerchantApi.WebhookEntry"); + +export const codecForWebhookDetails = + (): Codec<TalerMerchantApi.WebhookDetails> => + buildCodecForObject<TalerMerchantApi.WebhookDetails>() + .property("event_type", codecForString()) + .property("url", codecForString()) + .property("http_method", codecForString()) + .property("header_template", codecOptional(codecForString())) + .property("body_template", codecOptional(codecForString())) + .build("TalerMerchantApi.WebhookDetails"); + +export const codecForTokenFamilyKind = + (): Codec<TalerMerchantApi.TokenFamilyKind> => + codecForEither( + codecForConstString("discount"), + codecForConstString("subscription"), + ) as any //FIXME: create a codecForEnum + ; +export const codecForTokenFamilyDetails = + (): Codec<TalerMerchantApi.TokenFamilyDetails> => + buildCodecForObject<TalerMerchantApi.TokenFamilyDetails>() + .property("slug", codecForString()) + .property("name", codecForString()) + .property("description", codecForString()) + .property("description_i18n", (codecForInternationalizedString())) + .property("valid_after", (codecForTimestamp)) + .property("valid_before", (codecForTimestamp)) + .property("duration", (codecForDuration)) + .property("kind", codecForTokenFamilyKind()) + .property("issued", (codecForNumber())) + .property("redeemed", (codecForNumber())) + .build("TalerMerchantApi.TokenFamilyDetails"); + +export const codecForTokenFamiliesList = + (): Codec<TalerMerchantApi.TokenFamiliesList> => + buildCodecForObject<TalerMerchantApi.TokenFamiliesList>() + .property("token_families", codecForList(codecForTokenFamilySummary())) + .build("TalerMerchantApi.TokenFamiliesList"); + +export const codecForTokenFamilySummary = + (): Codec<TalerMerchantApi.TokenFamilySummary> => + buildCodecForObject<TalerMerchantApi.TokenFamilySummary>() + .property("slug", codecForString()) + .property("name", codecForString()) + .property("valid_after", codecForTimestamp) + .property("valid_before", codecForTimestamp) + .property("kind", codecForTokenFamilyKind()) + .build("TalerMerchantApi.TokenFamilySummary"); + + +export const codecForInstancesResponse = + (): Codec<TalerMerchantApi.InstancesResponse> => + buildCodecForObject<TalerMerchantApi.InstancesResponse>() + .property("instances", codecForList(codecForInstance())) + .build("TalerMerchantApi.InstancesResponse"); + +export const codecForInstance = + (): Codec<TalerMerchantApi.Instance> => + buildCodecForObject<TalerMerchantApi.Instance>() + .property("name", codecForString()) + .property("user_type", codecForString()) + .property("website", codecOptional(codecForString())) + .property("logo", codecOptional(codecForString())) + .property("id", codecForString()) + .property("merchant_pub", codecForString()) + .property("payment_targets", codecForList(codecForString())) + .property("deleted", codecForBoolean()) + .build("TalerMerchantApi.Instance"); + export const codecForExchangeConfig = (): Codec<TalerExchangeApi.ExchangeVersionResponse> => buildCodecForObject<TalerExchangeApi.ExchangeVersionResponse>() @@ -891,7 +1060,7 @@ export const codecForRegisterAccountResponse = export const codecForBankAccountCreateWithdrawalResponse = (): Codec<TalerCorebankApi.BankAccountCreateWithdrawalResponse> => buildCodecForObject<TalerCorebankApi.BankAccountCreateWithdrawalResponse>() - .property("taler_withdraw_uri", codecForTalerActionString()) + .property("taler_withdraw_uri", codecForTalerUriString()) .property("withdrawal_id", codecForString()) .build("TalerCorebankApi.BankAccountCreateWithdrawalResponse"); @@ -1810,7 +1979,7 @@ export namespace TalerCorebankApi { withdrawal_id: string; // URI that can be passed to the wallet to initiate the withdrawal. - taler_withdraw_uri: TalerActionString; + taler_withdraw_uri: TalerUriString; } export interface WithdrawalPublicInfo { // Current status of the operation @@ -2989,9 +3158,10 @@ export namespace TalerMerchantApi { // execution time. Default is -20. limit?: number; // Starting transfer_serial_id for an iteration. - offset?: number; + offset?: string; // Filter transfers by verification status. verified?: boolean; + order?: "asc" | "dec"; } export interface ListOrdersRequestParams { // If set to yes, only return paid orders, if no only @@ -3007,19 +3177,17 @@ export namespace TalerMerchantApi { // use “all”) to see all orders regardless of wire transfer // status. wired?: boolean; - // takes value of the form N (-N), so that at most N values - // strictly older (younger) than start and date_s are returned. - // Defaults to -20 to return the last 20 entries (before start - // and/or date_s). - delta?: number; + // At most return the given number of results. Negative + // for descending by row ID, positive for ascending by + // row ID. Default is 20. Since protocol v12. + limit?: number; // Non-negative date in seconds after the UNIX Epoc, see delta // for its interpretation. If not specified, we default to the // oldest or most recent entry, depending on delta. date?: AbsoluteTime; - // Row number threshold, see delta for its interpretation. - // Defaults to INT64_MAX, namely the biggest row id possible in - // the database. - start?: number; + // Starting product_serial_id for an iteration. + // Since protocol v12. + offset?: string; // Timeout in milliseconds to wait for additional orders if the // answer would otherwise be negative (long polling). Only useful // if delta is positive. Note that the merchant MAY still return @@ -3029,6 +3197,8 @@ export namespace TalerMerchantApi { sessionId?: string; // Since protocol v6. Filters by fulfillment URL. fulfillmentUrl?: string; + + order?: "asc" | "dec"; } export interface PayRequest { @@ -3417,12 +3587,12 @@ export namespace TalerMerchantApi { default_pay_delay: RelativeTime; } - interface InstancesResponse { + export interface InstancesResponse { // List of instances that are present in the backend (see Instance). instances: Instance[]; } - interface Instance { + export interface Instance { // Merchant name corresponding to this instance. name: string; @@ -4046,7 +4216,7 @@ export namespace TalerMerchantApi { // Human-readable refund justification. reason: string; } - interface MerchantRefundResponse { + export interface MerchantRefundResponse { // URL (handled by the backend) that the wallet should access to // trigger refund processing. // taler://refund/... @@ -4071,11 +4241,11 @@ export namespace TalerMerchantApi { exchange_url: string; } - interface TransferList { + export interface TransferList { // List of all the transfers that fit the filter that we know. transfers: TransferDetails[]; } - interface TransferDetails { + export interface TransferDetails { // How much was wired to the merchant (minus fees). credit_amount: AmountString; @@ -4318,11 +4488,11 @@ export namespace TalerMerchantApi { otp_ctr?: Integer; } - interface OtpDeviceSummaryResponse { + export interface OtpDeviceSummaryResponse { // Array of devices that are present in our backend. otp_devices: OtpDeviceEntry[]; } - interface OtpDeviceEntry { + export interface OtpDeviceEntry { // Device identifier. otp_device_id: string; @@ -4330,7 +4500,7 @@ export namespace TalerMerchantApi { device_description: string; } - interface OtpDeviceDetails { + export interface OtpDeviceDetails { // Human-readable description for the device. device_description: string; @@ -4392,7 +4562,7 @@ export namespace TalerMerchantApi { // Additional information in a separate template. template_contract: TemplateContractDetails; } - interface TemplateContractDetails { + export interface TemplateContractDetails { // Human-readable summary for the template. summary?: string; @@ -4426,19 +4596,27 @@ export namespace TalerMerchantApi { template_contract: TemplateContractDetails; } - interface TemplateSummaryResponse { + export interface TemplateSummaryResponse { // List of templates that are present in our backend. templates_list: TemplateEntry[]; } - interface TemplateEntry { + export interface TemplateEntry { // Template identifier, as found in the template. template_id: string; // Human-readable description for the template. template_description: string; } - interface TemplateDetails { + + export interface WalletTemplateDetails { + + // Hard-coded information about the contrac terms + // for this template. + template_contract: TemplateContractDetails; + } + + export interface TemplateDetails { // Human-readable description for the template. template_description: string; @@ -4494,12 +4672,12 @@ export namespace TalerMerchantApi { body_template?: string; } - interface WebhookSummaryResponse { + export interface WebhookSummaryResponse { // Return webhooks that are present in our backend. webhooks: WebhookEntry[]; } - interface WebhookEntry { + export interface WebhookEntry { // Webhook identifier, as found in the webhook. webhook_id: string; @@ -4507,7 +4685,7 @@ export namespace TalerMerchantApi { event_type: string; } - interface WebhookDetails { + export interface WebhookDetails { // The event of the webhook: why the webhook is used. event_type: string; @@ -4552,7 +4730,7 @@ export namespace TalerMerchantApi { kind: TokenFamilyKind; } - enum TokenFamilyKind { + export enum TokenFamilyKind { Discount = "discount", Subscription = "subscription", } @@ -4577,12 +4755,12 @@ export namespace TalerMerchantApi { duration: RelativeTime; } - interface TokenFamiliesList { + export interface TokenFamiliesList { // All configured token families of this instance. token_families: TokenFamilySummary[]; } - interface TokenFamilySummary { + export interface TokenFamilySummary { // Identifier for the token family consisting of unreserved characters // according to RFC 3986. slug: string; @@ -4600,7 +4778,7 @@ export namespace TalerMerchantApi { kind: TokenFamilyKind; } - interface TokenFamilyDetails { + export interface TokenFamilyDetails { // Identifier for the token family consisting of unreserved characters // according to RFC 3986. slug: string; |