UNPKG

orb-billing

Version:

The official TypeScript library for the Orb API

75 lines 3.41 kB
"use strict"; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. Object.defineProperty(exports, "__esModule", { value: true }); exports.Plans = void 0; const tslib_1 = require("../../internal/tslib.js"); const resource_1 = require("../../core/resource.js"); const ExternalPlanIDAPI = tslib_1.__importStar(require("./external-plan-id.js")); const external_plan_id_1 = require("./external-plan-id.js"); const MigrationsAPI = tslib_1.__importStar(require("./migrations.js")); const migrations_1 = require("./migrations.js"); const pagination_1 = require("../../core/pagination.js"); const path_1 = require("../../internal/utils/path.js"); /** * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by a * customer. Plans define the billing behavior of the subscription. You can see more about how to configure prices * in the [Price resource](/reference/price). */ class Plans extends resource_1.APIResource { constructor() { super(...arguments); this.externalPlanID = new ExternalPlanIDAPI.ExternalPlanID(this._client); this.migrations = new MigrationsAPI.Migrations(this._client); } /** * This endpoint allows creation of plans including their prices. */ create(body, options) { return this._client.post('/plans', { body, ...options }); } /** * This endpoint can be used to update the `external_plan_id`, `description`, and * `metadata` of an existing plan. * * Other fields on a plan are currently immutable. */ update(planID, body, options) { return this._client.put((0, path_1.path) `/plans/${planID}`, { body, ...options }); } /** * This endpoint returns a list of all [plans](/core-concepts#plan-and-price) for * an account in a list format. The list of plans is ordered starting from the most * recently created plan. The response also includes * [`pagination_metadata`](/api-reference/pagination) which lets the caller * retrieve the next page of results if they exist. */ list(query = {}, options) { return this._client.getAPIList('/plans', (pagination_1.Page), { query, ...options }); } /** * This endpoint is used to fetch [plan](/core-concepts#plan-and-price) details * given a plan identifier. It returns information about the prices included in the * plan and their configuration, as well as the product that the plan is attached * to. * * ## Serialized prices * * Orb supports a few different pricing models out of the box. Each of these models * is serialized differently in a given [Price](/core-concepts#plan-and-price) * object. The `model_type` field determines the key for the configuration object * that is present. A detailed explanation of price types can be found in the * [Price schema](/core-concepts#plan-and-price). * * ## Phases * * Orb supports plan phases, also known as contract ramps. For plans with phases, * the serialized prices refer to all prices across all phases. */ fetch(planID, options) { return this._client.get((0, path_1.path) `/plans/${planID}`, options); } } exports.Plans = Plans; Plans.ExternalPlanID = external_plan_id_1.ExternalPlanID; Plans.Migrations = migrations_1.Migrations; //# sourceMappingURL=plans.js.map