orb-billing 1.41.0 → 2.0.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 (51) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +13 -13
  3. package/core.d.ts.map +1 -1
  4. package/core.js +2 -1
  5. package/core.js.map +1 -1
  6. package/core.mjs +2 -1
  7. package/core.mjs.map +1 -1
  8. package/index.d.mts +1 -1
  9. package/index.d.ts +1 -1
  10. package/index.d.ts.map +1 -1
  11. package/index.js +1 -1
  12. package/index.js.map +1 -1
  13. package/index.mjs +1 -1
  14. package/index.mjs.map +1 -1
  15. package/package.json +4 -1
  16. package/resources/credit-notes.d.ts +1 -10
  17. package/resources/credit-notes.d.ts.map +1 -1
  18. package/resources/credit-notes.js.map +1 -1
  19. package/resources/credit-notes.mjs.map +1 -1
  20. package/resources/invoices.d.ts +21 -1
  21. package/resources/invoices.d.ts.map +1 -1
  22. package/resources/invoices.js +3 -0
  23. package/resources/invoices.js.map +1 -1
  24. package/resources/invoices.mjs +3 -0
  25. package/resources/invoices.mjs.map +1 -1
  26. package/resources/plans/plans.d.ts +40 -1
  27. package/resources/plans/plans.d.ts.map +1 -1
  28. package/resources/plans/plans.js.map +1 -1
  29. package/resources/plans/plans.mjs.map +1 -1
  30. package/resources/prices/prices.d.ts +317 -2
  31. package/resources/prices/prices.d.ts.map +1 -1
  32. package/resources/prices/prices.js.map +1 -1
  33. package/resources/prices/prices.mjs.map +1 -1
  34. package/resources/subscriptions.d.ts +279 -3
  35. package/resources/subscriptions.d.ts.map +1 -1
  36. package/resources/subscriptions.js.map +1 -1
  37. package/resources/subscriptions.mjs.map +1 -1
  38. package/src/core.ts +3 -1
  39. package/src/index.ts +1 -1
  40. package/src/resources/credit-notes.ts +1 -14
  41. package/src/resources/invoices.ts +24 -1
  42. package/src/resources/plans/plans.ts +50 -0
  43. package/src/resources/prices/prices.ts +421 -2
  44. package/src/resources/subscriptions.ts +348 -0
  45. package/src/version.ts +1 -1
  46. package/version.d.ts +1 -1
  47. package/version.d.ts.map +1 -1
  48. package/version.js +1 -1
  49. package/version.js.map +1 -1
  50. package/version.mjs +1 -1
  51. package/version.mjs.map +1 -1
