orb-billing 1.37.4 → 1.39.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/core.d.ts +5 -0
  3. package/core.d.ts.map +1 -1
  4. package/core.js +10 -1
  5. package/core.js.map +1 -1
  6. package/core.mjs +8 -0
  7. package/core.mjs.map +1 -1
  8. package/package.json +1 -1
  9. package/resources/customers/costs.d.ts +548 -12
  10. package/resources/customers/costs.d.ts.map +1 -1
  11. package/resources/customers/costs.js.map +1 -1
  12. package/resources/customers/costs.mjs.map +1 -1
  13. package/resources/customers/credits/credits.d.ts +13 -0
  14. package/resources/customers/credits/credits.d.ts.map +1 -1
  15. package/resources/customers/credits/credits.js +5 -0
  16. package/resources/customers/credits/credits.js.map +1 -1
  17. package/resources/customers/credits/credits.mjs +5 -0
  18. package/resources/customers/credits/credits.mjs.map +1 -1
  19. package/resources/customers/credits/index.d.ts +1 -0
  20. package/resources/customers/credits/index.d.ts.map +1 -1
  21. package/resources/customers/credits/index.js +5 -1
  22. package/resources/customers/credits/index.js.map +1 -1
  23. package/resources/customers/credits/index.mjs +1 -0
  24. package/resources/customers/credits/index.mjs.map +1 -1
  25. package/resources/customers/credits/top-ups.d.ts +399 -0
  26. package/resources/customers/credits/top-ups.d.ts.map +1 -0
  27. package/resources/customers/credits/top-ups.js +102 -0
  28. package/resources/customers/credits/top-ups.js.map +1 -0
  29. package/resources/customers/credits/top-ups.mjs +73 -0
  30. package/resources/customers/credits/top-ups.mjs.map +1 -0
  31. package/resources/customers/customers.d.ts +10 -0
  32. package/resources/customers/customers.d.ts.map +1 -1
  33. package/resources/customers/customers.js.map +1 -1
  34. package/resources/customers/customers.mjs.map +1 -1
  35. package/resources/subscriptions.d.ts +273 -5
  36. package/resources/subscriptions.d.ts.map +1 -1
  37. package/resources/subscriptions.js.map +1 -1
  38. package/resources/subscriptions.mjs.map +1 -1
  39. package/src/core.ts +11 -0
  40. package/src/resources/customers/costs.ts +586 -32
  41. package/src/resources/customers/credits/credits.ts +13 -0
  42. package/src/resources/customers/credits/index.ts +13 -0
  43. package/src/resources/customers/credits/top-ups.ts +542 -0
  44. package/src/resources/customers/customers.ts +12 -0
  45. package/src/resources/subscriptions.ts +283 -6
  46. package/src/version.ts +1 -1
  47. package/version.d.ts +1 -1
  48. package/version.js +1 -1
  49. package/version.mjs +1 -1
@@ -22,3 +22,16 @@ export {
22
22
  LedgerListByExternalIDResponsesPage,
23
23
  Ledger,
24
24
  } from './ledger';
