orb-billing 2.5.1 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,106 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
  import { APIResource } from 'orb-billing/resource';
3
+ import { isRequestOptions } from 'orb-billing/core';
4
+ import * as AlertsAPI from 'orb-billing/resources/alerts';
5
+ import { Page } from 'orb-billing/pagination';
3
6
  export class Alerts extends APIResource {
4
7
  /**
5
- * This endpoint can be used to enable an alert.
8
+ * This endpoint retrieves an alert by its ID.
6
9
  */
7
- enable(alertConfigurationId, options) {
8
- return this._client.post(`/alerts/${alertConfigurationId}/enable`, options);
10
+ retrieve(alertId, options) {
11
+ return this._client.get(`/alerts/${alertId}`, options);
9
12
  }
13
+ list(query = {}, options) {
14
+ if (isRequestOptions(query)) {
15
+ return this.list({}, query);
16
+ }
17
+ return this._client.getAPIList('/alerts', AlertsPage, { query, ...options });
18
+ }
19
+ /**
20
+ * This endpoint creates a new alert to monitor a customer's credit balance. There
21
+ * are three types of alerts that can be scoped to customers:
22
+ * `credit_balance_depleted`, `credit_balance_dropped`, and
23
+ * `credit_balance_recovered`. Customers can have a maximum of one of each type of
24
+ * alert per
25
+ * [credit balance currency](https://docs.withorb.com/guides/product-catalog/prepurchase).
26
+ * `credit_balance_dropped` alerts require a list of thresholds to be provided
27
+ * while `credit_balance_depleted` and `credit_balance_recovered` alerts do not
28
+ * require thresholds.
29
+ */
30
+ createForCustomer(customerId, body, options) {
31
+ return this._client.post(`/alerts/customer_id/${customerId}`, { body, ...options });
32
+ }
33
+ /**
34
+ * This endpoint creates a new alert to monitor a customer's credit balance. There
35
+ * are three types of alerts that can be scoped to customers:
36
+ * `credit_balance_depleted`, `credit_balance_dropped`, and
37
+ * `credit_balance_recovered`. Customers can have a maximum of one of each type of
38
+ * alert per
39
+ * [credit balance currency](https://docs.withorb.com/guides/product-catalog/prepurchase).
40
+ * `credit_balance_dropped` alerts require a list of thresholds to be provided
41
+ * while `credit_balance_depleted` and `credit_balance_recovered` alerts do not
42
+ * require thresholds.
43
+ */
44
+ createForExternalCustomer(externalCustomerId, body, options) {
45
+ return this._client.post(`/alerts/external_customer_id/${externalCustomerId}`, { body, ...options });
46
+ }
47
+ /**
48
+ * This endpoint is used to create alerts at the plan level. Plan level alerts are
49
+ * automatically propagated to all subscriptions associated with the plan. These
50
+ * alerts are scoped to a specific plan version; if no version is specified, the
51
+ * active plan version is used.
52
+ *
53
+ * Plan level alerts can be of two types: `usage_exceeded` or `cost_exceeded`. A
54
+ * `usage_exceeded` alert is scoped to a particular metric and is triggered when
55
+ * the usage of that metric exceeds a predefined thresholds during the current
56
+ * invoice cycle. A `cost_exceeded` alert is triggered when the total cost of the
57
+ * subscription on the plan surpasses predefined thresholds in the current invoice
58
+ * cycle.Each plan can have one `cost_exceeded` alert and one `usage_exceeded`
59
+ * alert per metric that is apart of the plan.
60
+ */
61
+ createForPlan(planId, body, options) {
62
+ return this._client.post(`/alerts/plan_id/${planId}`, { body, ...options });
63
+ }
64
+ /**
65
+ * This endpoint is used to create alerts at the subscription level.
66
+ *
67
+ * Subscription level alerts can be one of two types: `usage_exceeded` or
68
+ * `cost_exceeded`. A `usage_exceeded` alert is scoped to a particular metric and
69
+ * is triggered when the usage of that metric exceeds a predefined thresholds
70
+ * during the current invoice cycle. A `cost_exceeded` alert is triggered when the
71
+ * total cost of the subscription surpasses predefined thresholds in the current
72
+ * invoice cycle. Each subscription can have one `cost_exceeded` alert and one
73
+ * `usage_exceeded` alert per metric that is apart of the subscription. Alerts are
74
+ * triggered based on usage or cost conditions met during the current invoice
75
+ * cycle.
76
+ */
77
+ createForSubscription(subscriptionId, body, options) {
78
+ return this._client.post(`/alerts/subscription_id/${subscriptionId}`, { body, ...options });
79
+ }
80
+ disable(alertConfigurationId, params = {}, options) {
81
+ if (isRequestOptions(params)) {
82
+ return this.disable(alertConfigurationId, {}, params);
83
+ }
84
+ const { subscription_id } = params;
85
+ return this._client.post(`/alerts/${alertConfigurationId}/disable`, {
86
+ query: { subscription_id },
87
+ ...options,
88
+ });
89
+ }
90
+ enable(alertConfigurationId, params = {}, options) {
91
+ if (isRequestOptions(params)) {
92
+ return this.enable(alertConfigurationId, {}, params);
93
+ }
94
+ const { subscription_id } = params;
95
+ return this._client.post(`/alerts/${alertConfigurationId}/enable`, {
96
+ query: { subscription_id },
97
+ ...options,
98
+ });
99
+ }
100
+ }
101
+ export class AlertsPage extends Page {
10
102
  }
11
103
  (function (Alerts) {
104
+ Alerts.AlertsPage = AlertsAPI.AlertsPage;
12
105
  })(Alerts || (Alerts = {}));
13
106
  //# sourceMappingURL=alerts.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"alerts.mjs","sourceRoot":"","sources":["../src/resources/alerts.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAG/E,EAAE,WAAW,EAAE,MAAM,sBAAsB;AAGlD,MAAM,OAAO,MAAO,SAAQ,WAAW;IACrC;;OAEG;IACH,MAAM,CAAC,oBAA4B,EAAE,OAA6B;QAChE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,oBAAoB,SAAS,EAAE,OAAO,CAAC,CAAC;IAC9E,CAAC;CACF;AAoFD,WAAiB,MAAM;AAEvB,CAAC,EAFgB,MAAM,KAAN,MAAM,QAEtB"}
1
+ {"version":3,"file":"alerts.mjs","sourceRoot":"","sources":["../src/resources/alerts.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAG/E,EAAE,WAAW,EAAE,MAAM,sBAAsB;OAC3C,EAAE,gBAAgB,EAAE,MAAM,kBAAkB;OAC5C,KAAK,SAAS,MAAM,8BAA8B;OAClD,EAAE,IAAI,EAAmB,MAAM,wBAAwB;AAE9D,MAAM,OAAO,MAAO,SAAQ,WAAW;IACrC;;OAEG;IACH,QAAQ,CAAC,OAAe,EAAE,OAA6B;QACrD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,C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,EAC5B,SAAmD,EAAE,EACrD,OAA6B;QAE7B,IAAI,gBAAgB,CAAC,MAAM,CAAC,EAAE;YAC5B,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;SACvD;QACD,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,CAAC;QACnC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,oBAAoB,UAAU,EAAE;YAClE,KAAK,EAAE,EAAE,eAAe,EAAE;YAC1B,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;IAgBD,MAAM,CACJ,oBAA4B,EAC5B,SAAkD,EAAE,EACpD,OAA6B;QAE7B,IAAI,gBAAgB,CAAC,MAAM,CAAC,EAAE;YAC5B,OAAO,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;SACtD;QACD,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,CAAC;QACnC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,oBAAoB,SAAS,EAAE;YACjE,KAAK,EAAE,EAAE,eAAe,EAAE;YAC1B,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,OAAO,UAAW,SAAQ,IAAW;CAAG;AAiR9C,WAAiB,MAAM;IAEP,iBAAU,GAAG,SAAS,CAAC,UAAU,CAAC;AAQlD,CAAC,EAVgB,MAAM,KAAN,MAAM,QAUtB"}
@@ -1,5 +1,5 @@
1
1
  export * from "./shared.js";
2
- export { Alert, Alerts } from "./alerts.js";
2
+ export { Alert, AlertListParams, AlertCreateForCustomerParams, AlertCreateForExternalCustomerParams, AlertCreateForPlanParams, AlertCreateForSubscriptionParams, AlertDisableParams, AlertEnableParams, AlertsPage, Alerts, } from "./alerts.js";
3
3
  export { Coupon, CouponCreateParams, CouponListParams, CouponsPage, Coupons } from "./coupons/coupons.js";
4
4
  export { CreditNote, CreditNoteListParams, CreditNotesPage, CreditNotes } from "./credit-notes.js";
5
5
  export { Customer, CustomerCreateParams, CustomerUpdateParams, CustomerListParams, CustomerUpdateByExternalIDParams, CustomersPage, Customers, } from "./customers/customers.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"AAEA,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACvG,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAChG,OAAO,EACL,QAAQ,EACR,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,gCAAgC,EAChC,aAAa,EACb,SAAS,GACV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,kBAAkB,EAClB,KAAK,EACL,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,UAAU,EACV,MAAM,GACP,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,MAAM,GACP,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,OAAO,EACP,4BAA4B,EAC5B,mBAAmB,EACnB,iBAAiB,EACjB,0BAA0B,EAC1B,qBAAqB,EACrB,YAAY,EACZ,QAAQ,GACT,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,6BAA6B,EAC7B,2BAA2B,EAC3B,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,cAAc,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,SAAS,C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E,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
@@ -15,9 +15,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
16
  };
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.Webhooks = exports.TopLevel = exports.SubscriptionFetchScheduleResponsesPage = exports.SubscriptionsPage = exports.Subscriptions = exports.Plans = exports.PlansPage = exports.Metrics = exports.MetricListResponsesPage = exports.Items = exports.ItemsPage = exports.InvoiceLineItems = exports.Invoices = exports.InvoicesPage = exports.Events = exports.Prices = exports.PricesPage = exports.Customers = exports.CustomersPage = exports.CreditNotes = exports.CreditNotesPage = exports.Coupons = exports.CouponsPage = exports.Alerts = void 0;
18
+ exports.Webhooks = exports.TopLevel = exports.SubscriptionFetchScheduleResponsesPage = exports.SubscriptionsPage = exports.Subscriptions = exports.Plans = exports.PlansPage = exports.Metrics = exports.MetricListResponsesPage = exports.Items = exports.ItemsPage = exports.InvoiceLineItems = exports.Invoices = exports.InvoicesPage = exports.Events = exports.Prices = exports.PricesPage = exports.Customers = exports.CustomersPage = exports.CreditNotes = exports.CreditNotesPage = exports.Coupons = exports.CouponsPage = exports.Alerts = exports.AlertsPage = void 0;
19
19
  __exportStar(require("./shared.js"), exports);
20
20
  var alerts_1 = require("./alerts.js");
21
+ Object.defineProperty(exports, "AlertsPage", { enumerable: true, get: function () { return alerts_1.AlertsPage; } });
21
22
  Object.defineProperty(exports, "Alerts", { enumerable: true, get: function () { return alerts_1.Alerts; } });
22
23
  var coupons_1 = require("./coupons/coupons.js");
23
24
  Object.defineProperty(exports, "CouponsPage", { enumerable: true, get: function () { return coupons_1.CouponsPage; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;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SAAS,OAAA;AAEX,6CASyB;AAFvB,oGAAA,UAAU,OAAA;AACV,gGAAA,MAAM,OAAA;AAER,6CASyB;AADvB,gGAAA,MAAM,OAAA;AAER,0CASoB;AAFlB,wGAAA,YAAY,OAAA;AACZ,oGAAA,QAAQ,OAAA;AAEV,8DAI8B;AAD5B,sHAAA,gBAAgB,OAAA;AAElB,oCAAmF;AAAlC,kGAAA,SAAS,OAAA;AAAE,8FAAA,KAAK,OAAA;AACjE,wCAQmB;AAFjB,kHAAA,uBAAuB,OAAA;AACvB,kGAAA,OAAO,OAAA;AAET,0CAA2G;AAAxC,kGAAA,SAAS,OAAA;AAAE,8FAAA,KAAK,OAAA;AACnF,oDAoByB;AAjBvB,8GAAA,aAAa,OAAA;AAeb,kHAAA,iBAAiB,OAAA;AACjB,uIAAA,sCAAsC,OAAA;AAExC,4CAA6D;AAA9B,qGAAA,QAAQ,OAAA;AACvC,0CAAsC;AAA7B,oGAAA,QAAQ,OAAA"}
@@ -1,6 +1,6 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
  export * from "./shared.mjs";
3
- export { Alerts } from "./alerts.mjs";
3
+ export { AlertsPage, Alerts, } from "./alerts.mjs";
4
4
  export { CouponsPage, Coupons } from "./coupons/coupons.mjs";
5
5
  export { CreditNotesPage, CreditNotes } from "./credit-notes.mjs";
6
6
  export { CustomersPage, Customers, } from "./customers/customers.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;;OAG/E,EAAS,MAAM,EAAE;OACjB,EAAgD,WAAW,EAAE,OAAO,EAAE;OACtE,EAAoC,eAAe,EAAE,WAAW,EAAE;OAClE,EAML,aAAa,EACb,SAAS,GACV;OACM,EAOL,UAAU,EACV,MAAM,GACP;OACM,EAQL,MAAM,GACP;OACM,EAOL,YAAY,EACZ,QAAQ,GACT;OACM,EAGL,gBAAgB,GACjB;OACM,EAA0C,SAAS,EAAE,KAAK,EAAE;OAC5D,EAML,uBAAuB,EACvB,OAAO,GACR;OACM,EAA4D,SAAS,EAAE,KAAK,EAAE;OAC9E,EAGL,aAAa,EAeb,iBAAiB,EACjB,sCAAsC,GACvC;OACM,EAAwB,QAAQ,EAAE;OAClC,EAAE,QAAQ,EAAE"}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;;OAG/E,EASL,UAAU,EACV,MAAM,GACP;OACM,EAAgD,WAAW,EAAE,OAAO,EAAE;OACtE,EAAoC,eAAe,EAAE,WAAW,EAAE;OAClE,EAML,aAAa,EACb,SAAS,GACV;OACM,EAOL,UAAU,EACV,MAAM,GACP;OACM,EAQL,MAAM,GACP;OACM,EAOL,YAAY,EACZ,QAAQ,GACT;OACM,EAGL,gBAAgB,GACjB;OACM,EAA0C,SAAS,EAAE,KAAK,EAAE;OAC5D,EAML,uBAAuB,EACvB,OAAO,GACR;OACM,EAA4D,SAAS,EAAE,KAAK,EAAE;OAC9E,EAGL,aAAa,EAeb,iBAAiB,EACjB,sCAAsC,GACvC;OACM,EAAwB,QAAQ,EAAE;OAClC,EAAE,QAAQ,EAAE"}
@@ -896,7 +896,7 @@ export interface Subscription {
896
896
  /**
897
897
  * Determines whether issued invoices for this subscription will automatically be
898
898
  * charged with the saved payment method on the due date. This property defaults to
899
- * the plan's behavior.
899
+ * the plan's behavior. If null, defaults to the customer's setting.
900
900
  */
901
901
  auto_collection: boolean | null;
902
902
  /**
package/src/index.ts CHANGED
@@ -329,6 +329,14 @@ export namespace Orb {
329
329
 
330
330
  export import Alerts = API.Alerts;
331
331
  export import Alert = API.Alert;
332
+ export import AlertsPage = API.AlertsPage;
333
+ export import AlertListParams = API.AlertListParams;
334
+ export import AlertCreateForCustomerParams = API.AlertCreateForCustomerParams;
335
+ export import AlertCreateForExternalCustomerParams = API.AlertCreateForExternalCustomerParams;
336
+ export import AlertCreateForPlanParams = API.AlertCreateForPlanParams;
337
+ export import AlertCreateForSubscriptionParams = API.AlertCreateForSubscriptionParams;
338
+ export import AlertDisableParams = API.AlertDisableParams;
339
+ export import AlertEnableParams = API.AlertEnableParams;
332
340
 
333
341
  export import BillingCycleRelativeDate = API.BillingCycleRelativeDate;
334
342
  export import Discount = API.Discount;
@@ -2,17 +2,186 @@
2
2
 
3
3
  import * as Core from "../core";
4
4
  import { APIResource } from "../resource";
5
+ import { isRequestOptions } from "../core";
5
6
  import * as AlertsAPI from "./alerts";
7
+ import { Page, type PageParams } from "../pagination";
6
8
 
7
9
  export class Alerts extends APIResource {
10
+ /**
11
+ * This endpoint retrieves an alert by its ID.
12
+ */
13
+ retrieve(alertId: string, options?: Core.RequestOptions): Core.APIPromise<Alert> {
14
+ return this._client.get(`/alerts/${alertId}`, options);
15
+ }
16
+
17
+ /**
18
+ * This endpoint returns a list of all
19
+ * [`alerts`](https://docs.withorb.com/guides/product-catalog/configuring-alerts).
20
+ *
21
+ * The list of alerts is ordered starting from the most recently created alert.
22
+ * This endpoint follows Orb's
23
+ * [standardized pagination format](../reference/pagination).
24
+ *
25
+ * The request must specify one of customer_id, external_customer_id,
26
+ * subscription_id, or plan_id
27
+ *
28
+ * If querying by subscripion_id, the endpoint will return the subscription level
29
+ * alerts as well as the plan level alerts associated with the subscription.
30
+ */
31
+ list(query?: AlertListParams, options?: Core.RequestOptions): Core.PagePromise<AlertsPage, Alert>;
32
+ list(options?: Core.RequestOptions): Core.PagePromise<AlertsPage, Alert>;
33
+ list(
34
+ query: AlertListParams | Core.RequestOptions = {},
35
+ options?: Core.RequestOptions,
36
+ ): Core.PagePromise<AlertsPage, Alert> {
37
+ if (isRequestOptions(query)) {
38
+ return this.list({}, query);
39
+ }
40
+ return this._client.getAPIList('/alerts', AlertsPage, { query, ...options });
41
+ }
42
+
43
+ /**
44
+ * This endpoint creates a new alert to monitor a customer's credit balance. There
45
+ * are three types of alerts that can be scoped to customers:
46
+ * `credit_balance_depleted`, `credit_balance_dropped`, and
47
+ * `credit_balance_recovered`. Customers can have a maximum of one of each type of
48
+ * alert per
49
+ * [credit balance currency](https://docs.withorb.com/guides/product-catalog/prepurchase).
50
+ * `credit_balance_dropped` alerts require a list of thresholds to be provided
51
+ * while `credit_balance_depleted` and `credit_balance_recovered` alerts do not
52
+ * require thresholds.
53
+ */
54
+ createForCustomer(
55
+ customerId: string,
56
+ body: AlertCreateForCustomerParams,
57
+ options?: Core.RequestOptions,
58
+ ): Core.APIPromise<Alert> {
59
+ return this._client.post(`/alerts/customer_id/${customerId}`, { body, ...options });
60
+ }
61
+
62
+ /**
63
+ * This endpoint creates a new alert to monitor a customer's credit balance. There
64
+ * are three types of alerts that can be scoped to customers:
65
+ * `credit_balance_depleted`, `credit_balance_dropped`, and
66
+ * `credit_balance_recovered`. Customers can have a maximum of one of each type of
67
+ * alert per
68
+ * [credit balance currency](https://docs.withorb.com/guides/product-catalog/prepurchase).
69
+ * `credit_balance_dropped` alerts require a list of thresholds to be provided
70
+ * while `credit_balance_depleted` and `credit_balance_recovered` alerts do not
71
+ * require thresholds.
72
+ */
73
+ createForExternalCustomer(
74
+ externalCustomerId: string,
75
+ body: AlertCreateForExternalCustomerParams,
76
+ options?: Core.RequestOptions,
77
+ ): Core.APIPromise<Alert> {
78
+ return this._client.post(`/alerts/external_customer_id/${externalCustomerId}`, { body, ...options });
79
+ }
80
+
81
+ /**
82
+ * This endpoint is used to create alerts at the plan level. Plan level alerts are
83
+ * automatically propagated to all subscriptions associated with the plan. These
84
+ * alerts are scoped to a specific plan version; if no version is specified, the
85
+ * active plan version is used.
86
+ *
87
+ * Plan level alerts can be of two types: `usage_exceeded` or `cost_exceeded`. A
88
+ * `usage_exceeded` alert is scoped to a particular metric and is triggered when
89
+ * the usage of that metric exceeds a predefined thresholds during the current
90
+ * invoice cycle. A `cost_exceeded` alert is triggered when the total cost of the
91
+ * subscription on the plan surpasses predefined thresholds in the current invoice
92
+ * cycle.Each plan can have one `cost_exceeded` alert and one `usage_exceeded`
93
+ * alert per metric that is apart of the plan.
94
+ */
95
+ createForPlan(
96
+ planId: string,
97
+ body: AlertCreateForPlanParams,
98
+ options?: Core.RequestOptions,
99
+ ): Core.APIPromise<Alert> {
100
+ return this._client.post(`/alerts/plan_id/${planId}`, { body, ...options });
101
+ }
102
+
103
+ /**
104
+ * This endpoint is used to create alerts at the subscription level.
105
+ *
106
+ * Subscription level alerts can be one of two types: `usage_exceeded` or
107
+ * `cost_exceeded`. A `usage_exceeded` alert is scoped to a particular metric and
108
+ * is triggered when the usage of that metric exceeds a predefined thresholds
109
+ * during the current invoice cycle. A `cost_exceeded` alert is triggered when the
110
+ * total cost of the subscription surpasses predefined thresholds in the current
111
+ * invoice cycle. Each subscription can have one `cost_exceeded` alert and one
112
+ * `usage_exceeded` alert per metric that is apart of the subscription. Alerts are
113
+ * triggered based on usage or cost conditions met during the current invoice
114
+ * cycle.
115
+ */
116
+ createForSubscription(
117
+ subscriptionId: string,
118
+ body: AlertCreateForSubscriptionParams,
119
+ options?: Core.RequestOptions,
120
+ ): Core.APIPromise<Alert> {
121
+ return this._client.post(`/alerts/subscription_id/${subscriptionId}`, { body, ...options });
122
+ }
123
+
124
+ /**
125
+ * This endpoint can be used to disable an alert.
126
+ *
127
+ * By default, disabling a plan level alert will apply to all subscriptions on that
128
+ * plan. In order to toggle a plan level alert for a specific subscription, the
129
+ * client must provide the plan level alert id as well as the subscription_id
130
+ * parameter.
131
+ */
132
+ disable(
133
+ alertConfigurationId: string,
134
+ params?: AlertDisableParams,
135
+ options?: Core.RequestOptions,
136
+ ): Core.APIPromise<Alert>;
137
+ disable(alertConfigurationId: string, options?: Core.RequestOptions): Core.APIPromise<Alert>;
138
+ disable(
139
+ alertConfigurationId: string,
140
+ params: AlertDisableParams | Core.RequestOptions = {},
141
+ options?: Core.RequestOptions,
142
+ ): Core.APIPromise<Alert> {
143
+ if (isRequestOptions(params)) {
144
+ return this.disable(alertConfigurationId, {}, params);
145
+ }
146
+ const { subscription_id } = params;
147
+ return this._client.post(`/alerts/${alertConfigurationId}/disable`, {
148
+ query: { subscription_id },
149
+ ...options,
150
+ });
151
+ }
152
+
8
153
  /**
9
154
  * This endpoint can be used to enable an alert.
155
+ *
156
+ * By default, enabling a plan level alert will apply to all subscriptions on that
157
+ * plan. In order to toggle a plan level alert for a specific subscription, the
158
+ * client must provide the plan level alert id as well as the subscription_id
159
+ * parameter.
10
160
  */
11
- enable(alertConfigurationId: string, options?: Core.RequestOptions): Core.APIPromise<Alert> {
12
- return this._client.post(`/alerts/${alertConfigurationId}/enable`, options);
161
+ enable(
162
+ alertConfigurationId: string,
163
+ params?: AlertEnableParams,
164
+ options?: Core.RequestOptions,
165
+ ): Core.APIPromise<Alert>;
166
+ enable(alertConfigurationId: string, options?: Core.RequestOptions): Core.APIPromise<Alert>;
167
+ enable(
168
+ alertConfigurationId: string,
169
+ params: AlertEnableParams | Core.RequestOptions = {},
170
+ options?: Core.RequestOptions,
171
+ ): Core.APIPromise<Alert> {
172
+ if (isRequestOptions(params)) {
173
+ return this.enable(alertConfigurationId, {}, params);
174
+ }
175
+ const { subscription_id } = params;
176
+ return this._client.post(`/alerts/${alertConfigurationId}/enable`, {
177
+ query: { subscription_id },
178
+ ...options,
179
+ });
13
180
  }
14
181
  }
15
182
 
183
+ export class AlertsPage extends Page<Alert> {}
184
+
16
185
  /**
17
186
  * An
18
187
  * [Alert within Orb](https://docs.withorb.com/guides/product-catalog/configuring-alerts)
@@ -51,7 +220,7 @@ export interface Alert {
51
220
  currency: string | null;
52
221
 
53
222
  /**
54
- * The customer that the alert is scoped to.
223
+ * The customer the alert applies to.
55
224
  */
56
225
  customer: Record<string, string | null> | null;
57
226
 
@@ -60,13 +229,19 @@ export interface Alert {
60
229
  */
61
230
  enabled: boolean;
62
231
 
232
+ /**
233
+ * The metric the alert applies to.
234
+ */
63
235
  metric: Record<string, string | null> | null;
64
236
 
65
237
  /**
66
- * The plan that the alert is scoped to.
238
+ * The plan the alert applies to.
67
239
  */
68
240
  plan: Record<string, string | null> | null;
69
241
 
242
+ /**
243
+ * The subscription the alert applies to.
244
+ */
70
245
  subscription: Record<string, string | null> | null;
71
246
 
72
247
  /**
@@ -78,7 +253,12 @@ export interface Alert {
78
253
  /**
79
254
  * The type of alert. This must be a valid alert type.
80
255
  */
81
- type: 'credit_balance_depleted' | 'credit_balance_dropped' | 'credit_balance_recovered';
256
+ type:
257
+ | 'usage_exceeded'
258
+ | 'cost_exceeded'
259
+ | 'credit_balance_depleted'
260
+ | 'credit_balance_dropped'
261
+ | 'credit_balance_recovered';
82
262
  }
83
263
 
84
264
  export namespace Alert {
@@ -95,6 +275,192 @@ export namespace Alert {
95
275
  }
96
276
  }
97
277
 
278
+ export interface AlertListParams extends PageParams {
279
+ 'created_at[gt]'?: string | null;
280
+
281
+ 'created_at[gte]'?: string | null;
282
+
283
+ 'created_at[lt]'?: string | null;
284
+
285
+ 'created_at[lte]'?: string | null;
286
+
287
+ /**
288
+ * Fetch alerts scoped to this customer_id
289
+ */
290
+ customer_id?: string | null;
291
+
292
+ /**
293
+ * Fetch alerts scoped to this external_customer_id
294
+ */
295
+ external_customer_id?: string | null;
296
+
297
+ /**
298
+ * Fetch alerts scoped to this plan_id
299
+ */
300
+ plan_id?: string | null;
301
+
302
+ /**
303
+ * If provided alongside plan_id, only the alerts that are scoped to the specified plan_version will be returned.
304
+ */
305
+ plan_version?: number | null;
306
+
307
+ /**
308
+ * Fetch alerts scoped to this subscription_id
309
+ */
310
+ subscription_id?: string | null;
311
+ }
312
+
313
+ export interface AlertCreateForCustomerParams {
314
+ /**
315
+ * The case sensitive currency or custom pricing unit to use for this alert.
316
+ */
317
+ currency: string;
318
+
319
+ /**
320
+ * The thresholds that define the values at which the alert will be triggered.
321
+ */
322
+ type: string;
323
+
324
+ /**
325
+ * The thresholds for the alert.
326
+ */
327
+ thresholds?: Array<AlertCreateForCustomerParams.Threshold> | null;
328
+ }
329
+
330
+ export namespace AlertCreateForCustomerParams {
331
+ /**
332
+ * Thresholds are used to define the conditions under which an alert will be
333
+ * triggered.
334
+ */
335
+ export interface Threshold {
336
+ /**
337
+ * The value at which an alert will fire. For credit balance alerts, the alert will fire at or below this value. For usage and
338
+ * cost alerts, the alert will fire at or above this value.
339
+ */
340
+ value: number;
341
+ }
342
+ }
343
+
344
+ export interface AlertCreateForExternalCustomerParams {
345
+ /**
346
+ * The case sensitive currency or custom pricing unit to use for this alert.
347
+ */
348
+ currency: string;
349
+
350
+ /**
351
+ * The thresholds that define the values at which the alert will be triggered.
352
+ */
353
+ type: string;
354
+
355
+ /**
356
+ * The thresholds for the alert.
357
+ */
358
+ thresholds?: Array<AlertCreateForExternalCustomerParams.Threshold> | null;
359
+ }
360
+
361
+ export namespace AlertCreateForExternalCustomerParams {
362
+ /**
363
+ * Thresholds are used to define the conditions under which an alert will be
364
+ * triggered.
365
+ */
366
+ export interface Threshold {
367
+ /**
368
+ * The value at which an alert will fire. For credit balance alerts, the alert will fire at or below this value. For usage and
369
+ * cost alerts, the alert will fire at or above this value.
370
+ */
371
+ value: number;
372
+ }
373
+ }
374
+
375
+ export interface AlertCreateForPlanParams {
376
+ /**
377
+ * The thresholds for the alert.
378
+ */
379
+ thresholds: Array<AlertCreateForPlanParams.Threshold>;
380
+
381
+ /**
382
+ * The thresholds that define the values at which the alert will be triggered.
383
+ */
384
+ type: string;
385
+
386
+ /**
387
+ * The metric to track usage for.
388
+ */
389
+ metric_id?: string | null;
390
+
391
+ /**
392
+ * The plan version to create alerts for. If not specified, the default will be the plan's active plan version.
393
+ */
394
+ plan_version?: number | null;
395
+ }
396
+
397
+ export namespace AlertCreateForPlanParams {
398
+ /**
399
+ * Thresholds are used to define the conditions under which an alert will be
400
+ * triggered.
401
+ */
402
+ export interface Threshold {
403
+ /**
404
+ * The value at which an alert will fire. For credit balance alerts, the alert will fire at or below this value. For usage and
405
+ * cost alerts, the alert will fire at or above this value.
406
+ */
407
+ value: number;
408
+ }
409
+ }
410
+
411
+ export interface AlertCreateForSubscriptionParams {
412
+ /**
413
+ * The thresholds for the alert.
414
+ */
415
+ thresholds: Array<AlertCreateForSubscriptionParams.Threshold>;
416
+
417
+ /**
418
+ * The thresholds that define the values at which the alert will be triggered.
419
+ */
420
+ type: string;
421
+
422
+ /**
423
+ * The metric to track usage for.
424
+ */
425
+ metric_id?: string | null;
426
+ }
427
+
428
+ export namespace AlertCreateForSubscriptionParams {
429
+ /**
430
+ * Thresholds are used to define the conditions under which an alert will be
431
+ * triggered.
432
+ */
433
+ export interface Threshold {
434
+ /**
435
+ * The value at which an alert will fire. For credit balance alerts, the alert will fire at or below this value. For usage and
436
+ * cost alerts, the alert will fire at or above this value.
437
+ */
438
+ value: number;
439
+ }
440
+ }
441
+
442
+ export interface AlertDisableParams {
443
+ /**
444
+ * Used to update the status of a plan alert scoped to this subscription_id
445
+ */
446
+ subscription_id?: string | null;
447
+ }
448
+
449
+ export interface AlertEnableParams {
450
+ /**
451
+ * Used to update the status of a plan alert scoped to this subscription_id
452
+ */
453
+ subscription_id?: string | null;
454
+ }
455
+
98
456
  export namespace Alerts {
99
457
  export import Alert = AlertsAPI.Alert;
458
+ export import AlertsPage = AlertsAPI.AlertsPage;
459
+ export import AlertListParams = AlertsAPI.AlertListParams;
460
+ export import AlertCreateForCustomerParams = AlertsAPI.AlertCreateForCustomerParams;
461
+ export import AlertCreateForExternalCustomerParams = AlertsAPI.AlertCreateForExternalCustomerParams;
462
+ export import AlertCreateForPlanParams = AlertsAPI.AlertCreateForPlanParams;
463
+ export import AlertCreateForSubscriptionParams = AlertsAPI.AlertCreateForSubscriptionParams;
464
+ export import AlertDisableParams = AlertsAPI.AlertDisableParams;
465
+ export import AlertEnableParams = AlertsAPI.AlertEnableParams;
100
466
  }
@@ -1,7 +1,18 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  export * from './shared';
4
- export { Alert, Alerts } from './alerts';
4
+ export {
5
+ Alert,
6
+ AlertListParams,
7
+ AlertCreateForCustomerParams,
8
+ AlertCreateForExternalCustomerParams,
9
+ AlertCreateForPlanParams,
10
+ AlertCreateForSubscriptionParams,
11
+ AlertDisableParams,
12
+ AlertEnableParams,
13
+ AlertsPage,
14
+ Alerts,
15
+ } from './alerts';
5
16
  export { Coupon, CouponCreateParams, CouponListParams, CouponsPage, Coupons } from './coupons/coupons';
6
17
  export { CreditNote, CreditNoteListParams, CreditNotesPage, CreditNotes } from './credit-notes';
7
18
  export {
@@ -1074,7 +1074,7 @@ export interface Subscription {
1074
1074
  /**
1075
1075
  * Determines whether issued invoices for this subscription will automatically be
1076
1076
  * charged with the saved payment method on the due date. This property defaults to
1077
- * the plan's behavior.
1077
+ * the plan's behavior. If null, defaults to the customer's setting.
1078
1078
  */
1079
1079
  auto_collection: boolean | null;
1080
1080
 
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '2.5.1'; // x-release-please-version
1
+ export const VERSION = '2.6.0'; // x-release-please-version
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.5.1";
1
+ export declare const VERSION = "2.6.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '2.5.1'; // x-release-please-version
4
+ exports.VERSION = '2.6.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map