harness: helper to provision corebank account
This commit is contained in:
parent
2ecdd6816d
commit
a45f45b61b
@ -28,6 +28,8 @@ import {
|
|||||||
MerchantApiClient,
|
MerchantApiClient,
|
||||||
rsaBlind,
|
rsaBlind,
|
||||||
setGlobalLogLevelFromString,
|
setGlobalLogLevelFromString,
|
||||||
|
RegisterAccountRequest,
|
||||||
|
HttpStatusCode,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import { clk } from "@gnu-taler/taler-util/clk";
|
import { clk } from "@gnu-taler/taler-util/clk";
|
||||||
import {
|
import {
|
||||||
@ -519,6 +521,48 @@ deploymentCli
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
deploymentCli
|
||||||
|
.subcommand("provisionBankAccount", "provision-bank-account", {
|
||||||
|
help: "Provision a corebank account.",
|
||||||
|
})
|
||||||
|
.requiredArgument("corebankApiBaseUrl", clk.STRING)
|
||||||
|
.flag("exchange", ["--exchange"])
|
||||||
|
.flag("public", ["--public"])
|
||||||
|
.requiredOption("login", ["--login"], clk.STRING)
|
||||||
|
.requiredOption("name", ["--name"], clk.STRING)
|
||||||
|
.requiredOption("password", ["--password"], clk.STRING)
|
||||||
|
.maybeOption("internalPayto", ["--payto"], clk.STRING)
|
||||||
|
.action(async (args) => {
|
||||||
|
const httpLib = createPlatformHttpLib();
|
||||||
|
const corebankApiBaseUrl = args.provisionBankAccount.corebankApiBaseUrl;
|
||||||
|
const url = new URL("accounts", corebankApiBaseUrl);
|
||||||
|
const accountLogin = args.provisionBankAccount.login;
|
||||||
|
const body: RegisterAccountRequest = {
|
||||||
|
name: args.provisionBankAccount.name,
|
||||||
|
password: args.provisionBankAccount.password,
|
||||||
|
username: accountLogin,
|
||||||
|
is_public: !!args.provisionBankAccount.public,
|
||||||
|
is_taler_exchange: !!args.provisionBankAccount.exchange,
|
||||||
|
internal_payto_uri: args.provisionBankAccount.internalPayto,
|
||||||
|
};
|
||||||
|
const resp = await httpLib.fetch(url.href, {
|
||||||
|
method: "POST",
|
||||||
|
body,
|
||||||
|
});
|
||||||
|
if (resp.status >= 200 && resp.status <= 299) {
|
||||||
|
logger.info(`account ${accountLogin} successfully provisioned`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (resp.status === HttpStatusCode.Conflict) {
|
||||||
|
logger.info(`account ${accountLogin} already provisioned`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
logger.error(
|
||||||
|
`unable to provision bank account, HTTP response status ${resp.status}`,
|
||||||
|
);
|
||||||
|
process.exit(2);
|
||||||
|
});
|
||||||
|
|
||||||
deploymentCli
|
deploymentCli
|
||||||
.subcommand("coincfg", "gen-coin-config", {
|
.subcommand("coincfg", "gen-coin-config", {
|
||||||
help: "Generate a coin/denomination configuration for the exchange.",
|
help: "Generate a coin/denomination configuration for the exchange.",
|
||||||
|
Loading…
Reference in New Issue
Block a user