orb-billing 2.4.0 → 2.5.1

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/index.d.mts +224 -5
  3. package/index.d.ts +224 -5
  4. package/index.d.ts.map +1 -1
  5. package/index.js +132 -10
  6. package/index.js.map +1 -1
  7. package/index.mjs +129 -5
  8. package/index.mjs.map +1 -1
  9. package/package.json +1 -1
  10. package/resources/alerts.d.ts +84 -0
  11. package/resources/alerts.d.ts.map +1 -0
  12. package/resources/alerts.js +17 -0
  13. package/resources/alerts.js.map +1 -0
  14. package/resources/alerts.mjs +13 -0
  15. package/resources/alerts.mjs.map +1 -0
  16. package/resources/customers/customers.d.ts +592 -432
  17. package/resources/customers/customers.d.ts.map +1 -1
  18. package/resources/customers/customers.js.map +1 -1
  19. package/resources/customers/customers.mjs.map +1 -1
  20. package/resources/index.d.ts +1 -0
  21. package/resources/index.d.ts.map +1 -1
  22. package/resources/index.js +3 -1
  23. package/resources/index.js.map +1 -1
  24. package/resources/index.mjs +1 -0
  25. package/resources/index.mjs.map +1 -1
  26. package/resources/invoices.d.ts +296 -216
  27. package/resources/invoices.d.ts.map +1 -1
  28. package/resources/invoices.js.map +1 -1
  29. package/resources/invoices.mjs.map +1 -1
  30. package/src/index.ts +303 -6
  31. package/src/resources/alerts.ts +100 -0
  32. package/src/resources/customers/customers.ts +728 -424
  33. package/src/resources/index.ts +1 -0
  34. package/src/resources/invoices.ts +364 -212
  35. package/src/version.ts +1 -1
  36. package/version.d.ts +1 -1
  37. package/version.js +1 -1
  38. package/version.mjs +1 -1
  39. package/client.d.ts +0 -222
  40. package/client.d.ts.map +0 -1
  41. package/client.js +0 -156
  42. package/client.js.map +0 -1
  43. package/client.mjs +0 -129
  44. package/client.mjs.map +0 -1
  45. package/src/client.ts +0 -301
package/index.js CHANGED
@@ -23,19 +23,141 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  __setModuleDefault(result, mod);
24
24
  return result;
25
25
  };
26
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
27
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
28
- };
26
+ var _a;
29
27
  Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.DuplicateResourceCreation = exports.UnprocessableEntityError = exports.OrbInternalServerError = exports.OrbAuthenticationError = exports.RequestValidationError = exports.PermissionDeniedError = exports.FeatureNotAvailable = exports.ConstraintViolation = exports.InternalServerError = exports.AuthenticationError = exports.ResourceTooLarge = exports.ResourceConflict = exports.ResourceNotFound = exports.TooManyRequests = exports.RequestTooLarge = exports.BadRequestError = exports.RateLimitError = exports.ConflictError = exports.NotFoundError = exports.URLNotFound = exports.APIUserAbortError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIError = exports.OrbError = exports.fileFromPath = exports.toFile = exports.Orb = void 0;
28
+ exports.fileFromPath = exports.toFile = exports.DuplicateResourceCreation = exports.UnprocessableEntityError = exports.OrbInternalServerError = exports.OrbAuthenticationError = exports.RequestValidationError = exports.PermissionDeniedError = exports.FeatureNotAvailable = exports.ConstraintViolation = exports.InternalServerError = exports.AuthenticationError = exports.ResourceTooLarge = exports.ResourceConflict = exports.ResourceNotFound = exports.TooManyRequests = exports.RequestTooLarge = exports.BadRequestError = exports.RateLimitError = exports.ConflictError = exports.NotFoundError = exports.URLNotFound = exports.APIUserAbortError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIError = exports.OrbError = exports.Orb = void 0;
29
+ const Core = __importStar(require("./core.js"));
31
30
  const Errors = __importStar(require("./error.js"));
32
31
  const Uploads = __importStar(require("./uploads.js"));
