|
27 | 27 | - [Trip](#trip) |
28 | 28 | - [Telemetry](#telemetry) |
29 | 29 | - [Custom Domains](#custom-domains) |
| 30 | +- [Plans](#plans) |
30 | 31 |
|
31 | 32 | # Auth |
32 | 33 |
|
@@ -4625,3 +4626,119 @@ console.log(response.org_name); |
4625 | 4626 | ``` |
4626 | 4627 |
|
4627 | 4628 | </details> |
| 4629 | + |
| 4630 | +--- |
| 4631 | + |
| 4632 | +# Plans |
| 4633 | + |
| 4634 | +## Overview |
| 4635 | + |
| 4636 | +The `Plans` class provides methods for retrieving subscription plans, including their pricing items, features, and support entitlements. |
| 4637 | + |
| 4638 | +## Types |
| 4639 | + |
| 4640 | +### PlanCode |
| 4641 | + |
| 4642 | +```typescript |
| 4643 | +type PlanCode = 'free' | 'pro'; |
| 4644 | +``` |
| 4645 | + |
| 4646 | +### BillingCycle |
| 4647 | + |
| 4648 | +```typescript |
| 4649 | +type BillingCycle = 'monthly' | 'yearly'; |
| 4650 | +``` |
| 4651 | + |
| 4652 | +### FeatureValueType |
| 4653 | + |
| 4654 | +```typescript |
| 4655 | +type FeatureValueType = 'limit' | 'boolean' | 'quota'; |
| 4656 | +``` |
| 4657 | + |
| 4658 | +### Plan |
| 4659 | + |
| 4660 | +```typescript |
| 4661 | +interface Plan { |
| 4662 | + id: string; // Unique identifier of the plan |
| 4663 | + name: string; // Human-readable plan name (e.g. "Free") |
| 4664 | + code: PlanCode; // Machine-readable plan code (e.g. "free") |
| 4665 | + description: string; // Description of the plan |
| 4666 | + plan_items: PlanItem[]; // Pricing options for each billing cycle |
| 4667 | + is_current_plan: boolean; // Whether this is the caller's current plan |
| 4668 | + created_at: string; // Creation timestamp (ISO 8601 format) |
| 4669 | + updated_at: string; // Last update timestamp (ISO 8601 format) |
| 4670 | + features: PlanFeature[]; // Feature entitlements for the plan |
| 4671 | + support: PlanFeature[]; // Support entitlements for the plan |
| 4672 | +} |
| 4673 | +``` |
| 4674 | + |
| 4675 | +### PlanItem |
| 4676 | + |
| 4677 | +```typescript |
| 4678 | +interface PlanItem { |
| 4679 | + id: string; // Unique identifier of the plan item |
| 4680 | + price: string; // Price as a decimal string (e.g. "0.00") |
| 4681 | + icon: string; // Icon reference for the plan item |
| 4682 | + currency: string; // Currency code (e.g. "USD") |
| 4683 | + discount: number; // Discount applied to the price |
| 4684 | + billing_cycle: BillingCycle; // Billing cycle for this item |
| 4685 | + is_active: boolean; // Whether this item is currently active |
| 4686 | + created_at: string; // Creation timestamp (ISO 8601 format) |
| 4687 | + updated_at: string; // Last update timestamp (ISO 8601 format) |
| 4688 | +} |
| 4689 | +``` |
| 4690 | + |
| 4691 | +### PlanFeature |
| 4692 | + |
| 4693 | +```typescript |
| 4694 | +interface PlanFeature { |
| 4695 | + id: string; // Unique identifier of the plan feature |
| 4696 | + feature: Feature; // The underlying feature definition |
| 4697 | + enabled: boolean; // Whether the feature is enabled for the plan |
| 4698 | + limit_value: number | null; // Numeric limit/quota, or null for boolean features |
| 4699 | + metadata: Record<string, unknown>; // Additional feature metadata |
| 4700 | +} |
| 4701 | +``` |
| 4702 | + |
| 4703 | +### Feature |
| 4704 | + |
| 4705 | +```typescript |
| 4706 | +interface Feature { |
| 4707 | + id: string; // Unique identifier of the feature |
| 4708 | + code: string; // Machine-readable feature code (e.g. "device.max_count") |
| 4709 | + name: string; // Human-readable feature name |
| 4710 | + description: string; // Description of the feature |
| 4711 | + value_type: FeatureValueType; // How the feature's value is interpreted |
| 4712 | +} |
| 4713 | +``` |
| 4714 | + |
| 4715 | +## Methods |
| 4716 | + |
| 4717 | +<details> |
| 4718 | + <summary><strong>retrieve</strong></summary> |
| 4719 | + |
| 4720 | +Retrieve a plan by its code. |
| 4721 | + |
| 4722 | +**Signature:** |
| 4723 | + |
| 4724 | +```typescript |
| 4725 | +retrieve(plan: PlanCode, options?: Core.RequestOptions): Core.APIPromise<Plan> |
| 4726 | +``` |
| 4727 | + |
| 4728 | +**Parameters:** |
| 4729 | + |
| 4730 | +- `plan` _(PlanCode)_: The plan code identifying the plan (`'free'` or `'pro'`). |
| 4731 | +- `options` _(Core.RequestOptions, optional)_: Additional request options. |
| 4732 | + |
| 4733 | +**Returns:** `Promise<Plan>` |
| 4734 | + |
| 4735 | +**Example:** |
| 4736 | + |
| 4737 | +```typescript |
| 4738 | +const plan = await client.plans.retrieve('free'); |
| 4739 | +console.log(plan.name); |
| 4740 | +console.log(plan.is_current_plan); |
| 4741 | +console.log(plan.features.map((f) => f.feature.code)); |
| 4742 | +``` |
| 4743 | + |
| 4744 | +</details> |
0 commit comments