@@ -154,7 +154,7 @@ export namespace CreditNote {
154
154
  amount: string;
155
155
 
156
156
  /**
157
- * Any line items discounts from the invoice's line item.
157
+ * Any line item discounts from the invoice's line item.
158
158
  */
159
159
  discounts: Array<LineItem.Discount>;
160
160
 
@@ -168,11 +168,6 @@ export namespace CreditNote {
168
168
  */
169
169
  quantity: number | null;
170
170
 
171
- /**
172
- * Any sub line items that may be credited.
173
- */
174
- sub_line_items: Array<LineItem.SubLineItem>;
175
-
176
171
  /**
177
172
  * The amount of the line item, excluding any line item minimums and discounts.
178
173
  */
@@ -201,14 +196,6 @@ export namespace CreditNote {
201
196
  reason?: string | null;
202
197
  }
203
198
 
204
- export interface SubLineItem {
205
- amount: string;
206
-
207
- name: string;
208
-
209
- quantity: number | null;
210
- }
211
-
212
199
  export interface TaxAmount {
213
200
  /**
214
201
  * The amount of additional tax incurred by this tax rate.
@@ -42,6 +42,9 @@ export class Invoices extends APIResource {
42
42
  /**
43
43
  * This endpoint is used to fetch an [`Invoice`](../guides/concepts#invoice) given
44
44
  * an identifier.
45
+ *
46
+ * This endpoint supports returning ApiCachedUsageData (see
47
+ * api/cache_control_utils.py)
45
48
  */
46
49
  fetch(invoiceId: string, options?: Core.RequestOptions): Core.APIPromise<Invoice> {
47
50
  return this._client.get(`/invoices/${invoiceId}`, options);
@@ -51,6 +54,9 @@ export class Invoices extends APIResource {
51
54
  * This endpoint can be used to fetch the upcoming
52
55
  * [invoice](../guides/concepts#invoice) for the current billing period given a
53
56
  * subscription.
57
+ *
58
+ * This endpoint supports returning ApiCachedUsageData (see
59
+ * api/cache_control_utils.py)
54
60
  */
55
61
  fetchUpcoming(
56
62
  query?: InvoiceFetchUpcomingParams,
@@ -416,6 +422,11 @@ export namespace Invoice {
416
422
 
417
423
  credit_note_number: string;
418
424
 
425
+ /**
426
+ * An optional memo supplied on the credit note.
427
+ */
428
+ memo: string | null;
429
+
419
430
  reason: string;
420
431
 
421
432
  total: string;
@@ -1496,6 +1507,11 @@ export namespace InvoiceFetchUpcomingResponse {
1496
1507
 
1497
1508
  credit_note_number: string;
1498
1509
 
1510
+ /**
1511
+ * An optional memo supplied on the credit note.
1512
+ */
1513
+ memo: string | null;
1514
+
1499
1515
  reason: string;
1500
1516
 
1501
1517
  total: string;
@@ -2314,6 +2330,13 @@ export interface InvoiceCreateParams {
2314
2330
  */
2315
2331
  memo?: string | null;
2316
2332
 
2333
+ /**
2334
+ * User-specified key/value pairs for the resource. Individual keys can be removed
2335
+ * by setting the value to `null`, and the entire metadata mapping can be cleared
2336
+ * by setting `metadata` to `null`.
2337
+ */
2338
+ metadata?: Record<string, string | null> | null;
2339
+
2317
2340
  /**
2318
2341
  * When true, this invoice will automatically be issued upon creation. When false,
2319
2342
  * the resulting invoice will require manual review to issue. Defaulted to false.
@@ -2396,7 +2419,7 @@ export interface InvoiceListParams extends PageParams {
2396
2419
 
2397
2420
  is_recurring?: boolean | null;
2398
2421
 
2399
- 'status[]'?: Array<'draft' | 'issued' | 'paid' | 'synced' | 'void'> | null;
2422
+ status?: Array<'draft' | 'issued' | 'paid' | 'synced' | 'void'> | null;
2400
2423
 
2401
2424
  subscription_id?: string | null;
2402
2425
  }
@@ -314,6 +314,7 @@ export interface PlanCreateParams {
314
314
  | PlanCreateParams.NewPlanThresholdTotalAmountPrice
315
315
  | PlanCreateParams.NewPlanTieredPackagePrice
316
316
  | PlanCreateParams.NewPlanTieredWithMinimumPrice
317
+ | PlanCreateParams.NewPlanUnitWithPercentPrice
317
318
  | PlanCreateParams.NewPlanPackageWithAllocationPrice
318
319
  >;
319
320
 
@@ -1082,6 +1083,55 @@ export namespace PlanCreateParams {
1082
1083
  invoice_grouping_key?: string | null;
1083
1084
  }
1084
1085
 
1086
+ export interface NewPlanUnitWithPercentPrice {
1087
+ /**
1088
+ * The cadence to bill for this price on.
1089
+ */
1090
+ cadence: 'annual' | 'monthly' | 'quarterly' | 'one_time';
1091
+
1092
+ /**
1093
+ * The id of the item the plan will be associated with.
1094
+ */
1095
+ item_id: string;
1096
+
1097
+ model_type: 'unit_with_percent';
1098
+
1099
+ /**
1100
+ * The name of the price.
1101
+ */
1102
+ name: string;
1103
+
1104
+ unit_with_percent_config: Record<string, unknown>;
1105
+
1106
+ /**
1107
+ * The id of the billable metric for the price. Only needed if the price is
1108
+ * usage-based.
1109
+ */
1110
+ billable_metric_id?: string | null;
1111
+
1112
+ /**
1113
+ * If the Price represents a fixed cost, the price will be billed in-advance if
1114
+ * this is true, and in-arrears if this is false.
1115
+ */
1116
+ billed_in_advance?: boolean | null;
1117
+
1118
+ /**
1119
+ * An alias for the price.
1120
+ */
1121
+ external_price_id?: string | null;
1122
+
1123
+ /**
1124
+ * If the Price represents a fixed cost, this represents the quantity of units
1125
+ * applied.
1126
+ */
1127
+ fixed_price_quantity?: number | null;
1128
+
1129
+ /**
1130
+ * The property used to group this price on an invoice
1131
+ */
1132
+ invoice_grouping_key?: string | null;
1133
+ }
1134
+
1085
1135
  export interface NewPlanPackageWithAllocationPrice {
1086
1136
  /**
1087
1137
  * The cadence to bill for this price on.
@@ -298,7 +298,9 @@ export type Price =
298
298
  | Price.ThresholdTotalAmountPrice
299
299
  | Price.TieredPackagePrice
300
300
  | Price.TieredWithMinimumPrice
301
- | Price.PackageWithAllocationPrice;
301
+ | Price.PackageWithAllocationPrice
302
+ | Price.UnitWithPercentPrice
303
+ | Price.MatrixWithAllocationPrice;
302
304
 
303
305
  export namespace Price {
304
306
  export interface UnitPrice {
@@ -1399,12 +1401,214 @@ export namespace Price {
1399
1401
  minimum_amount: string;
1400
1402
  }
1401
1403
  }
1404
+
1405
+ export interface UnitWithPercentPrice {
1406
+ id: string;
1407
+
1408
+ billable_metric: UnitWithPercentPrice.BillableMetric | null;
1409
+
1410
+ cadence: 'one_time' | 'monthly' | 'quarterly' | 'annual';
1411
+
1412
+ created_at: string;
1413
+
1414
+ currency: string;
1415
+
1416
+ discount: Shared.Discount | null;
1417
+
1418
+ external_price_id: string | null;
1419
+
1420
+ fixed_price_quantity: number | null;
1421
+
1422
+ item: UnitWithPercentPrice.Item;
1423
+
1424
+ maximum: UnitWithPercentPrice.Maximum | null;
1425
+
1426
+ maximum_amount: string | null;
1427
+
1428
+ minimum: UnitWithPercentPrice.Minimum | null;
1429
+
1430
+ minimum_amount: string | null;
1431
+
1432
+ model_type: 'unit_with_percent';
1433
+
1434
+ name: string;
1435
+
1436
+ plan_phase_order: number | null;
1437
+
1438
+ price_type: 'usage_price' | 'fixed_price';
1439
+
1440
+ unit_with_percent_config: Record<string, unknown>;
1441
+ }
1442
+
1443
+ export namespace UnitWithPercentPrice {
1444
+ export interface BillableMetric {
1445
+ id: string;
1446
+ }
1447
+
1448
+ export interface Item {
1449
+ id: string;
1450
+
1451
+ name: string;
1452
+ }
1453
+
1454
+ export interface Maximum {
1455
+ /**
1456
+ * List of price_ids that this maximum amount applies to. For plan/plan phase
1457
+ * maximums, this can be a subset of prices.
1458
+ */
1459
+ applies_to_price_ids: Array<string>;
1460
+
1461
+ /**
1462
+ * Maximum amount applied
1463
+ */
1464
+ maximum_amount: string;
1465
+ }
1466
+
1467
+ export interface Minimum {
1468
+ /**
1469
+ * List of price_ids that this minimum amount applies to. For plan/plan phase
1470
+ * minimums, this can be a subset of prices.
1471
+ */
1472
+ applies_to_price_ids: Array<string>;
1473
+
1474
+ /**
1475
+ * Minimum amount applied
1476
+ */
1477
+ minimum_amount: string;
1478
+ }
1479
+ }
1480
+
1481
+ export interface MatrixWithAllocationPrice {
1482
+ id: string;
1483
+
1484
+ billable_metric: MatrixWithAllocationPrice.BillableMetric | null;
1485
+
1486
+ cadence: 'one_time' | 'monthly' | 'quarterly' | 'annual';
1487
+
1488
+ created_at: string;
1489
+
1490
+ currency: string;
1491
+
1492
+ discount: Shared.Discount | null;
1493
+
1494
+ external_price_id: string | null;
1495
+
1496
+ fixed_price_quantity: number | null;
1497
+
1498
+ item: MatrixWithAllocationPrice.Item;
1499
+
1500
+ matrix_with_allocation_config: MatrixWithAllocationPrice.MatrixWithAllocationConfig;
1501
+
1502
+ maximum: MatrixWithAllocationPrice.Maximum | null;
1503
+
1504
+ maximum_amount: string | null;
1505
+
1506
+ minimum: MatrixWithAllocationPrice.Minimum | null;
1507
+
1508
+ minimum_amount: string | null;
1509
+
1510
+ model_type: 'matrix_with_allocation';
1511
+
1512
+ name: string;
1513
+
1514
+ plan_phase_order: number | null;
1515
+
1516
+ price_type: 'usage_price' | 'fixed_price';
1517
+ }
1518
+
1519
+ export namespace MatrixWithAllocationPrice {
1520
+ export interface BillableMetric {
1521
+ id: string;
1522
+ }
1523
+
1524
+ export interface Item {
1525
+ id: string;
1526
+
1527
+ name: string;
1528
+ }
1529
+
1530
+ export interface MatrixWithAllocationConfig {
1531
+ /**
1532
+ * Allocation to be used to calculate the price
1533
+ */
1534
+ allocation: number;
1535
+
1536
+ /**
1537
+ * Default per unit rate for any usage not bucketed into a specified matrix_value
1538
+ */
1539
+ default_unit_amount: string;
1540
+
1541
+ /**
1542
+ * One or two event property values to evaluate matrix groups by
1543
+ */
1544
+ dimensions: Array<string | null>;
1545
+
1546
+ /**
1547
+ * Matrix values for specified matrix grouping keys
1548
+ */
1549
+ matrix_values: Array<MatrixWithAllocationConfig.MatrixValue>;
1550
+
1551
+ /**
1552
+ * Default optional multiplier to scale rated quantities that fall into the default
1553
+ * bucket by
1554
+ */
1555
+ scaling_factor?: number | null;
1556
+ }
1557
+
1558
+ export namespace MatrixWithAllocationConfig {
1559
+ export interface MatrixValue {
1560
+ /**
1561
+ * One or two matrix keys to filter usage to this Matrix value by. For example,
1562
+ * ["region", "tier"] could be used to filter cloud usage by a cloud region and an
1563
+ * instance tier.
1564
+ */
1565
+ dimension_values: Array<string | null>;
1566
+
1567
+ /**
1568
+ * Unit price for the specified dimension_values
1569
+ */
1570
+ unit_amount: string;
1571
+
1572
+ /**
1573
+ * Optional multiplier to scale rated quantities by
1574
+ */
1575
+ scaling_factor?: number | null;
1576
+ }
1577
+ }
1578
+
1579
+ export interface Maximum {
1580
+ /**
1581
+ * List of price_ids that this maximum amount applies to. For plan/plan phase
1582
+ * maximums, this can be a subset of prices.
1583
+ */
1584
+ applies_to_price_ids: Array<string>;
1585
+
1586
+ /**
1587
+ * Maximum amount applied
1588
+ */
1589
+ maximum_amount: string;
1590
+ }
1591
+
1592
+ export interface Minimum {
1593
+ /**
1594
+ * List of price_ids that this minimum amount applies to. For plan/plan phase
1595
+ * minimums, this can be a subset of prices.
1596
+ */
1597
+ applies_to_price_ids: Array<string>;
1598
+
1599
+ /**
1600
+ * Minimum amount applied
1601
+ */
1602
+ minimum_amount: string;
1603
+ }
1604
+ }
1402
1605
  }
1403
1606
 
1404
1607
  export type PriceCreateParams =
1405
1608
  | PriceCreateParams.NewFloatingUnitPrice
1406
1609
  | PriceCreateParams.NewFloatingPackagePrice
1407
1610
  | PriceCreateParams.NewFloatingMatrixPrice
1611
+ | PriceCreateParams.NewFloatingMatrixWithAllocationPrice
1408
1612
  | PriceCreateParams.NewFloatingTieredPrice
1409
1613
  | PriceCreateParams.NewFloatingTieredBpsPrice
1410
1614
  | PriceCreateParams.NewFloatingBpsPrice
@@ -1413,7 +1617,9 @@ export type PriceCreateParams =
1413
1617
  | PriceCreateParams.NewFloatingThresholdTotalAmountPrice
1414
1618
  | PriceCreateParams.NewFloatingTieredPackagePrice
1415
1619
  | PriceCreateParams.NewFloatingTieredWithMinimumPrice
1416
- | PriceCreateParams.NewFloatingPackageWithAllocationPrice;
1620
+ | PriceCreateParams.NewFloatingPackageWithAllocationPrice
1621
+ | PriceCreateParams.NewFloatingTieredPackageWithMinimumPrice
1622
+ | PriceCreateParams.NewFloatingUnitWithPercentPrice;
1417
1623
 
1418
1624
  export namespace PriceCreateParams {
1419
1625
  export interface NewFloatingUnitPrice {
@@ -1653,6 +1859,111 @@ export namespace PriceCreateParams {
1653
1859
  }
1654
1860
  }
1655
1861
 
1862
+ export interface NewFloatingMatrixWithAllocationPrice {
1863
+ /**
1864
+ * The cadence to bill for this price on.
1865
+ */
1866
+ cadence: 'annual' | 'monthly' | 'quarterly' | 'one_time';
1867
+
1868
+ /**
1869
+ * An ISO 4217 currency string for which this price is billed in.
1870
+ */
1871
+ currency: string;
1872
+
1873
+ /**
1874
+ * The id of the item the plan will be associated with.
1875
+ */
1876
+ item_id: string;
1877
+
1878
+ matrix_with_allocation_config: PriceCreateParams.NewFloatingMatrixWithAllocationPrice.MatrixWithAllocationConfig;
1879
+
1880
+ model_type: 'matrix_with_allocation';
1881
+
1882
+ /**
1883
+ * The name of the price.
1884
+ */
1885
+ name: string;
1886
+
1887
+ /**
1888
+ * The id of the billable metric for the price. Only needed if the price is
1889
+ * usage-based.
1890
+ */
1891
+ billable_metric_id?: string | null;
1892
+
1893
+ /**
1894
+ * If the Price represents a fixed cost, the price will be billed in-advance if
1895
+ * this is true, and in-arrears if this is false.
1896
+ */
1897
+ billed_in_advance?: boolean | null;
1898
+
1899
+ /**
1900
+ * An alias for the price.
1901
+ */
1902
+ external_price_id?: string | null;
1903
+
1904
+ /**
1905
+ * If the Price represents a fixed cost, this represents the quantity of units
1906
+ * applied.
1907
+ */
1908
+ fixed_price_quantity?: number | null;
1909
+
1910
+ /**
1911
+ * The property used to group this price on an invoice
1912
+ */
1913
+ invoice_grouping_key?: string | null;
1914
+ }
1915
+
1916
+ export namespace NewFloatingMatrixWithAllocationPrice {
1917
+ export interface MatrixWithAllocationConfig {
1918
+ /**
1919
+ * Allocation to be used to calculate the price
1920
+ */
1921
+ allocation: number;
1922
+
1923
+ /**
1924
+ * Default per unit rate for any usage not bucketed into a specified matrix_value
1925
+ */
1926
+ default_unit_amount: string;
1927
+
1928
+ /**
1929
+ * One or two event property values to evaluate matrix groups by
1930
+ */
1931
+ dimensions: Array<string | null>;
1932
+
1933
+ /**
1934
+ * Matrix values for specified matrix grouping keys
1935
+ */
1936
+ matrix_values: Array<MatrixWithAllocationConfig.MatrixValue>;
1937
+
1938
+ /**
1939
+ * Default optional multiplier to scale rated quantities that fall into the default
1940
+ * bucket by
1941
+ */
1942
+ scaling_factor?: number | null;
1943
+ }
1944
+
1945
+ export namespace MatrixWithAllocationConfig {
1946
+ export interface MatrixValue {
1947
+ /**
1948
+ * One or two matrix keys to filter usage to this Matrix value by. For example,
1949
+ * ["region", "tier"] could be used to filter cloud usage by a cloud region and an
1950
+ * instance tier.
1951
+ */
1952
+ dimension_values: Array<string | null>;
1953
+
1954
+ /**
1955
+ * Unit price for the specified dimension_values
1956
+ */
1957
+ unit_amount: string;
1958
+
1959
+ /**
1960
+ * Optional multiplier to scale rated quantities by
1961
+ */
1962
+ scaling_factor?: number | null;
1963
+ }
1964
+ }
1965
+ }
1966
+
1656
1967
  export interface NewFloatingTieredPrice {
1657
1968
  /**
1658
1969
  * The cadence to bill for this price on.
@@ -2266,6 +2577,114 @@ export namespace PriceCreateParams {
2266
2577
  */
2267
2578
  invoice_grouping_key?: string | null;
2268
2579
  }
2580
+
2581
+ export interface NewFloatingTieredPackageWithMinimumPrice {
2582
+ /**
2583
+ * The cadence to bill for this price on.
2584
+ */
2585
+ cadence: 'annual' | 'monthly' | 'quarterly' | 'one_time';
2586
+
2587
+ /**
2588
+ * An ISO 4217 currency string for which this price is billed in.
2589
+ */
2590
+ currency: string;
2591
+
2592
+ /**
2593
+ * The id of the item the plan will be associated with.
2594
+ */
2595
+ item_id: string;
2596
+
2597
+ model_type: 'tiered_package_with_minimum';
2598
+
2599
+ /**
2600
+ * The name of the price.
2601
+ */
2602
+ name: string;
2603
+
2604
+ tiered_package_with_minimum_config: Record<string, unknown>;
2605
+
2606
+ /**
2607
+ * The id of the billable metric for the price. Only needed if the price is
2608
+ * usage-based.
2609
+ */
2610
+ billable_metric_id?: string | null;
2611
+
2612
+ /**
2613
+ * If the Price represents a fixed cost, the price will be billed in-advance if
2614
+ * this is true, and in-arrears if this is false.
2615
+ */
2616
+ billed_in_advance?: boolean | null;
2617
+
2618
+ /**
2619
+ * An alias for the price.
2620
+ */
2621
+ external_price_id?: string | null;
2622
+
2623
+ /**
2624
+ * If the Price represents a fixed cost, this represents the quantity of units
2625
+ * applied.
2626
+ */
2627
+ fixed_price_quantity?: number | null;
2628
+
2629
+ /**
2630
+ * The property used to group this price on an invoice
2631
+ */
2632
+ invoice_grouping_key?: string | null;
2633
+ }
2634
+
2635
+ export interface NewFloatingUnitWithPercentPrice {
2636
+ /**
2637
+ * The cadence to bill for this price on.
2638
+ */
2639
+ cadence: 'annual' | 'monthly' | 'quarterly' | 'one_time';
2640
+
2641
+ /**
2642
+ * An ISO 4217 currency string for which this price is billed in.
2643
+ */
2644
+ currency: string;
2645
+
2646
+ /**
2647
+ * The id of the item the plan will be associated with.
2648
+ */
2649
+ item_id: string;
2650
+
2651
+ model_type: 'unit_with_percent';
2652
+
2653
+ /**
2654
+ * The name of the price.
2655
+ */
2656
+ name: string;
2657
+
2658
+ unit_with_percent_config: Record<string, unknown>;
2659
+
2660
+ /**
2661
+ * The id of the billable metric for the price. Only needed if the price is
2662
+ * usage-based.
2663
+ */
2664
+ billable_metric_id?: string | null;
2665
+
2666
+ /**
2667
+ * If the Price represents a fixed cost, the price will be billed in-advance if
2668
+ * this is true, and in-arrears if this is false.
2669
+ */
2670
+ billed_in_advance?: boolean | null;
2671
+
2672
+ /**
2673
+ * An alias for the price.
2674
+ */
2675
+ external_price_id?: string | null;
2676
+
2677
+ /**
2678
+ * If the Price represents a fixed cost, this represents the quantity of units
2679
+ * applied.
2680
+ */
2681
+ fixed_price_quantity?: number | null;
2682
+
2683
+ /**
2684
+ * The property used to group this price on an invoice
2685
+ */
2686
+ invoice_grouping_key?: string | null;
2687
+ }
2269
2688
  }
2270
2689
 
2271
2690
  export interface PriceListParams extends PageParams {}