33
- const client_1 = require("./client.js");
34
- Object.defineProperty(exports, "Orb", { enumerable: true, get: function () { return client_1.Orb; } });
35
- exports = module.exports = client_1;
36
- exports.default = client_1.Orb;
32
+ const qs = __importStar(require("qs"));
33
+ const Pagination = __importStar(require("orb-billing/pagination"));
34
+ const API = __importStar(require("orb-billing/resources/index"));
35
+ /** API Client for interfacing with the Orb API. */
36
+ class Orb extends Core.APIClient {
37
+ /**
38
+ * API Client for interfacing with the Orb API.
39
+ *
40
+ * @param {string | undefined} [opts.apiKey=process.env['ORB_API_KEY'] ?? undefined]
41
+ * @param {string | null | undefined} [opts.webhookSecret=process.env['ORB_WEBHOOK_SECRET'] ?? null]
42
+ * @param {string} [opts.baseURL=process.env['ORB_BASE_URL'] ?? https://api.withorb.com/v1] - Override the default base URL for the API.
43
+ * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
44
+ * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
45
+ * @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
46
+ * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
47
+ * @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
48
+ * @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
49
+ */
50
+ constructor({ baseURL = Core.readEnv('ORB_BASE_URL'), apiKey = Core.readEnv('ORB_API_KEY'), webhookSecret = Core.readEnv('ORB_WEBHOOK_SECRET') ?? null, ...opts } = {}) {
51
+ if (apiKey === undefined) {
52
+ throw new Errors.OrbError("The ORB_API_KEY environment variable is missing or empty; either provide it, or instantiate the Orb client with an apiKey option, like new Orb({ apiKey: 'My API Key' }).");
53
+ }
54
+ const options = {
55
+ apiKey,
56
+ webhookSecret,
57
+ ...opts,
58
+ baseURL: baseURL || `https://api.withorb.com/v1`,
59
+ };
60
+ super({
61
+ baseURL: options.baseURL,
62
+ timeout: options.timeout ?? 60000 /* 1 minute */,
63
+ httpAgent: options.httpAgent,
64
+ maxRetries: options.maxRetries,
65
+ fetch: options.fetch,
66
+ });
67
+ this.topLevel = new API.TopLevel(this);
68
+ this.coupons = new API.Coupons(this);
69
+ this.creditNotes = new API.CreditNotes(this);
70
+ this.customers = new API.Customers(this);
71
+ this.events = new API.Events(this);
72
+ this.invoiceLineItems = new API.InvoiceLineItems(this);
73
+ this.invoices = new API.Invoices(this);
74
+ this.items = new API.Items(this);
75
+ this.metrics = new API.Metrics(this);
76
+ this.plans = new API.Plans(this);
77
+ this.prices = new API.Prices(this);
78
+ this.subscriptions = new API.Subscriptions(this);
79
+ this.webhooks = new API.Webhooks(this);
80
+ this.alerts = new API.Alerts(this);
81
+ this._options = options;
82
+ this.idempotencyHeader = 'Idempotency-Key';
83
+ this.apiKey = apiKey;
84
+ this.webhookSecret = webhookSecret;
85
+ }
86
+ defaultQuery() {
87
+ return this._options.defaultQuery;
88
+ }
89
+ defaultHeaders(opts) {
90
+ return {
91
+ ...super.defaultHeaders(opts),
92
+ ...this._options.defaultHeaders,
93
+ };
94
+ }
95
+ authHeaders(opts) {
96
+ return { Authorization: `Bearer ${this.apiKey}` };
97
+ }
98
+ stringifyQuery(query) {
99
+ return qs.stringify(query, { arrayFormat: 'brackets' });
100
+ }
101
+ }
102
+ exports.Orb = Orb;
103
+ _a = Orb;
104
+ Orb.Orb = _a;
105
+ Orb.OrbError = Errors.OrbError;
106
+ Orb.APIError = Errors.APIError;
107
+ Orb.APIConnectionError = Errors.APIConnectionError;
108
+ Orb.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
109
+ Orb.APIUserAbortError = Errors.APIUserAbortError;
110
+ Orb.URLNotFound = Errors.URLNotFound;
111
+ Orb.NotFoundError = Errors.NotFoundError;
112
+ Orb.ConflictError = Errors.ConflictError;
113
+ Orb.RateLimitError = Errors.RateLimitError;
114
+ Orb.BadRequestError = Errors.BadRequestError;
115
+ Orb.RequestTooLarge = Errors.RequestTooLarge;
116
+ Orb.TooManyRequests = Errors.TooManyRequests;
117
+ Orb.ResourceNotFound = Errors.ResourceNotFound;
118
+ Orb.ResourceConflict = Errors.ResourceConflict;
119
+ Orb.ResourceTooLarge = Errors.ResourceTooLarge;
120
+ Orb.AuthenticationError = Errors.AuthenticationError;
121
+ Orb.InternalServerError = Errors.InternalServerError;
122
+ Orb.ConstraintViolation = Errors.ConstraintViolation;
123
+ Orb.FeatureNotAvailable = Errors.FeatureNotAvailable;
124
+ Orb.PermissionDeniedError = Errors.PermissionDeniedError;
125
+ Orb.RequestValidationError = Errors.RequestValidationError;
126
+ Orb.OrbAuthenticationError = Errors.OrbAuthenticationError;
127
+ Orb.OrbInternalServerError = Errors.OrbInternalServerError;
128
+ Orb.UnprocessableEntityError = Errors.UnprocessableEntityError;
129
+ Orb.DuplicateResourceCreation = Errors.DuplicateResourceCreation;
130
+ Orb.toFile = Uploads.toFile;
131
+ Orb.fileFromPath = Uploads.fileFromPath;
132
+ exports.OrbError = Errors.OrbError, exports.APIError = Errors.APIError, exports.APIConnectionError = Errors.APIConnectionError, exports.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError, exports.APIUserAbortError = Errors.APIUserAbortError, exports.URLNotFound = Errors.URLNotFound, exports.NotFoundError = Errors.NotFoundError, exports.ConflictError = Errors.ConflictError, exports.RateLimitError = Errors.RateLimitError, exports.BadRequestError = Errors.BadRequestError, exports.RequestTooLarge = Errors.RequestTooLarge, exports.TooManyRequests = Errors.TooManyRequests, exports.ResourceNotFound = Errors.ResourceNotFound, exports.ResourceConflict = Errors.ResourceConflict, exports.ResourceTooLarge = Errors.ResourceTooLarge, exports.AuthenticationError = Errors.AuthenticationError, exports.InternalServerError = Errors.InternalServerError, exports.ConstraintViolation = Errors.ConstraintViolation, exports.FeatureNotAvailable = Errors.FeatureNotAvailable, exports.PermissionDeniedError = Errors.PermissionDeniedError, exports.RequestValidationError = Errors.RequestValidationError, exports.OrbAuthenticationError = Errors.OrbAuthenticationError, exports.OrbInternalServerError = Errors.OrbInternalServerError, exports.UnprocessableEntityError = Errors.UnprocessableEntityError, exports.DuplicateResourceCreation = Errors.DuplicateResourceCreation;
37
133
  exports.toFile = Uploads.toFile;
