Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: 2.6.1 #195

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 .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "2.6.0"
".": "2.6.1"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 90
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb-513711d9c7ecfa388704769b0eacdfaef1752c88942b061c28f4239260089651.yml
configured_endpoints: 89
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb-762f50aa6ea13f42e719339aa5cb31233984499720a7be832182357f949927a1.yml
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 2.6.1 (2024-05-10)

Full Changelog: [v2.6.0...v2.6.1](https://github.com/orbcorp/orb-node/compare/v2.6.0...v2.6.1)

### Bug Fixes

* **api:** remove alert parameters and method that aren't supported by the live API ([#197](https://github.com/orbcorp/orb-node/issues/197)) ([66999d9](https://github.com/orbcorp/orb-node/commit/66999d9db101bff76d53b47a50d7e32b8d65032e))


### Chores

* **docs:** improve alert endpoints descriptions ([#194](https://github.com/orbcorp/orb-node/issues/194)) ([23ee7ed](https://github.com/orbcorp/orb-node/commit/23ee7ed33bc17e63be63dff60d74ad19c957ce95))
* rebuild project due to oas spec rename ([#196](https://github.com/orbcorp/orb-node/issues/196)) ([1afa7de](https://github.com/orbcorp/orb-node/commit/1afa7defea4a549657dded707b77208ae2b3befa))

## 2.6.0 (2024-05-09)

Full Changelog: [v2.5.1...v2.6.0](https://github.com/orbcorp/orb-node/compare/v2.5.1...v2.6.0)
Expand Down
5 changes: 2 additions & 3 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ Methods:
- <code title="get /alerts">client.alerts.<a href="./src/resources/alerts.ts">list</a>({ ...params }) -> AlertsPage</code>
- <code title="post /alerts/customer_id/{customer_id}">client.alerts.<a href="./src/resources/alerts.ts">createForCustomer</a>(customerId, { ...params }) -> Alert</code>
- <code title="post /alerts/external_customer_id/{external_customer_id}">client.alerts.<a href="./src/resources/alerts.ts">createForExternalCustomer</a>(externalCustomerId, { ...params }) -> Alert</code>
- <code title="post /alerts/plan_id/{plan_id}">client.alerts.<a href="./src/resources/alerts.ts">createForPlan</a>(planId, { ...params }) -> Alert</code>
- <code title="post /alerts/subscription_id/{subscription_id}">client.alerts.<a href="./src/resources/alerts.ts">createForSubscription</a>(subscriptionId, { ...params }) -> Alert</code>
- <code title="post /alerts/{alert_configuration_id}/disable">client.alerts.<a href="./src/resources/alerts.ts">disable</a>(alertConfigurationId, { ...params }) -> Alert</code>
- <code title="post /alerts/{alert_configuration_id}/enable">client.alerts.<a href="./src/resources/alerts.ts">enable</a>(alertConfigurationId, { ...params }) -> Alert</code>
- <code title="post /alerts/{alert_configuration_id}/disable">client.alerts.<a href="./src/resources/alerts.ts">disable</a>(alertConfigurationId) -> Alert</code>
- <code title="post /alerts/{alert_configuration_id}/enable">client.alerts.<a href="./src/resources/alerts.ts">enable</a>(alertConfigurationId) -> Alert</code>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "orb-billing",
"version": "2.6.0",
"version": "2.6.1",
"description": "The official TypeScript library for the Orb API",
"author": "Orb <[email protected]>",
"types": "dist/index.d.ts",
Expand Down
3 changes: 0 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,7 @@ export namespace Orb {
export import AlertListParams = API.AlertListParams;
export import AlertCreateForCustomerParams = API.AlertCreateForCustomerParams;
export import AlertCreateForExternalCustomerParams = API.AlertCreateForExternalCustomerParams;
export import AlertCreateForPlanParams = API.AlertCreateForPlanParams;
export import AlertCreateForSubscriptionParams = API.AlertCreateForSubscriptionParams;
export import AlertDisableParams = API.AlertDisableParams;
export import AlertEnableParams = API.AlertEnableParams;

export import BillingCycleRelativeDate = API.BillingCycleRelativeDate;
export import Discount = API.Discount;
Expand Down
218 changes: 42 additions & 176 deletions src/resources/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,17 @@ export class Alerts extends APIResource {
}

/**
* This endpoint returns a list of all
* [`alerts`](https://docs.withorb.com/guides/product-catalog/configuring-alerts).
* This endpoint returns a list of alerts within Orb.
*
* The list of alerts is ordered starting from the most recently created alert.
* This endpoint follows Orb's
* [standardized pagination format](../reference/pagination).
*
* The request must specify one of customer_id, external_customer_id,
* subscription_id, or plan_id
* The request must specify one of `customer_id`, `external_customer_id`, or
* `subscription_id`.
*
* If querying by subscripion_id, the endpoint will return the subscription level
* alerts as well as the plan level alerts associated with the subscription.
*
* The list of alerts is ordered starting from the most recently created alert.
* This endpoint follows Orb's
* [standardized pagination format](../reference/pagination).
*/
list(query?: AlertListParams, options?: Core.RequestOptions): Core.PagePromise<AlertsPage, Alert>;
list(options?: Core.RequestOptions): Core.PagePromise<AlertsPage, Alert>;
Expand Down Expand Up @@ -78,40 +77,18 @@ export class Alerts extends APIResource {
return this._client.post(`/alerts/external_customer_id/${externalCustomerId}`, { body, ...options });
}

/**
* This endpoint is used to create alerts at the plan level. Plan level alerts are
* automatically propagated to all subscriptions associated with the plan. These
* alerts are scoped to a specific plan version; if no version is specified, the
* active plan version is used.
*
* Plan level alerts can be of two types: `usage_exceeded` or `cost_exceeded`. A
* `usage_exceeded` alert is scoped to a particular metric and is triggered when
* the usage of that metric exceeds a predefined thresholds during the current
* invoice cycle. A `cost_exceeded` alert is triggered when the total cost of the
* subscription on the plan surpasses predefined thresholds in the current invoice
* cycle.Each plan can have one `cost_exceeded` alert and one `usage_exceeded`
* alert per metric that is apart of the plan.
*/
createForPlan(
planId: string,
body: AlertCreateForPlanParams,
options?: Core.RequestOptions,
): Core.APIPromise<Alert> {
return this._client.post(`/alerts/plan_id/${planId}`, { body, ...options });
}

/**
* This endpoint is used to create alerts at the subscription level.
*
* Subscription level alerts can be one of two types: `usage_exceeded` or
* `cost_exceeded`. A `usage_exceeded` alert is scoped to a particular metric and
* is triggered when the usage of that metric exceeds a predefined thresholds
* during the current invoice cycle. A `cost_exceeded` alert is triggered when the
* total cost of the subscription surpasses predefined thresholds in the current
* invoice cycle. Each subscription can have one `cost_exceeded` alert and one
* `usage_exceeded` alert per metric that is apart of the subscription. Alerts are
* triggered based on usage or cost conditions met during the current invoice
* cycle.
* is triggered when the usage of that metric exceeds predefined thresholds during
* the current billing cycle. A `cost_exceeded` alert is triggered when the total
* amount due during the current billing cycle surpasses predefined thresholds.
* `cost_exceeded` alerts do not include burndown of pre-purchase credits. Each
* subscription can have one `cost_exceeded` alert and one `usage_exceeded` alert
* per metric that is a part of the subscription. Alerts are triggered based on
* usage or cost conditions met during the current billing cycle.
*/
createForSubscription(
subscriptionId: string,
Expand All @@ -123,85 +100,33 @@ export class Alerts extends APIResource {

/**
* This endpoint can be used to disable an alert.
*
* By default, disabling a plan level alert will apply to all subscriptions on that
* plan. In order to toggle a plan level alert for a specific subscription, the
* client must provide the plan level alert id as well as the subscription_id
* parameter.
*/
disable(
alertConfigurationId: string,
params?: AlertDisableParams,
options?: Core.RequestOptions,
): Core.APIPromise<Alert>;
disable(alertConfigurationId: string, options?: Core.RequestOptions): Core.APIPromise<Alert>;
disable(
alertConfigurationId: string,
params: AlertDisableParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.APIPromise<Alert> {
if (isRequestOptions(params)) {
return this.disable(alertConfigurationId, {}, params);
}
const { subscription_id } = params;
return this._client.post(`/alerts/${alertConfigurationId}/disable`, {
query: { subscription_id },
...options,
});
*/
disable(alertConfigurationId: string, options?: Core.RequestOptions): Core.APIPromise<Alert> {
return this._client.post(`/alerts/${alertConfigurationId}/disable`, options);
}

/**
* This endpoint can be used to enable an alert.
*
* By default, enabling a plan level alert will apply to all subscriptions on that
* plan. In order to toggle a plan level alert for a specific subscription, the
* client must provide the plan level alert id as well as the subscription_id
* parameter.
*/
enable(
alertConfigurationId: string,
params?: AlertEnableParams,
options?: Core.RequestOptions,
): Core.APIPromise<Alert>;
enable(alertConfigurationId: string, options?: Core.RequestOptions): Core.APIPromise<Alert>;
enable(
alertConfigurationId: string,
params: AlertEnableParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.APIPromise<Alert> {
if (isRequestOptions(params)) {
return this.enable(alertConfigurationId, {}, params);
}
const { subscription_id } = params;
return this._client.post(`/alerts/${alertConfigurationId}/enable`, {
query: { subscription_id },
...options,
});
*/
enable(alertConfigurationId: string, options?: Core.RequestOptions): Core.APIPromise<Alert> {
return this._client.post(`/alerts/${alertConfigurationId}/enable`, options);
}
}

export class AlertsPage extends Page<Alert> {}

/**
* An
* [Alert within Orb](https://docs.withorb.com/guides/product-catalog/configuring-alerts)
* monitors a customer's spending, usage, or credit balance and triggers a webhook
* when a threshold is exceeded.
*
* Alerts can be configured to monitor usage, cost, or credit balance. Alerts can
* be scoped to either a customer, a plan, or a subscription.
*
* Customer scoped alerts track a customer's credit balance. Valid customer alert
* types are "credit_balance_depleted", "credit_balance_recovered", and
* "credit_balance_dropped".
* [Alerts within Orb](https://docs.withorb.com/guides/product-catalog/configuring-alerts)
* monitor spending, usage, or credit balance and trigger webhooks when a threshold
* is exceeded.
*
* Subscription scoped alerts track a subscriptions's usage or cost. Valid plan
* alert types are "usage_exceeded" or "cost_exceeded".
* Alerts created through the API can be scoped to either customers or
* subscriptions.
*
* Plan scoped alerts are similar to subscriptions alerts but when a plan alert is
* created, it is propagated to all subscriptions associated with the plan.
* Disabling a plan alert will disable the alert for all subscriptions. Valid plan
* alert types are "usage_exceeded" or "cost_exceeded".
* | Scope | Monitors | Vaild Alert Types |
* | ------------ | ------------------------------ | ----------------------------------------------------------------------------------- |
* | Customer | A customer's credit balance | `credit_balance_depleted`, `credit_balance_recovered`, and `credit_balance_dropped` |
* | Subscription | A subscription's usage or cost | `usage_exceeded` and `cost_exceeded` |
*/
export interface Alert {
/**
Expand All @@ -215,7 +140,7 @@ export interface Alert {
created_at: string;

/**
* The name of the currency the credit balance for this alert is denominated in.
* The name of the currency the credit balance or invoice cost is denominated in.
*/
currency: string | null;

Expand Down Expand Up @@ -268,8 +193,9 @@ export namespace Alert {
*/
export interface Threshold {
/**
* The value at which an alert will fire. For credit balance alerts, the alert will fire at or below this value. For usage and
* cost alerts, the alert will fire at or above this value.
* The value at which an alert will fire. For credit balance alerts, the alert will
* fire at or below this value. For usage and cost alerts, the alert will fire at
* or above this value.
*/
value: number;
}
Expand All @@ -294,16 +220,6 @@ export interface AlertListParams extends PageParams {
*/
external_customer_id?: string | null;

/**
* Fetch alerts scoped to this plan_id
*/
plan_id?: string | null;

/**
* If provided alongside plan_id, only the alerts that are scoped to the specified plan_version will be returned.
*/
plan_version?: number | null;

/**
* Fetch alerts scoped to this subscription_id
*/
Expand Down Expand Up @@ -334,8 +250,9 @@ export namespace AlertCreateForCustomerParams {
*/
export interface Threshold {
/**
* The value at which an alert will fire. For credit balance alerts, the alert will fire at or below this value. For usage and
* cost alerts, the alert will fire at or above this value.
* The value at which an alert will fire. For credit balance alerts, the alert will
* fire at or below this value. For usage and cost alerts, the alert will fire at
* or above this value.
*/
value: number;
}
Expand Down Expand Up @@ -365,44 +282,9 @@ export namespace AlertCreateForExternalCustomerParams {
*/
export interface Threshold {
/**
* The value at which an alert will fire. For credit balance alerts, the alert will fire at or below this value. For usage and
* cost alerts, the alert will fire at or above this value.
*/
value: number;
}
}

export interface AlertCreateForPlanParams {
/**
* The thresholds for the alert.
*/
thresholds: Array<AlertCreateForPlanParams.Threshold>;

/**
* The thresholds that define the values at which the alert will be triggered.
*/
type: string;

/**
* The metric to track usage for.
*/
metric_id?: string | null;

/**
* The plan version to create alerts for. If not specified, the default will be the plan's active plan version.
*/
plan_version?: number | null;
}

export namespace AlertCreateForPlanParams {
/**
* Thresholds are used to define the conditions under which an alert will be
* triggered.
*/
export interface Threshold {
/**
* The value at which an alert will fire. For credit balance alerts, the alert will fire at or below this value. For usage and
* cost alerts, the alert will fire at or above this value.
* The value at which an alert will fire. For credit balance alerts, the alert will
* fire at or below this value. For usage and cost alerts, the alert will fire at
* or above this value.
*/
value: number;
}
Expand Down Expand Up @@ -432,35 +314,19 @@ export namespace AlertCreateForSubscriptionParams {
*/
export interface Threshold {
/**
* The value at which an alert will fire. For credit balance alerts, the alert will fire at or below this value. For usage and
* cost alerts, the alert will fire at or above this value.
* The value at which an alert will fire. For credit balance alerts, the alert will
* fire at or below this value. For usage and cost alerts, the alert will fire at
* or above this value.
*/
value: number;
}
}

export interface AlertDisableParams {
/**
* Used to update the status of a plan alert scoped to this subscription_id
*/
subscription_id?: string | null;
}

export interface AlertEnableParams {
/**
* Used to update the status of a plan alert scoped to this subscription_id
*/
subscription_id?: string | null;
}

export namespace Alerts {
export import Alert = AlertsAPI.Alert;
export import AlertsPage = AlertsAPI.AlertsPage;
export import AlertListParams = AlertsAPI.AlertListParams;
export import AlertCreateForCustomerParams = AlertsAPI.AlertCreateForCustomerParams;
export import AlertCreateForExternalCustomerParams = AlertsAPI.AlertCreateForExternalCustomerParams;
export import AlertCreateForPlanParams = AlertsAPI.AlertCreateForPlanParams;
export import AlertCreateForSubscriptionParams = AlertsAPI.AlertCreateForSubscriptionParams;
export import AlertDisableParams = AlertsAPI.AlertDisableParams;
export import AlertEnableParams = AlertsAPI.AlertEnableParams;
}
Loading