Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TELEMETRY.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ A telemetry request has the following structure:
|---|---|---|
| `client` | Always | Identifies the event as coming from the Chargebee CLI. |
| `visitor_id` | Always | Random install ID generated by the CLI. It is not derived from your account, user, or machine. |
| `site_name` | Always | Site name of the active Chargebee profile, or `unconfigured`. |
| `site_name` | Always | Site name of the active Chargebee profile, or `unconfigured`. For `auth add` and `auth switch`, the site that is active once the command succeeds. |
| `cli_version` | Always | Installed CLI version. |
| `name` | Always | Command path, such as `customer list`. Arguments and values are not included. |
| `timestamp` | Always | Time the event was recorded. |
Expand Down
2 changes: 1 addition & 1 deletion THIRD_PARTY_NOTICES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ change-case@5.4.4 (MIT)
This package ships no LICENSE, LICENCE, or COPYING file. Its package.json
declares the SPDX license identifier "MIT".

chargebee@3.34.0 (MIT)
chargebee@3.35.0 (MIT)
----------------------
The MIT License

Expand Down
2 changes: 1 addition & 1 deletion bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/commands/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { setCommandGroup } from "./help.js";
import { sectionTitle } from "../lib/help-style.js";
import { switchProfileAction } from "../lib/config/switch-profile.js";
import { EXIT_CODES } from "../lib/exit-codes.js";
import { noteActiveSite } from "../lib/telemetry/active-site.js";

const DEFAULT_PROFILE = "default";

Expand Down Expand Up @@ -192,6 +193,7 @@ export function registerAuthCommand(program: Command): void {
...(savedRegion === DEFAULT_REGION ? {} : { region: savedRegion }),
});
await writeConfig({ domain: site, activeProfile: profileName });
noteActiveSite(site);
jsonResult({ configured: true, profile: profileName, site, region: savedRegion,
host: persistableHost(apiHost), product_catalog_version: catalog.productCatalogVersion ?? null,
chargebee_response_schema_type: catalog.responseSchemaType ?? null, key_storage: saved.backend });
Expand Down
98 changes: 96 additions & 2 deletions src/commands/generated/business_entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import { Option, type Command } from "commander";

import { getClient, ensureWriteAllowed, ensureCatalogAllowed } from "../../lib/api/sdk.js";
import { handleSdkError, printResult } from "../../lib/api/print.js";
import { handleCodeSample } from "../../lib/api/generated-command.js";
import { loadOperationParams, readJsonMarker } from "../../lib/api/stdin-params.js";
import { assertResourceId, handleCodeSample } from "../../lib/api/generated-command.js";
import { warnBareListFilters } from "../../lib/codesample/index.js";
import { loadOperationParams, takeResourceId, readJsonMarker, warnBareJsonFilters } from "../../lib/api/stdin-params.js";

import { toSdkParams } from "../../lib/api/params.js";

Expand All @@ -16,6 +17,28 @@ export function registerBusinessEntity(parent: Command): void {
.alias("business_entity")
.description("API operations for business entities");

cmd
.command("create")
.argument("[json]", "'-' reads a JSON object from stdin.")
.description("Create a business_entity")
.option("-d, --data <pairs...>", "Request parameters in key=value format; repeat for multiple fields")
.option("-s, --code-sample <lang>", "Generate code sample (curl, python, nodejs, go, ruby, java, php, dotnet, list)")
.addOption(new Option("--pc-version <version>", "Product catalog version for the code sample (v1 or v2)").hideHelp())
.option("-y, --yes", "Skip the confirmation prompt for writes on a live site")
.addHelpText("after", "\n\u001b[1mDOCUMENTATION\u001b[0m\n chargebee docs business-entity create\n")
.action(async (json: string | undefined, opts: { data?: string[]; codeSample?: string; pcVersion?: string; yes?: boolean }, command: Command) => {
const fromStdin = readJsonMarker(json, command);
const params = await loadOperationParams(opts.data ?? [], fromStdin, command, { method: "POST", jsonInput: false, opIdV2: "create_a_business_entity", opIdV1: "", pcVersionFlag: opts.pcVersion });
if (opts.codeSample !== "list") await ensureCatalogAllowed("pc2", "business-entity create");
if (opts.codeSample) return handleCodeSample({ lang: opts.codeSample, opIdV2: "create_a_business_entity", opIdV1: "", method: "POST", uri: "/business_entities", dataFlags: opts.data ?? [], params, pcVersionFlag: opts.pcVersion });
await ensureWriteAllowed("POST", "business-entity create", opts.yes === true);
try {
const client = await getClient();
const result = await (client as any).businessEntity.create(params);
printResult(result);
} catch (e) { handleSdkError(e); }
});

cmd
.command("create-transfers")
.argument("[json]", "'-' reads a JSON object from stdin.")
Expand Down Expand Up @@ -58,4 +81,75 @@ export function registerBusinessEntity(parent: Command): void {
} catch (e) { handleSdkError(e); }
});