38
134
  exports.fileFromPath = Uploads.fileFromPath;
39
- exports.OrbError = Errors.OrbError, exports.APIError = Errors.APIError, exports.APIConnectionError = Errors.APIConnectionError, exports.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError, exports.APIUserAbortError = Errors.APIUserAbortError, exports.URLNotFound = Errors.URLNotFound, exports.NotFoundError = Errors.NotFoundError, exports.ConflictError = Errors.ConflictError, exports.RateLimitError = Errors.RateLimitError, exports.BadRequestError = Errors.BadRequestError, exports.RequestTooLarge = Errors.RequestTooLarge, exports.TooManyRequests = Errors.TooManyRequests, exports.ResourceNotFound = Errors.ResourceNotFound, exports.ResourceConflict = Errors.ResourceConflict, exports.ResourceTooLarge = Errors.ResourceTooLarge, exports.AuthenticationError = Errors.AuthenticationError, exports.InternalServerError = Errors.InternalServerError, exports.ConstraintViolation = Errors.ConstraintViolation, exports.FeatureNotAvailable = Errors.FeatureNotAvailable, exports.PermissionDeniedError = Errors.PermissionDeniedError, exports.RequestValidationError = Errors.RequestValidationError, exports.OrbAuthenticationError = Errors.OrbAuthenticationError, exports.OrbInternalServerError = Errors.OrbInternalServerError, exports.UnprocessableEntityError = Errors.UnprocessableEntityError, exports.DuplicateResourceCreation = Errors.DuplicateResourceCreation;
40
- __exportStar(require("./client.js"), exports);
135
+ (function (Orb) {
136
+ Orb.Page = Pagination.Page;
137
+ Orb.TopLevel = API.TopLevel;
138
+ Orb.Coupons = API.Coupons;
139
+ Orb.CouponsPage = API.CouponsPage;
140
+ Orb.CreditNotes = API.CreditNotes;
141
+ Orb.CreditNotesPage = API.CreditNotesPage;
142
+ Orb.Customers = API.Customers;
143
+ Orb.CustomersPage = API.CustomersPage;
144
+ Orb.Events = API.Events;
145
+ Orb.InvoiceLineItems = API.InvoiceLineItems;
146
+ Orb.Invoices = API.Invoices;
147
+ Orb.InvoicesPage = API.InvoicesPage;
148
+ Orb.Items = API.Items;
149
+ Orb.ItemsPage = API.ItemsPage;
150
+ Orb.Metrics = API.Metrics;
151
+ Orb.MetricListResponsesPage = API.MetricListResponsesPage;
152
+ Orb.Plans = API.Plans;
153
+ Orb.PlansPage = API.PlansPage;
154
+ Orb.Prices = API.Prices;
155
+ Orb.PricesPage = API.PricesPage;
156
+ Orb.Subscriptions = API.Subscriptions;
157
+ Orb.SubscriptionsPage = API.SubscriptionsPage;
158
+ Orb.SubscriptionFetchScheduleResponsesPage = API.SubscriptionFetchScheduleResponsesPage;
159
+ Orb.Alerts = API.Alerts;
160
+ })(Orb = exports.Orb || (exports.Orb = {}));
161
+ exports = module.exports = Orb;
162
+ exports.default = Orb;
41
163
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtF,mDAAkC;AAClC,sDAAqC;AACrC,wCAA+B;AAEtB,oFAFA,YAAG,OAEA;AACZ,kBAAe,YAAG,CAAC;AAEL,QAAA,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;AACxB,QAAA,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;AAGhD,gBAAQ,GAyBN,MAAM,WAxBR,gBAAQ,GAwBN,MAAM,WAvBR,0BAAkB,GAuBhB,MAAM,qBAtBR,iCAAyB,GAsBvB,MAAM,4BArBR,yBAAiB,GAqBf,MAAM,oBApBR,mBAAW,GAoBT,MAAM,cAnBR,qBAAa,GAmBX,MAAM,gBAlBR,qBAAa,GAkBX,MAAM,gBAjBR,sBAAc,GAiBZ,MAAM,iBAhBR,uBAAe,GAgBb,MAAM,kBAfR,uBAAe,GAeb,MAAM,kBAdR,uBAAe,GAcb,MAAM,kBAbR,wBAAgB,GAad,MAAM,mBAZR,wBAAgB,GAYd,MAAM,mBAXR,wBAAgB,GAWd,MAAM,mBAVR,2BAAmB,GAUjB,MAAM,sBATR,2BAAmB,GASjB,MAAM,sBARR,2BAAmB,GAQjB,MAAM,sBAPR,2BAAmB,GAOjB,MAAM,sBANR,6BAAqB,GAMnB,MAAM,wBALR,8BAAsB,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QAAQ,CAAC;IAGxB,WAAO,GAAG,GAAG,CAAC,OAAO,CAAC;IAEtB,eAAW,GAAG,GAAG,CAAC,WAAW,CAAC;IAI9B,eAAW,GAAG,GAAG,CAAC,WAAW,CAAC;IAE9B,mBAAe,GAAG,GAAG,CAAC,eAAe,CAAC;IAGtC,aAAS,GAAG,GAAG,CAAC,SAAS,CAAC;IAE1B,iBAAa,GAAG,GAAG,CAAC,aAAa,CAAC;IAMlC,UAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IASpB,oBAAgB,GAAG,GAAG,CAAC,gBAAgB,CAAC;IAIxC,YAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;IAGxB,gBAAY,GAAG,GAAG,CAAC,YAAY,CAAC;IAMhC,SAAK,GAAG,GAAG,CAAC,KAAK,CAAC;IAElB,aAAS,GAAG,GAAG,CAAC,SAAS,CAAC;IAI1B,WAAO,GAAG,GAAG,CAAC,OAAO,CAAC;IAItB,2BAAuB,GAAG,GAAG,CAAC,uBAAuB,CAAC;IAItD,SAAK,GAAG,GAAG,CAAC,KAAK,CAAC;IAElB,aAAS,GAAG,GAAG,CAAC,SAAS,CAAC;IAK1B,UAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IAIpB,cAAU,GAAG,GAAG,CAAC,UAAU,CAAC;IAK5B,iBAAa,GAAG,GAAG,CAAC,aAAa,CAAC;IAKlC,qBAAiB,GAAG,GAAG,CAAC,iBAAiB,CAAC;IAC1C,0CAAsC,GAAG,GAAG,CAAC,sCAAsC,CAAC;IAcpF,UAAM,GAAG,GAAG,CAAC,MAAM,CAAC;AAMpC,CAAC,EA3GgB,GAAG,GAAH,WAAG,KAAH,WAAG,QA2GnB;AAED,kBAAe,GAAG,CAAC"}
package/index.mjs CHANGED
@@ -1,11 +1,135 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ var _a;
3
+ import * as Core from "./core.mjs";
2
4
  import * as Errors from "./error.mjs";
