diff options
Diffstat (limited to 'packages/taler-wallet-cli')
-rw-r--r-- | packages/taler-wallet-cli/src/index.ts | 97 |
1 files changed, 49 insertions, 48 deletions
diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts index 66d2d92e0..f713635a2 100644 --- a/packages/taler-wallet-cli/src/index.ts +++ b/packages/taler-wallet-cli/src/index.ts @@ -21,7 +21,6 @@ import { AbsoluteTime, addPaytoQueryParams, AgeRestriction, - classifyTalerUri, codecForList, codecForString, CoreApiResponse, @@ -32,13 +31,14 @@ import { j2s, Logger, parsePaytoUri, + parseTalerUri, PreparePayResultType, RecoveryMergeStrategy, sampleWalletCoreTransactions, setDangerousTimetravel, setGlobalLogLevelFromString, summarizeTalerErrorDetail, - TalerUriType, + TalerUriAction, WalletNotification, } from "@gnu-taler/taler-util"; import { clk } from "@gnu-taler/taler-util/clk"; @@ -639,70 +639,68 @@ walletCli } else { uri = await readlinePrompt("Taler URI: "); } - const uriType = classifyTalerUri(uri); - switch (uriType) { - case TalerUriType.TalerPay: + const parsedTalerUri = parseTalerUri(uri); + if (!parsedTalerUri) { + throw Error("invalid taler URI"); + } + switch (parsedTalerUri.type) { + case TalerUriAction.Pay: await doPay(wallet.client, uri, { alwaysYes: args.handleUri.autoYes, }); break; - case TalerUriType.TalerTip: - { - const res = await wallet.client.call( - WalletApiOperation.PrepareTip, - { - talerTipUri: uri, - }, - ); - console.log("tip status", res); - await wallet.client.call(WalletApiOperation.AcceptTip, { - walletTipId: res.walletTipId, - }); - } + case TalerUriAction.Tip: { + const res = await wallet.client.call(WalletApiOperation.PrepareTip, { + talerTipUri: uri, + }); + console.log("tip status", res); + await wallet.client.call(WalletApiOperation.AcceptTip, { + walletTipId: res.walletTipId, + }); break; - case TalerUriType.TalerRefund: + } + case TalerUriAction.Refund: await wallet.client.call(WalletApiOperation.StartRefundQueryForUri, { talerRefundUri: uri, }); break; - case TalerUriType.TalerWithdraw: - { - const withdrawInfo = await wallet.client.call( - WalletApiOperation.GetWithdrawalDetailsForUri, - { - talerWithdrawUri: uri, - restrictAge: args.handleUri.restrictAge, - }, - ); - console.log("withdrawInfo", withdrawInfo); - const selectedExchange = - args.handleUri.withdrawalExchange ?? - withdrawInfo.defaultExchangeBaseUrl; - if (!selectedExchange) { - console.error( - "no exchange specified for withdrawal (and no exchange suggested by the bank)", - ); - processExit(1); - return; - } - const res = await wallet.client.call( - WalletApiOperation.AcceptBankIntegratedWithdrawal, - { - exchangeBaseUrl: selectedExchange, - talerWithdrawUri: uri, - }, + case TalerUriAction.Withdraw: { + const withdrawInfo = await wallet.client.call( + WalletApiOperation.GetWithdrawalDetailsForUri, + { + talerWithdrawUri: uri, + restrictAge: args.handleUri.restrictAge, + }, + ); + console.log("withdrawInfo", withdrawInfo); + const selectedExchange = + args.handleUri.withdrawalExchange ?? + withdrawInfo.defaultExchangeBaseUrl; + if (!selectedExchange) { + console.error( + "no exchange specified for withdrawal (and no exchange suggested by the bank)", ); - console.log("accept withdrawal response", res); + processExit(1); + return; } + const res = await wallet.client.call( + WalletApiOperation.AcceptBankIntegratedWithdrawal, + { + exchangeBaseUrl: selectedExchange, + talerWithdrawUri: uri, + }, + ); + console.log("accept withdrawal response", res); break; - case TalerUriType.TalerDevExperiment: { + } + case TalerUriAction.DevExperiment: { await wallet.client.call(WalletApiOperation.ApplyDevExperiment, { devExperimentUri: uri, }); break; } default: - console.log(`URI type (${uriType}) not handled`); + console.log(`URI type (${parsedTalerUri}) not handled`); break; } return; @@ -1683,3 +1681,6 @@ async function read(stream: NodeJS.ReadStream) { export function main() { walletCli.run(); } +function classifyTalerUri(uri: string) { + throw new Error("Function not implemented."); +} |