25
+ export {
26
+ TopUpCreateResponse,
27
+ TopUpListResponse,
28
+ TopUpCreateByExternalIDResponse,
29
+ TopUpListByExternalIDResponse,
30
+ TopUpCreateParams,
31
+ TopUpListParams,
32
+ TopUpCreateByExternalIDParams,
33
+ TopUpListByExternalIDParams,
34
+ TopUpListResponsesPage,
35
+ TopUpListByExternalIDResponsesPage,
36
+ TopUps,
37
+ } from './top-ups';
@@ -0,0 +1,542 @@
1
+ // File generated from our OpenAPI spec by Stainless.
2
+
3
+ import * as Core from "../../../core";
4
+ import { APIResource } from "../../../resource";
5
+ import { isRequestOptions } from "../../../core";
6
+ import * as TopUpsAPI from "./top-ups";
7
+ import { Page, type PageParams } from "../../../pagination";
8
+
9
+ export class TopUps extends APIResource {
10
+ /**
11
+ * This endpoint allows you to create a new top-up for a specified customer's
12
+ * balance. While this top-up is active, the customer's balance will added in
13
+ * increments of the specified amount whenever the balance reaches the specified
14
+ * threshold.
15
+ *
16
+ * If a top-up already exists for this customer in the same currency, the existing
17
+ * top-up will be replaced.
18
+ */
19
+ create(
20
+ customerId: string | null,
21
+ body: TopUpCreateParams,
22
+ options?: Core.RequestOptions,
23
+ ): Core.APIPromise<TopUpCreateResponse> {
24
+ return this._client.post(`/customers/${customerId}/credits/top_ups`, { body, ...options });
25
+ }
26
+
27
+ /**
28
+ * List top-ups
29
+ */
30
+ list(
31
+ customerId: string | null,
32
+ query?: TopUpListParams,
33
+ options?: Core.RequestOptions,
34
+ ): Core.PagePromise<TopUpListResponsesPage, TopUpListResponse>;
35
+ list(
36
+ customerId: string | null,
37
+ options?: Core.RequestOptions,
38
+ ): Core.PagePromise<TopUpListResponsesPage, TopUpListResponse>;
39
+ list(
40
+ customerId: string | null,
41
+ query: TopUpListParams | Core.RequestOptions = {},
42
+ options?: Core.RequestOptions,
43
+ ): Core.PagePromise<TopUpListResponsesPage, TopUpListResponse> {
44
+ if (isRequestOptions(query)) {
45
+ return this.list(customerId, {}, query);
46
+ }
47
+ return this._client.getAPIList(`/customers/${customerId}/credits/top_ups`, TopUpListResponsesPage, {
48
+ query,
49
+ ...options,
50
+ });
51
+ }
52
+
53
+ /**
54
+ * Delete top-up
55
+ */
56
+ delete(customerId: string | null, topUpId: string, options?: Core.RequestOptions): Core.APIPromise<void> {
57
+ return this._client.delete(`/customers/${customerId}/credits/top_ups/${topUpId}`, {
58
+ ...options,
59
+ headers: { Accept: '*/*', ...options?.headers },
60
+ });
61
+ }
62
+
63
+ /**
64
+ * This endpoint allows you to create a new top-up for a specified customer's
65
+ * balance. While this top-up is active, the customer's balance will added in
66
+ * increments of the specified amount whenever the balance reaches the specified
67
+ * threshold.
68
+ *
69
+ * If a top-up already exists for this customer in the same currency, the existing
70
+ * top-up will be replaced.
71
+ */
72
+ createByExternalId(
73
+ externalCustomerId: string | null,
74
+ body: TopUpCreateByExternalIDParams,
75
+ options?: Core.RequestOptions,
76
+ ): Core.APIPromise<TopUpCreateByExternalIDResponse> {
77
+ return this._client.post(`/customers/external_customer_id/${externalCustomerId}/credits/top_ups`, {
78
+ body,
79
+ ...options,
80
+ });
81
+ }
82
+
83
+ /**
84
+ * Delete top-up by external ID
85
+ */
86
+ deleteByExternalId(
87
+ externalCustomerId: string | null,
88
+ topUpId: string,
89
+ options?: Core.RequestOptions,
90
+ ): Core.APIPromise<void> {
91
+ return this._client.delete(
92
+ `/customers/external_customer_id/${externalCustomerId}/credits/top_ups/${topUpId}`,
93
+ { ...options, headers: { Accept: '*/*', ...options?.headers } },
94
+ );
95
+ }
96
+
97
+ /**
98
+ * List top-ups by external ID
99
+ */
100
+ listByExternalId(
101
+ externalCustomerId: string | null,
102
+ query?: TopUpListByExternalIDParams,
103
+ options?: Core.RequestOptions,
104
+ ): Core.PagePromise<TopUpListByExternalIDResponsesPage, TopUpListByExternalIDResponse>;
105
+ listByExternalId(
106
+ externalCustomerId: string | null,
107
+ options?: Core.RequestOptions,
108
+ ): Core.PagePromise<TopUpListByExternalIDResponsesPage, TopUpListByExternalIDResponse>;
109
+ listByExternalId(
110
+ externalCustomerId: string | null,
111
+ query: TopUpListByExternalIDParams | Core.RequestOptions = {},
112
+ options?: Core.RequestOptions,
113
+ ): Core.PagePromise<TopUpListByExternalIDResponsesPage, TopUpListByExternalIDResponse> {
114
+ if (isRequestOptions(query)) {
115
+ return this.listByExternalId(externalCustomerId, {}, query);
116
+ }
117
+ return this._client.getAPIList(
118
+ `/customers/external_customer_id/${externalCustomerId}/credits/top_ups`,
119
+ TopUpListByExternalIDResponsesPage,
120
+ { query, ...options },
121
+ );
122
+ }
123
+ }
124
+
125
+ export class TopUpListResponsesPage extends Page<TopUpListResponse> {}
126
+
127
+ export class TopUpListByExternalIDResponsesPage extends Page<TopUpListByExternalIDResponse> {}
128
+
129
+ export interface TopUpCreateResponse {
130
+ id: string;
131
+
132
+ /**
133
+ * The amount to increment when the threshold is reached.
134
+ */
135
+ amount: string;
136
+
137
+ /**
138
+ * The currency or custom pricing unit to use for this top-up. If this is a
139
+ * real-world currency, it must match the customer's invoicing currency.
140
+ */
141
+ currency: string;
142
+
143
+ /**
144
+ * Settings for invoices generated by triggered top-ups.
145
+ */
146
+ invoice_settings: TopUpCreateResponse.InvoiceSettings;
147
+
148
+ /**
149
+ * How much, in the customer's currency, to charge for each unit.
150
+ */
151
+ per_unit_cost_basis: string;
152
+
153
+ /**
154
+ * The threshold at which to trigger the top-up. If the balance is at or below this
155
+ * threshold, the top-up will be triggered.
156
+ */
157
+ threshold: string;
158
+
159
+ /**
160
+ * The number of days or months after which the top-up expires. If unspecified, it
161
+ * does not expire.
162
+ */
163
+ expires_after?: number | null;
164
+
165
+ /**
166
+ * The unit of expires_after.
167
+ */
168
+ expires_after_unit?: 'day' | 'month' | null;
169
+ }
170
+
171
+ export namespace TopUpCreateResponse {
172
+ /**
173
+ * Settings for invoices generated by triggered top-ups.
174
+ */
175
+ export interface InvoiceSettings {
176
+ /**
177
+ * Whether the credits purchase invoice should auto collect with the customer's
178
+ * saved payment method.
179
+ */
180
+ auto_collection: boolean;
181
+
182
+ /**
183
+ * The net terms determines the difference between the invoice date and the issue
184
+ * date for the invoice. If you intend the invoice to be due on issue, set this
185
+ * to 0.
186
+ */
187
+ net_terms: number;
188
+
189
+ /**
190
+ * An optional memo to display on the invoice.
191
+ */
192
+ memo?: string | null;
193
+ }
194
+ }
195
+
196
+ export interface TopUpListResponse {
197
+ id: string;
198
+
199
+ /**
200
+ * The amount to increment when the threshold is reached.
201
+ */
202
+ amount: string;
203
+
204
+ /**
205
+ * The currency or custom pricing unit to use for this top-up. If this is a
206
+ * real-world currency, it must match the customer's invoicing currency.
207
+ */
208
+ currency: string;
209
+
210
+ /**
211
+ * Settings for invoices generated by triggered top-ups.
212
+ */
213
+ invoice_settings: TopUpListResponse.InvoiceSettings;
214
+
215
+ /**
216
+ * How much, in the customer's currency, to charge for each unit.
217
+ */
218
+ per_unit_cost_basis: string;
219
+
220
+ /**
221
+ * The threshold at which to trigger the top-up. If the balance is at or below this
222
+ * threshold, the top-up will be triggered.
223
+ */
224
+ threshold: string;
225
+
226
+ /**
227
+ * The number of days or months after which the top-up expires. If unspecified, it
228
+ * does not expire.
229
+ */
230
+ expires_after?: number | null;
231
+
232
+ /**
233
+ * The unit of expires_after.
234
+ */
235
+ expires_after_unit?: 'day' | 'month' | null;
236
+ }
237
+
238
+ export namespace TopUpListResponse {
239
+ /**
240
+ * Settings for invoices generated by triggered top-ups.
241
+ */
242
+ export interface InvoiceSettings {
243
+ /**
244
+ * Whether the credits purchase invoice should auto collect with the customer's
245
+ * saved payment method.
246
+ */
247
+ auto_collection: boolean;
248
+
249
+ /**
250
+ * The net terms determines the difference between the invoice date and the issue
251
+ * date for the invoice. If you intend the invoice to be due on issue, set this
252
+ * to 0.
253
+ */
254
+ net_terms: number;
255
+
256
+ /**
257
+ * An optional memo to display on the invoice.
258
+ */
259
+ memo?: string | null;
260
+ }
261
+ }
262
+
263
+ export interface TopUpCreateByExternalIDResponse {
264
+ id: string;
265
+
266
+ /**
267
+ * The amount to increment when the threshold is reached.
268
+ */
269
+ amount: string;
270
+
271
+ /**
272
+ * The currency or custom pricing unit to use for this top-up. If this is a
273
+ * real-world currency, it must match the customer's invoicing currency.
274
+ */
275
+ currency: string;
276
+
277
+ /**
278
+ * Settings for invoices generated by triggered top-ups.
279
+ */
280
+ invoice_settings: TopUpCreateByExternalIDResponse.InvoiceSettings;
281
+
282
+ /**
283
+ * How much, in the customer's currency, to charge for each unit.
284
+ */
285
+ per_unit_cost_basis: string;
286
+
287
+ /**
288
+ * The threshold at which to trigger the top-up. If the balance is at or below this
289
+ * threshold, the top-up will be triggered.
290
+ */
291
+ threshold: string;
292
+
293
+ /**
294
+ * The number of days or months after which the top-up expires. If unspecified, it
295
+ * does not expire.
296
+ */
297
+ expires_after?: number | null;
298
+
299
+ /**
300
+ * The unit of expires_after.
301
+ */
302
+ expires_after_unit?: 'day' | 'month' | null;
303
+ }
304
+
305
+ export namespace TopUpCreateByExternalIDResponse {
306
+ /**
307
+ * Settings for invoices generated by triggered top-ups.
308
+ */
309
+ export interface InvoiceSettings {
310
+ /**
311
+ * Whether the credits purchase invoice should auto collect with the customer's
312
+ * saved payment method.
313
+ */
314
+ auto_collection: boolean;
315
+
316
+ /**
317
+ * The net terms determines the difference between the invoice date and the issue
318
+ * date for the invoice. If you intend the invoice to be due on issue, set this
319
+ * to 0.
320
+ */
321
+ net_terms: number;
322
+
323
+ /**
324
+ * An optional memo to display on the invoice.
325
+ */
326
+ memo?: string | null;
327
+ }
328
+ }
329
+
330
+ export interface TopUpListByExternalIDResponse {
331
+ id: string;
332
+
333
+ /**
334
+ * The amount to increment when the threshold is reached.
335
+ */
336
+ amount: string;
337
+
338
+ /**
339
+ * The currency or custom pricing unit to use for this top-up. If this is a
340
+ * real-world currency, it must match the customer's invoicing currency.
341
+ */
342
+ currency: string;
343
+
344
+ /**
345
+ * Settings for invoices generated by triggered top-ups.
346
+ */
347
+ invoice_settings: TopUpListByExternalIDResponse.InvoiceSettings;
348
+
349
+ /**
350
+ * How much, in the customer's currency, to charge for each unit.
351
+ */
352
+ per_unit_cost_basis: string;
353
+
354
+ /**
355
+ * The threshold at which to trigger the top-up. If the balance is at or below this
356
+ * threshold, the top-up will be triggered.
357
+ */
358
+ threshold: string;
359
+
360
+ /**
361
+ * The number of days or months after which the top-up expires. If unspecified, it
362
+ * does not expire.
363
+ */
364
+ expires_after?: number | null;
365
+
366
+ /**
367
+ * The unit of expires_after.
368
+ */
369
+ expires_after_unit?: 'day' | 'month' | null;
370
+ }
371
+
372
+ export namespace TopUpListByExternalIDResponse {
373
+ /**
374
+ * Settings for invoices generated by triggered top-ups.
375
+ */
376
+ export interface InvoiceSettings {
377
+ /**
378
+ * Whether the credits purchase invoice should auto collect with the customer's
379
+ * saved payment method.
380
+ */
381
+ auto_collection: boolean;
382
+
383
+ /**
384
+ * The net terms determines the difference between the invoice date and the issue
385
+ * date for the invoice. If you intend the invoice to be due on issue, set this
386
+ * to 0.
387
+ */
388
+ net_terms: number;
389
+
390
+ /**
391
+ * An optional memo to display on the invoice.
392
+ */
393
+ memo?: string | null;
394
+ }
395
+ }
396
+
397
+ export interface TopUpCreateParams {
398
+ /**
399
+ * The amount to increment when the threshold is reached.
400
+ */
401
+ amount: string;
402
+
403
+ /**
404
+ * The currency or custom pricing unit to use for this top-up. If this is a
405
+ * real-world currency, it must match the customer's invoicing currency.
406
+ */
407
+ currency: string;
408
+
409
+ /**
410
+ * Settings for invoices generated by triggered top-ups.
411
+ */
412
+ invoice_settings: TopUpCreateParams.InvoiceSettings;
413
+
414
+ /**
415
+ * How much, in the customer's currency, to charge for each unit.
416
+ */
417
+ per_unit_cost_basis: string;
418
+
419
+ /**
420
+ * The threshold at which to trigger the top-up. If the balance is at or below this
421
+ * threshold, the top-up will be triggered.
422
+ */
423
+ threshold: string;
424
+
425
+ /**
426
+ * The number of days or months after which the top-up expires. If unspecified, it
427
+ * does not expire.
428
+ */
429
+ expires_after?: number | null;
430
+
431
+ /**
432
+ * The unit of expires_after.
433
+ */
434
+ expires_after_unit?: 'day' | 'month' | null;
435
+ }
436
+
437
+ export namespace TopUpCreateParams {
438
+ /**
439
+ * Settings for invoices generated by triggered top-ups.
440
+ */
441
+ export interface InvoiceSettings {
442
+ /**
443
+ * Whether the credits purchase invoice should auto collect with the customer's
444
+ * saved payment method.
445
+ */
446
+ auto_collection: boolean;
447
+
448
+ /**
449
+ * The net terms determines the difference between the invoice date and the issue
450
+ * date for the invoice. If you intend the invoice to be due on issue, set this
451
+ * to 0.
452
+ */
453
+ net_terms: number;
454
+
455
+ /**
456
+ * An optional memo to display on the invoice.
457
+ */
458
+ memo?: string | null;
459
+ }
460
+ }
461
+
462
+ export interface TopUpListParams extends PageParams {}
463
+
464
+ export interface TopUpCreateByExternalIDParams {
465
+ /**
466
+ * The amount to increment when the threshold is reached.
467
+ */
468
+ amount: string;
469
+
470
+ /**
471
+ * The currency or custom pricing unit to use for this top-up. If this is a
472
+ * real-world currency, it must match the customer's invoicing currency.
473
+ */
474
+ currency: string;
475
+
476
+ /**
477
+ * Settings for invoices generated by triggered top-ups.
478
+ */
479
+ invoice_settings: TopUpCreateByExternalIDParams.InvoiceSettings;
480
+
481
+ /**
482
+ * How much, in the customer's currency, to charge for each unit.
483
+ */
484
+ per_unit_cost_basis: string;
485
+
486
+ /**
487
+ * The threshold at which to trigger the top-up. If the balance is at or below this
488
+ * threshold, the top-up will be triggered.
489
+ */
490
+ threshold: string;
491
+
492
+ /**
493
+ * The number of days or months after which the top-up expires. If unspecified, it
494
+ * does not expire.
495
+ */
496
+ expires_after?: number | null;
497
+
498
+ /**
499
+ * The unit of expires_after.
500
+ */
501
+ expires_after_unit?: 'day' | 'month' | null;
502
+ }
503
+
504
+ export namespace TopUpCreateByExternalIDParams {
505
+ /**
506
+ * Settings for invoices generated by triggered top-ups.
507
+ */
508
+ export interface InvoiceSettings {
509
+ /**
510
+ * Whether the credits purchase invoice should auto collect with the customer's
511
+ * saved payment method.
512
+ */
513
+ auto_collection: boolean;
514
+
515
+ /**
516
+ * The net terms determines the difference between the invoice date and the issue
517
+ * date for the invoice. If you intend the invoice to be due on issue, set this
518
+ * to 0.
519
+ */
520
+ net_terms: number;
521
+
522
+ /**
523
+ * An optional memo to display on the invoice.
524
+ */
525
+ memo?: string | null;
526
+ }
527
+ }
528
+
529
+ export interface TopUpListByExternalIDParams extends PageParams {}
530
+
531
+ export namespace TopUps {
532
+ export import TopUpCreateResponse = TopUpsAPI.TopUpCreateResponse;
533
+ export import TopUpListResponse = TopUpsAPI.TopUpListResponse;
534
+ export import TopUpCreateByExternalIDResponse = TopUpsAPI.TopUpCreateByExternalIDResponse;
535
+ export import TopUpListByExternalIDResponse = TopUpsAPI.TopUpListByExternalIDResponse;
536
+ export import TopUpListResponsesPage = TopUpsAPI.TopUpListResponsesPage;
537
+ export import TopUpListByExternalIDResponsesPage = TopUpsAPI.TopUpListByExternalIDResponsesPage;
538
+ export import TopUpCreateParams = TopUpsAPI.TopUpCreateParams;
539
+ export import TopUpListParams = TopUpsAPI.TopUpListParams;
540
+ export import TopUpCreateByExternalIDParams = TopUpsAPI.TopUpCreateByExternalIDParams;
541
+ export import TopUpListByExternalIDParams = TopUpsAPI.TopUpListByExternalIDParams;
542
+ }
@@ -1045,6 +1045,12 @@ export interface CustomerUpdateParams {
1045
1045
 
1046
1046
  email_delivery?: boolean | null;
1047
1047
 
1048
+ /**
1049
+ * The external customer ID. This can only be set if empty and the customer has no
1050
+ * past or current subscriptions.
1051
+ */
1052
+ external_customer_id?: string | null;
1053
+
1048
1054
  /**
1049
1055
  * User-specified key/value pairs for the resource. Individual keys can be removed
1050
1056
  * by setting the value to `null`, and the entire metadata mapping can be cleared
@@ -1465,6 +1471,12 @@ export interface CustomerUpdateByExternalIDParams {
1465
1471
 
1466
1472
  email_delivery?: boolean | null;
1467
1473
 
1474
+ /**
1475
+ * The external customer ID. This can only be set if empty and the customer has no
1476
+ * past or current subscriptions.
1477
+ */
1478
+ external_customer_id?: string | null;
1479
+
1468
1480
  /**
1469
1481
  * User-specified key/value pairs for the resource. Individual keys can be removed
1470
1482
  * by setting the value to `null`, and the entire metadata mapping can be cleared