3
5
  import * as Uploads from "./uploads.mjs";
4
- import { Orb } from "./client.mjs";
5
- export { Orb };
6
- export default Orb;
6
+ import * as qs from 'qs';
7
+ import * as Pagination from 'orb-billing/pagination';
8
+ import * as API from 'orb-billing/resources/index';
9
+ /** API Client for interfacing with the Orb API. */
10
+ export class Orb extends Core.APIClient {
11
+ /**
12
+ * API Client for interfacing with the Orb API.
13
+ *
14
+ * @param {string | undefined} [opts.apiKey=process.env['ORB_API_KEY'] ?? undefined]
15
+ * @param {string | null | undefined} [opts.webhookSecret=process.env['ORB_WEBHOOK_SECRET'] ?? null]
16
+ * @param {string} [opts.baseURL=process.env['ORB_BASE_URL'] ?? https://api.withorb.com/v1] - Override the default base URL for the API.
17
+ * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
18
+ * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
19
+ * @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
20
+ * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
21
+ * @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
22
+ * @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
23
+ */
24
+ constructor({ baseURL = Core.readEnv('ORB_BASE_URL'), apiKey = Core.readEnv('ORB_API_KEY'), webhookSecret = Core.readEnv('ORB_WEBHOOK_SECRET') ?? null, ...opts } = {}) {
25
+ if (apiKey === undefined) {
26
+ throw new Errors.OrbError("The ORB_API_KEY environment variable is missing or empty; either provide it, or instantiate the Orb client with an apiKey option, like new Orb({ apiKey: 'My API Key' }).");
27
+ }
28
+ const options = {
29
+ apiKey,
30
+ webhookSecret,
31
+ ...opts,
32
+ baseURL: baseURL || `https://api.withorb.com/v1`,
33
+ };
34
+ super({
35
+ baseURL: options.baseURL,
36
+ timeout: options.timeout ?? 60000 /* 1 minute */,
37
+ httpAgent: options.httpAgent,
38
+ maxRetries: options.maxRetries,
39
+ fetch: options.fetch,
40
+ });
41
+ this.topLevel = new API.TopLevel(this);
42
+ this.coupons = new API.Coupons(this);
43
+ this.creditNotes = new API.CreditNotes(this);
44
+ this.customers = new API.Customers(this);
45
+ this.events = new API.Events(this);
46
+ this.invoiceLineItems = new API.InvoiceLineItems(this);
47
+ this.invoices = new API.Invoices(this);
48
+ this.items = new API.Items(this);
49
+ this.metrics = new API.Metrics(this);
50
+ this.plans = new API.Plans(this);
51
+ this.prices = new API.Prices(this);
52
+ this.subscriptions = new API.Subscriptions(this);
53
+ this.webhooks = new API.Webhooks(this);
54
+ this.alerts = new API.Alerts(this);
55
+ this._options = options;
56
+ this.idempotencyHeader = 'Idempotency-Key';
57
+ this.apiKey = apiKey;
58
+ this.webhookSecret = webhookSecret;
59
+ }
60
+ defaultQuery() {
61
+ return this._options.defaultQuery;
62
+ }
63
+ defaultHeaders(opts) {
64
+ return {
65
+ ...super.defaultHeaders(opts),
66
+ ...this._options.defaultHeaders,
67
+ };
68
+ }
69
+ authHeaders(opts) {
70
+ return { Authorization: `Bearer ${this.apiKey}` };
71
+ }
72
+ stringifyQuery(query) {
73
+ return qs.stringify(query, { arrayFormat: 'brackets' });
74
+ }
75
+ }
76
+ _a = Orb;
77
+ Orb.Orb = _a;
78
+ Orb.OrbError = Errors.OrbError;
79
+ Orb.APIError = Errors.APIError;
80
+ Orb.APIConnectionError = Errors.APIConnectionError;
81
+ Orb.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
82
+ Orb.APIUserAbortError = Errors.APIUserAbortError;
83
+ Orb.URLNotFound = Errors.URLNotFound;
84
+ Orb.NotFoundError = Errors.NotFoundError;
85
+ Orb.ConflictError = Errors.ConflictError;
86
+ Orb.RateLimitError = Errors.RateLimitError;
87
+ Orb.BadRequestError = Errors.BadRequestError;
88
+ Orb.RequestTooLarge = Errors.RequestTooLarge;
89
+ Orb.TooManyRequests = Errors.TooManyRequests;
90
+ Orb.ResourceNotFound = Errors.ResourceNotFound;
91
+ Orb.ResourceConflict = Errors.ResourceConflict;
92
+ Orb.ResourceTooLarge = Errors.ResourceTooLarge;
93
+ Orb.AuthenticationError = Errors.AuthenticationError;
94
+ Orb.InternalServerError = Errors.InternalServerError;
95
+ Orb.ConstraintViolation = Errors.ConstraintViolation;
96
+ Orb.FeatureNotAvailable = Errors.FeatureNotAvailable;
97
+ Orb.PermissionDeniedError = Errors.PermissionDeniedError;
98
+ Orb.RequestValidationError = Errors.RequestValidationError;
99
+ Orb.OrbAuthenticationError = Errors.OrbAuthenticationError;
100
+ Orb.OrbInternalServerError = Errors.OrbInternalServerError;
101
+ Orb.UnprocessableEntityError = Errors.UnprocessableEntityError;
102
+ Orb.DuplicateResourceCreation = Errors.DuplicateResourceCreation;
103
+ Orb.toFile = Uploads.toFile;
104
+ Orb.fileFromPath = Uploads.fileFromPath;
105
+ export const { OrbError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, URLNotFound, NotFoundError, ConflictError, RateLimitError, BadRequestError, RequestTooLarge, TooManyRequests, ResourceNotFound, ResourceConflict, ResourceTooLarge, AuthenticationError, InternalServerError, ConstraintViolation, FeatureNotAvailable, PermissionDeniedError, RequestValidationError, OrbAuthenticationError, OrbInternalServerError, UnprocessableEntityError, DuplicateResourceCreation, } = Errors;
7
106
  export var toFile = Uploads.toFile;
