orb-billing
Version:
The official TypeScript library for the Orb API
70 lines • 2.94 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../resource.mjs";
import { isRequestOptions } from "../../core.mjs";
import * as ExternalPlanIDAPI from "./external-plan-id.mjs";
import { ExternalPlanID } from "./external-plan-id.mjs";
import * as MigrationsAPI from "./migrations.mjs";
import { MigrationListResponsesPage, Migrations, } from "./migrations.mjs";
import { Page } from "../../pagination.mjs";
/**
* 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).
*/
export class Plans extends 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`, and `metadata` of an
* existing plan.
*
* Other fields on a plan are currently immutable.
*/
update(planId, body, options) {
return this._client.put(`/plans/${planId}`, { body, ...options });
}
list(query = {}, options) {
if (isRequestOptions(query)) {
return this.list({}, query);
}
return this._client.getAPIList('/plans', PlansPage, { 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(`/plans/${planId}`, options);
}
}
export class PlansPage extends Page {
}
Plans.PlansPage = PlansPage;
Plans.ExternalPlanID = ExternalPlanID;
Plans.Migrations = Migrations;
Plans.MigrationListResponsesPage = MigrationListResponsesPage;
//# sourceMappingURL=plans.mjs.map