cmd
.command("list")
.argument("[json]", "'-' reads a JSON object from stdin.")
.description("List business entities")
.option("-d, --data <pairs...>", "Parameters as key=value. List filters require an operator suffix (id[is]=…). Bare keys: limit, offset, include_deleted.")
.option("-s, --code-sample <lang>", "Generate code sample (curl, python, nodejs, go, ruby, java, php, dotnet, list)")
.addOption(new Option("--pc-version <version>", "Product catalog version for the code sample (v1 or v2)").hideHelp())
.addHelpText("after", "\n\u001b[1mLIST FILTERS\u001b[0m\n Filter fields need an operator suffix: [is], [in], [starts_with], [between], [gt], [lt], ...\n Pagination uses bare keys: -d limit=10\n See https://apidocs.chargebee.com/docs/api/list-ops\n Per-resource Filter Params: chargebee docs business-entity list")
.addHelpText("after", "\n\u001b[1mDOCUMENTATION\u001b[0m\n chargebee docs business-entity list\n")
.action(async (json: string | undefined, opts: { data?: string[]; codeSample?: string; pcVersion?: string }, command: Command) => {
const fromStdin = readJsonMarker(json, command);
const params = await loadOperationParams(opts.data ?? [], fromStdin, command, { method: "GET", jsonInput: false, opIdV2: "list_business_entities", opIdV1: "", pcVersionFlag: opts.pcVersion });
if (opts.codeSample !== "list") await ensureCatalogAllowed("pc2", "business-entity list");
if (opts.codeSample) return handleCodeSample({ lang: opts.codeSample, opIdV2: "list_business_entities", opIdV1: "", method: "GET", uri: "/business_entities", dataFlags: opts.data ?? [], params, pcVersionFlag: opts.pcVersion });
if (fromStdin) warnBareJsonFilters(params, "business-entity");
else warnBareListFilters(opts.data ?? [], "business-entity");
try {
const client = await getClient();
const result = await (client as any).businessEntity.list(toSdkParams(params, "GET", true));
printResult(result);
} catch (e) { handleSdkError(e); }
});

cmd
.command("retrieve")
.argument("[business-entity-id]", "A unique and immutable identifier for the business entity.")
.argument("[json]", "'-' reads a JSON object from stdin.")
.description("Retrieve a business entity")
.option("-d, --data <pairs...>", "Request parameters in key=value format; repeat for multiple fields")
.option("-s, --code-sample <lang>", "Generate code sample (curl, python, nodejs, go, ruby, java, php, dotnet, list)")
.addOption(new Option("--pc-version <version>", "Product catalog version for the code sample (v1 or v2)").hideHelp())
.addHelpText("after", "\n\u001b[1mDOCUMENTATION\u001b[0m\n chargebee docs business-entity retrieve\n")
.action(async (id: string | undefined, json: string | undefined, opts: { data?: string[]; codeSample?: string; pcVersion?: string }, command: Command) => {
const resource = takeResourceId(id, json, command);
const params = await loadOperationParams(opts.data ?? [], resource.fromStdin, command, { method: "GET", jsonInput: false, opIdV2: "retrieve_a_business_entity", opIdV1: "", pcVersionFlag: opts.pcVersion });
if (opts.codeSample !== "list") await ensureCatalogAllowed("pc2", "business-entity retrieve");
if (opts.codeSample) return handleCodeSample({ lang: opts.codeSample, opIdV2: "retrieve_a_business_entity", opIdV1: "", method: "GET", uri: "/business_entities/{id}", dataFlags: opts.data ?? [], params, resourceId: resource.id, pathParamName: "business-entity-id", pcVersionFlag: opts.pcVersion });
if (!resource.id) command.error("error: missing required argument 'business-entity-id'");
assertResourceId(resource.id, command);
try {
const client = await getClient();
const result = await (client as any).businessEntity.retrieve(resource.id, toSdkParams(params, "GET", false));
printResult(result);
} catch (e) { handleSdkError(e); }
});

cmd
.command("update")
.argument("[business-entity-id]", "A unique and immutable identifier for the business entity.")
.argument("[json]", "'-' reads a JSON object from stdin.")
.description("Update business entity")
.option("-d, --data <pairs...>", "Request parameters in key=value format; repeat for multiple fields")
.option("-s, --code-sample <lang>", "Generate code sample (curl, python, nodejs, go, ruby, java, php, dotnet, list)")
.addOption(new Option("--pc-version <version>", "Product catalog version for the code sample (v1 or v2)").hideHelp())
.option("-y, --yes", "Skip the confirmation prompt for writes on a live site")
.addHelpText("after", "\n\u001b[1mDOCUMENTATION\u001b[0m\n chargebee docs business-entity update\n")
.action(async (id: string | undefined, json: string | undefined, opts: { data?: string[]; codeSample?: string; pcVersion?: string; yes?: boolean }, command: Command) => {
const resource = takeResourceId(id, json, command);
const params = await loadOperationParams(opts.data ?? [], resource.fromStdin, command, { method: "POST", jsonInput: false, opIdV2: "update_business_entity", opIdV1: "", pcVersionFlag: opts.pcVersion });
if (opts.codeSample !== "list") await ensureCatalogAllowed("pc2", "business-entity update");
if (opts.codeSample) return handleCodeSample({ lang: opts.codeSample, opIdV2: "update_business_entity", opIdV1: "", method: "POST", uri: "/business_entities/{id}", dataFlags: opts.data ?? [], params, resourceId: resource.id, pathParamName: "business-entity-id", pcVersionFlag: opts.pcVersion });
if (!resource.id) command.error("error: missing required argument 'business-entity-id'");
assertResourceId(resource.id, command);
await ensureWriteAllowed("POST", "business-entity update", opts.yes === true);
try {
const client = await getClient();
const result = await (client as any).businessEntity.update(resource.id, params);
printResult(result);
} catch (e) { handleSdkError(e); }
});

}
Loading
Loading