8
107
  export var fileFromPath = Uploads.fileFromPath;
9
- export const { OrbError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, URLNotFound, NotFoundError, ConflictError, RateLimitError, BadRequestError, RequestTooLarge, TooManyRequests, ResourceNotFound, ResourceConflict, ResourceTooLarge, AuthenticationError, InternalServerError, ConstraintViolation, FeatureNotAvailable, PermissionDeniedError, RequestValidationError, OrbAuthenticationError, OrbInternalServerError, UnprocessableEntityError, DuplicateResourceCreation, } = Errors;
10
- export * from "./client.mjs";
108
+ (function (Orb) {
109
+ Orb.Page = Pagination.Page;
110
+ Orb.TopLevel = API.TopLevel;
111
+ Orb.Coupons = API.Coupons;
112
+ Orb.CouponsPage = API.CouponsPage;
113
+ Orb.CreditNotes = API.CreditNotes;
114
+ Orb.CreditNotesPage = API.CreditNotesPage;
115
+ Orb.Customers = API.Customers;
116
+ Orb.CustomersPage = API.CustomersPage;
117
+ Orb.Events = API.Events;
118
+ Orb.InvoiceLineItems = API.InvoiceLineItems;
119
+ Orb.Invoices = API.Invoices;
120
+ Orb.InvoicesPage = API.InvoicesPage;
121
+ Orb.Items = API.Items;
122
+ Orb.ItemsPage = API.ItemsPage;
123
+ Orb.Metrics = API.Metrics;
124
+ Orb.MetricListResponsesPage = API.MetricListResponsesPage;
125
+ Orb.Plans = API.Plans;
126
+ Orb.PlansPage = API.PlansPage;
127
+ Orb.Prices = API.Prices;
128
+ Orb.PricesPage = API.PricesPage;
129
+ Orb.Subscriptions = API.Subscriptions;
130
+ Orb.SubscriptionsPage = API.SubscriptionsPage;
131
+ Orb.SubscriptionFetchScheduleResponsesPage = API.SubscriptionFetchScheduleResponsesPage;
132
+ Orb.Alerts = API.Alerts;
133
+ })(Orb || (Orb = {}));
134
+ export default Orb;
11
135
  //# sourceMappingURL=index.mjs.map
package/index.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,KAAK,MAAM;OACX,KAAK,OAAO;OACZ,EAAE,GAAG,EAAE;AAEd,OAAO,EAAE,GAAG,EAAE,CAAC;AACf,eAAe,GAAG,CAAC;AAEnB,MAAM,KAAQ,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;AACtC,MAAM,KAAQ,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;AAElD,MAAM,CAAC,MAAM,EACX,QAAQ,EACR,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB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C,UAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IASpB,oBAAgB,GAAG,GAAG,CAAC,gBAAgB,CAAC;IAIxC,YAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;IAGxB,gBAAY,GAAG,GAAG,CAAC,YAAY,CAAC;IAMhC,SAAK,GAAG,GAAG,CAAC,KAAK,CAAC;IAElB,aAAS,GAAG,GAAG,CAAC,SAAS,CAAC;IAI1B,WAAO,GAAG,GAAG,CAAC,OAAO,CAAC;IAItB,2BAAuB,GAAG,GAAG,CAAC,uBAAuB,CAAC;IAItD,SAAK,GAAG,GAAG,CAAC,KAAK,CAAC;IAElB,aAAS,GAAG,GAAG,CAAC,SAAS,CAAC;IAK1B,UAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IAIpB,cAAU,GAAG,GAAG,CAAC,UAAU,CAAC;IAK5B,iBAAa,GAAG,GAAG,CAAC,aAAa,CAAC;IAKlC,qBAAiB,GAAG,GAAG,CAAC,iBAAiB,CAAC;IAC1C,0CAAsC,GAAG,GAAG,CAAC,sCAAsC,CAAC;IAcpF,UAAM,GAAG,GAAG,CAAC,MAAM,CAAC;AAMpC,CAAC,EA3GgB,GAAG,KAAH,GAAG,QA2GnB;AAED,eAAe,GAAG,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orb-billing",
3
- "version": "2.4.0",
3
+ "version": "2.5.1",
4
4
  "description": "The official TypeScript library for the Orb API",
5
5
  "author": "Orb <team@withorb.com>",
6
6
  "types": "./index.d.ts",
@@ -0,0 +1,84 @@
1
+ import * as Core from 'orb-billing/core';
2
+ import { APIResource } from 'orb-billing/resource';
3
+ import * as AlertsAPI from 'orb-billing/resources/alerts';
4
+ export declare class Alerts extends APIResource {
5
+ /**
6
+ * This endpoint can be used to enable an alert.
7
+ */
8
+ enable(alertConfigurationId: string, options?: Core.RequestOptions): Core.APIPromise<Alert>;
9
+ }
10
+ /**
11
+ * An
12
+ * [Alert within Orb](https://docs.withorb.com/guides/product-catalog/configuring-alerts)
13
+ * monitors a customer's spending, usage, or credit balance and triggers a webhook
14
+ * when a threshold is exceeded.
15
+ *
16
+ * Alerts can be configured to monitor usage, cost, or credit balance. Alerts can
17
+ * be scoped to either a customer, a plan, or a subscription.
18
+ *
19
+ * Customer scoped alerts track a customer's credit balance. Valid customer alert
20
+ * types are "credit_balance_depleted", "credit_balance_recovered", and
21
+ * "credit_balance_dropped".
22
+ *
23
+ * Subscription scoped alerts track a subscriptions's usage or cost. Valid plan
24
+ * alert types are "usage_exceeded" or "cost_exceeded".
25
+ *
26
+ * Plan scoped alerts are similar to subscriptions alerts but when a plan alert is
27
+ * created, it is propagated to all subscriptions associated with the plan.
28
+ * Disabling a plan alert will disable the alert for all subscriptions. Valid plan
29
+ * alert types are "usage_exceeded" or "cost_exceeded".
30
+ */
31
+ export interface Alert {
32
+ /**
33
+ * Also referred to as alert_id in this documentation.
34
+ */
35
+ id: string;
36
+ /**
37
+ * The creation time of the resource in Orb.
38
+ */
39
+ created_at: string;
40
+ /**
41
+ * The name of the currency the credit balance for this alert is denominated in.
42
+ */
43
+ currency: string | null;
44
+ /**
45
+ * The customer that the alert is scoped to.
46
+ */
47
+ customer: Record<string, string | null> | null;
48
+ /**
49
+ * Whether the alert is enabled or disabled.
50
+ */
51
+ enabled: boolean;
52
+ metric: Record<string, string | null> | null;
53
+ /**
54
+ * The plan that the alert is scoped to.
55
+ */
56
+ plan: Record<string, string | null> | null;
57
+ subscription: Record<string, string | null> | null;
58
+ /**
59
+ * The thresholds that define the conditions under which the alert will be
60
+ * triggered.
61
+ */
62
+ thresholds: Array<Alert.Threshold> | null;
63
+ /**
64
+ * The type of alert. This must be a valid alert type.
65
+ */
66
+ type: 'credit_balance_depleted' | 'credit_balance_dropped' | 'credit_balance_recovered';
67
+ }
68
+ export declare namespace Alert {
69
+ /**
70
+ * Thresholds are used to define the conditions under which an alert will be
71
+ * triggered.
72
+ */
73
+ interface Threshold {
74
+ /**
75
+ * The value at which an alert will fire. For credit balance alerts, the alert will fire at or below this value. For usage and
76
+ * cost alerts, the alert will fire at or above this value.
77
+ */
78
+ value: number;
79
+ }
80
+ }
81
+ export declare namespace Alerts {
82
+ export import Alert = AlertsAPI.Alert;
83
+ }
84
+ //# sourceMappingURL=alerts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alerts.d.ts","sourceRoot":"","sources":["../src/resources/alerts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,SAAS,MAAM,8BAA8B,CAAC;AAE1D,qBAAa,MAAO,SAAQ,WAAW;IACrC;;OAEG;IACH,MAAM,CAAC,oBAAoB,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;CAG5F;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,KAAK;IACpB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAExB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAE/C;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAE7C;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAE3C,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAEnD;;;OAGG;IACH,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;IAE1C;;OAEG;IACH,IAAI,EAAE,yBAAyB,GAAG,wBAAwB,GAAG,0BAA0B,CAAC;CACzF;AAED,yBAAiB,KAAK,CAAC;IACrB;;;OAGG;IACH,UAAiB,SAAS;QACxB;;;WAGG;QACH,KAAK,EAAE,MAAM,CAAC;KACf;CACF;AAED,yBAAiB,MAAM,CAAC;IACtB,MAAM,QAAQ,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC;CACvC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Alerts = void 0;
5
+ const resource_1 = require("orb-billing/resource");
6
+ class Alerts extends resource_1.APIResource {
7
+ /**
8
+ * This endpoint can be used to enable an alert.
9
+ */
10
+ enable(alertConfigurationId, options) {
11
+ return this._client.post(`/alerts/${alertConfigurationId}/enable`, options);
12
+ }
13
+ }
14
+ exports.Alerts = Alerts;
15
+ (function (Alerts) {
16
+ })(Alerts = exports.Alerts || (exports.Alerts = {}));
17
+ //# sourceMappingURL=alerts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alerts.js","sourceRoot":"","sources":["../src/resources/alerts.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAGtF,mDAAmD;AAGnD,MAAa,MAAO,SAAQ,sBAAW;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;AAPD,wBAOC;AAoFD,WAAiB,MAAM;AAEvB,CAAC,EAFgB,MAAM,GAAN,cAAM,KAAN,cAAM,QAEtB"}
@@ -0,0 +1,13 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ import { APIResource } from 'orb-billing/resource';
3
+ export class Alerts extends APIResource {
4
+ /**
5
+ * This endpoint can be used to enable an alert.
6
+ */
7
+ enable(alertConfigurationId, options) {
8
+ return this._client.post(`/alerts/${alertConfigurationId}/enable`, options);
9
+ }
10
+ }
11
+ (function (Alerts) {
12
+ })(Alerts || (Alerts = {}));
13
+ //# sourceMappingURL=alerts.mjs.map
@@ -0,0 +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"}