@metronome/sdk 1.0.0 → 2.1.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 (192) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/bin/cli +5 -12
  3. package/internal/to-file.d.mts +1 -1
  4. package/internal/to-file.d.ts +1 -1
  5. package/internal/to-file.js +1 -1
  6. package/internal/to-file.mjs +1 -1
  7. package/package.json +1 -1
  8. package/resources/shared.d.mts +157 -7
  9. package/resources/shared.d.mts.map +1 -1
  10. package/resources/shared.d.ts +157 -7
  11. package/resources/shared.d.ts.map +1 -1
  12. package/resources/v1/alerts.d.mts +68 -64
  13. package/resources/v1/alerts.d.mts.map +1 -1
  14. package/resources/v1/alerts.d.ts +68 -64
  15. package/resources/v1/alerts.d.ts.map +1 -1
  16. package/resources/v1/alerts.js +40 -39
  17. package/resources/v1/alerts.js.map +1 -1
  18. package/resources/v1/alerts.mjs +40 -39
  19. package/resources/v1/alerts.mjs.map +1 -1
  20. package/resources/v1/contracts/contracts.d.mts +56 -9
  21. package/resources/v1/contracts/contracts.d.mts.map +1 -1
  22. package/resources/v1/contracts/contracts.d.ts +56 -9
  23. package/resources/v1/contracts/contracts.d.ts.map +1 -1
  24. package/resources/v1/contracts/contracts.js +5 -4
  25. package/resources/v1/contracts/contracts.js.map +1 -1
  26. package/resources/v1/contracts/contracts.mjs +5 -4
  27. package/resources/v1/contracts/contracts.mjs.map +1 -1
  28. package/resources/v1/credit-grants.d.mts +10 -5
  29. package/resources/v1/credit-grants.d.mts.map +1 -1
  30. package/resources/v1/credit-grants.d.ts +10 -5
  31. package/resources/v1/credit-grants.d.ts.map +1 -1
  32. package/resources/v1/credit-grants.js +10 -5
  33. package/resources/v1/credit-grants.js.map +1 -1
  34. package/resources/v1/credit-grants.mjs +10 -5
  35. package/resources/v1/credit-grants.mjs.map +1 -1
  36. package/resources/v1/customers/alerts.d.mts +99 -78
  37. package/resources/v1/customers/alerts.d.mts.map +1 -1
  38. package/resources/v1/customers/alerts.d.ts +99 -78
  39. package/resources/v1/customers/alerts.d.ts.map +1 -1
  40. package/resources/v1/customers/alerts.js +65 -46
  41. package/resources/v1/customers/alerts.js.map +1 -1
  42. package/resources/v1/customers/alerts.mjs +65 -46
  43. package/resources/v1/customers/alerts.mjs.map +1 -1
  44. package/resources/v1/customers/billing-config.d.mts +15 -7
  45. package/resources/v1/customers/billing-config.d.mts.map +1 -1
  46. package/resources/v1/customers/billing-config.d.ts +15 -7
  47. package/resources/v1/customers/billing-config.d.ts.map +1 -1
  48. package/resources/v1/customers/billing-config.js +6 -3
  49. package/resources/v1/customers/billing-config.js.map +1 -1
  50. package/resources/v1/customers/billing-config.mjs +6 -3
  51. package/resources/v1/customers/billing-config.mjs.map +1 -1
  52. package/resources/v1/customers/commits.d.mts +3 -2
  53. package/resources/v1/customers/commits.d.mts.map +1 -1
  54. package/resources/v1/customers/commits.d.ts +3 -2
  55. package/resources/v1/customers/commits.d.ts.map +1 -1
  56. package/resources/v1/customers/commits.js +2 -1
  57. package/resources/v1/customers/commits.js.map +1 -1
  58. package/resources/v1/customers/commits.mjs +2 -1
  59. package/resources/v1/customers/commits.mjs.map +1 -1
  60. package/resources/v1/customers/customers.d.mts +35 -26
  61. package/resources/v1/customers/customers.d.mts.map +1 -1
  62. package/resources/v1/customers/customers.d.ts +35 -26
  63. package/resources/v1/customers/customers.d.ts.map +1 -1
  64. package/resources/v1/customers/customers.js +11 -5
  65. package/resources/v1/customers/customers.js.map +1 -1
  66. package/resources/v1/customers/customers.mjs +11 -5
  67. package/resources/v1/customers/customers.mjs.map +1 -1
  68. package/resources/v1/customers/index.d.mts +1 -1
  69. package/resources/v1/customers/index.d.mts.map +1 -1
  70. package/resources/v1/customers/index.d.ts +1 -1
  71. package/resources/v1/customers/index.d.ts.map +1 -1
  72. package/resources/v1/customers/index.js.map +1 -1
  73. package/resources/v1/customers/index.mjs.map +1 -1
  74. package/resources/v1/customers/invoices.d.mts +169 -5
  75. package/resources/v1/customers/invoices.d.mts.map +1 -1
  76. package/resources/v1/customers/invoices.d.ts +169 -5
  77. package/resources/v1/customers/invoices.d.ts.map +1 -1
  78. package/resources/v1/customers/invoices.js +51 -1
  79. package/resources/v1/customers/invoices.js.map +1 -1
  80. package/resources/v1/customers/invoices.mjs +51 -1
  81. package/resources/v1/customers/invoices.mjs.map +1 -1
  82. package/resources/v1/customers/plans.d.mts +8 -4
  83. package/resources/v1/customers/plans.d.mts.map +1 -1
  84. package/resources/v1/customers/plans.d.ts +8 -4
  85. package/resources/v1/customers/plans.d.ts.map +1 -1
  86. package/resources/v1/customers/plans.js +8 -4
  87. package/resources/v1/customers/plans.js.map +1 -1
  88. package/resources/v1/customers/plans.mjs +8 -4
  89. package/resources/v1/customers/plans.mjs.map +1 -1
  90. package/resources/v1/index.d.mts +2 -0
  91. package/resources/v1/index.d.mts.map +1 -1
  92. package/resources/v1/index.d.ts +2 -0
  93. package/resources/v1/index.d.ts.map +1 -1
  94. package/resources/v1/index.js +5 -1
  95. package/resources/v1/index.js.map +1 -1
  96. package/resources/v1/index.mjs +2 -0
  97. package/resources/v1/index.mjs.map +1 -1
  98. package/resources/v1/payments.d.mts +117 -0
  99. package/resources/v1/payments.d.mts.map +1 -0
  100. package/resources/v1/payments.d.ts +117 -0
  101. package/resources/v1/payments.d.ts.map +1 -0
  102. package/resources/v1/payments.js +71 -0
  103. package/resources/v1/payments.js.map +1 -0
  104. package/resources/v1/payments.mjs +67 -0
  105. package/resources/v1/payments.mjs.map +1 -0
  106. package/resources/v1/plans.d.mts +8 -4
  107. package/resources/v1/plans.d.mts.map +1 -1
  108. package/resources/v1/plans.d.ts +8 -4
  109. package/resources/v1/plans.d.ts.map +1 -1
  110. package/resources/v1/plans.js +8 -4
  111. package/resources/v1/plans.js.map +1 -1
  112. package/resources/v1/plans.mjs +8 -4
  113. package/resources/v1/plans.mjs.map +1 -1
  114. package/resources/v1/settings/billing-providers.d.mts +103 -0
  115. package/resources/v1/settings/billing-providers.d.mts.map +1 -0
  116. package/resources/v1/settings/billing-providers.d.ts +103 -0
  117. package/resources/v1/settings/billing-providers.d.ts.map +1 -0
  118. package/resources/v1/settings/billing-providers.js +48 -0
  119. package/resources/v1/settings/billing-providers.js.map +1 -0
  120. package/resources/v1/settings/billing-providers.mjs +44 -0
  121. package/resources/v1/settings/billing-providers.mjs.map +1 -0
  122. package/resources/v1/settings/index.d.mts +3 -0
  123. package/resources/v1/settings/index.d.mts.map +1 -0
  124. package/resources/v1/settings/index.d.ts +3 -0
  125. package/resources/v1/settings/index.d.ts.map +1 -0
  126. package/resources/v1/settings/index.js +9 -0
  127. package/resources/v1/settings/index.js.map +1 -0
  128. package/resources/v1/settings/index.mjs +4 -0
  129. package/resources/v1/settings/index.mjs.map +1 -0
  130. package/resources/v1/settings/settings.d.mts +54 -0
  131. package/resources/v1/settings/settings.d.mts.map +1 -0
  132. package/resources/v1/settings/settings.d.ts +54 -0
  133. package/resources/v1/settings/settings.d.ts.map +1 -0
  134. package/resources/v1/settings/settings.js +39 -0
  135. package/resources/v1/settings/settings.js.map +1 -0
  136. package/resources/v1/settings/settings.mjs +34 -0
  137. package/resources/v1/settings/settings.mjs.map +1 -0
  138. package/resources/v1/settings.d.mts +2 -0
  139. package/resources/v1/settings.d.mts.map +1 -0
  140. package/resources/v1/settings.d.ts +2 -0
  141. package/resources/v1/settings.d.ts.map +1 -0
  142. package/resources/v1/settings.js +6 -0
  143. package/resources/v1/settings.js.map +1 -0
  144. package/resources/v1/settings.mjs +3 -0
  145. package/resources/v1/settings.mjs.map +1 -0
  146. package/resources/v1/usage.d.mts +4 -2
  147. package/resources/v1/usage.d.mts.map +1 -1
  148. package/resources/v1/usage.d.ts +4 -2
  149. package/resources/v1/usage.d.ts.map +1 -1
  150. package/resources/v1/usage.js +4 -2
  151. package/resources/v1/usage.js.map +1 -1
  152. package/resources/v1/usage.mjs +4 -2
  153. package/resources/v1/usage.mjs.map +1 -1
  154. package/resources/v1/v1.d.mts +8 -0
  155. package/resources/v1/v1.d.mts.map +1 -1
  156. package/resources/v1/v1.d.ts +8 -0
  157. package/resources/v1/v1.d.ts.map +1 -1
  158. package/resources/v1/v1.js +8 -0
  159. package/resources/v1/v1.js.map +1 -1
  160. package/resources/v1/v1.mjs +8 -0
  161. package/resources/v1/v1.mjs.map +1 -1
  162. package/resources/v2/contracts.d.mts +120 -5
  163. package/resources/v2/contracts.d.mts.map +1 -1
  164. package/resources/v2/contracts.d.ts +120 -5
  165. package/resources/v2/contracts.d.ts.map +1 -1
  166. package/src/internal/to-file.ts +1 -1
  167. package/src/resources/shared.ts +190 -7
  168. package/src/resources/v1/alerts.ts +68 -64
  169. package/src/resources/v1/contracts/contracts.ts +61 -9
  170. package/src/resources/v1/credit-grants.ts +10 -5
  171. package/src/resources/v1/customers/alerts.ts +99 -77
  172. package/src/resources/v1/customers/billing-config.ts +18 -7
  173. package/src/resources/v1/customers/commits.ts +3 -2
  174. package/src/resources/v1/customers/customers.ts +39 -25
  175. package/src/resources/v1/customers/index.ts +1 -0
  176. package/src/resources/v1/customers/invoices.ts +210 -4
  177. package/src/resources/v1/customers/plans.ts +8 -4
  178. package/src/resources/v1/index.ts +16 -0
  179. package/src/resources/v1/payments.ts +172 -0
  180. package/src/resources/v1/plans.ts +8 -4
  181. package/src/resources/v1/settings/billing-providers.ts +139 -0
  182. package/src/resources/v1/settings/index.ts +14 -0
  183. package/src/resources/v1/settings/settings.ts +87 -0
  184. package/src/resources/v1/settings.ts +3 -0
  185. package/src/resources/v1/usage.ts +4 -2
  186. package/src/resources/v1/v1.ts +40 -0
  187. package/src/resources/v2/contracts.ts +156 -5
  188. package/src/version.ts +1 -1
  189. package/version.d.mts +1 -1
  190. package/version.d.ts +1 -1
  191. package/version.js +1 -1
  192. package/version.mjs +1 -1
@@ -70,6 +70,7 @@ export {
70
70
  type InvoiceListParams,
71
71
  type InvoiceAddChargeParams,
72
72
  type InvoiceListBreakdownsParams,
73
+ type InvoiceRetrievePdfParams,
73
74
  type InvoicesCursorPage,
74
75
  type InvoiceListBreakdownsResponsesCursorPage,
75
76
  } from './invoices';
@@ -4,6 +4,7 @@ import { APIResource } from '../../../core/resource';
4
4
  import * as Shared from '../../shared';
5
5
  import { APIPromise } from '../../../core/api-promise';
6
6
  import { CursorPage, type CursorPageParams, PagePromise } from '../../../core/pagination';
7
+ import { buildHeaders } from '../../../internal/headers';
7
8
  import { RequestOptions } from '../../../internal/request-options';
8
9
  import { path } from '../../../internal/utils/path';
9
10
 
@@ -132,7 +133,8 @@ export class Invoices extends APIResource {
132
133
  }
133
134
 
134
135
  /**
135
- * Add a one time charge to the specified invoice
136
+ * Add a one time charge to the specified invoice. This is a Plans (deprecated)
137
+ * endpoint. New clients should implement using Contracts.
136
138
  *
137
139
  * @example
138
140
  * ```ts
@@ -219,6 +221,55 @@ export class Invoices extends APIResource {
219
221
  { query, ...options },
220
222
  );
221
223
  }
224
+
225
+ /**
226
+ * Retrieve a PDF version of a specific invoice by its unique identifier. This
227
+ * endpoint generates a professionally formatted invoice document suitable for
228
+ * sharing with customers, accounting teams, or for record-keeping purposes.
229
+ *
230
+ * ### Use this endpoint to:
231
+ *
232
+ * - Provide customers with downloadable or emailable copies of their invoices
233
+ * - Support accounting and finance teams with official billing documents
234
+ * - Maintain accurate records of billing transactions for audits and compliance
235
+ *
236
+ * ### Key response details:
237
+ *
238
+ * - The response is a binary PDF file representing the full invoice
239
+ * - The PDF includes all standard invoice information such as line items, totals,
240
+ * billing period, and customer details
241
+ * - The document is formatted for clarity and professionalism, suitable for
242
+ * official use
243
+ *
244
+ * ### Usage guidelines:
245
+ *
246
+ * - Ensure the `invoice_id` corresponds to an existing invoice for the specified
247
+ * `customer_id`
248
+ * - The PDF is generated on-demand; frequent requests for the same invoice may
249
+ * impact performance
250
+ * - Use appropriate headers to handle the binary response in your application
251
+ * (e.g., setting `Content-Type: application/pdf`)
252
+ *
253
+ * @example
254
+ * ```ts
255
+ * const response =
256
+ * await client.v1.customers.invoices.retrievePdf({
257
+ * customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',
258
+ * invoice_id: '6a37bb88-8538-48c5-b37b-a41c836328bd',
259
+ * });
260
+ *
261
+ * const content = await response.blob();
262
+ * console.log(content);
263
+ * ```
264
+ */
265
+ retrievePdf(params: InvoiceRetrievePdfParams, options?: RequestOptions): APIPromise<Response> {
266
+ const { customer_id, invoice_id } = params;
267
+ return this._client.get(path`/v1/customers/${customer_id}/invoices/${invoice_id}/pdf`, {
268
+ ...options,
269
+ headers: buildHeaders([{ Accept: 'application/pdf' }, options?.headers]),
270
+ __binaryResponse: true,
271
+ });
272
+ }
222
273
  }
223
274
 
224
275
  export type InvoicesCursorPage = CursorPage<Invoice>;
@@ -245,7 +296,13 @@ export interface Invoice {
245
296
  /**
246
297
  * This field's availability is dependent on your client's configuration.
247
298
  */
248
- billable_status?: 'billable' | 'unbillable';
299
+ billable_status?: unknown;
300
+
301
+ /**
302
+ * Account hierarchy M3 - Required on invoices with type USAGE_CONSOLIDATED. List
303
+ * of constituent invoices that were consolidated to create this invoice.
304
+ */
305
+ constituent_invoices?: Array<Invoice.ConstituentInvoice>;
249
306
 
250
307
  /**
251
308
  * Custom fields to be added eg. { "key1": "value1", "key2": "value2" }
@@ -290,6 +347,12 @@ export interface Invoice {
290
347
  */
291
348
  netsuite_sales_order_id?: string;
292
349
 
350
+ /**
351
+ * Account hierarchy M3 - Required for account hierarchy usage invoices. An object
352
+ * containing the contract and customer UUIDs that pay for this invoice.
353
+ */
354
+ payer?: Invoice.Payer;
355
+
293
356
  /**
294
357
  * Custom fields to be added eg. { "key1": "value1", "key2": "value2" }
295
358
  */
@@ -434,6 +497,13 @@ export namespace Invoice {
434
497
 
435
498
  netsuite_item_id?: string;
436
499
 
500
+ /**
501
+ * Account hierarchy M3 - Present on line items from invoices with type
502
+ * USAGE_CONSOLIDATED. Indicates the original customer, contract, invoice and line
503
+ * item from which this line item was copied.
504
+ */
505
+ origin?: LineItem.Origin;
506
+
437
507
  /**
438
508
  * Only present for line items paying for a postpaid commit true-up.
439
509
  */
@@ -534,6 +604,21 @@ export namespace Invoice {
534
604
  type: 'PREPAID' | 'POSTPAID' | 'CREDIT';
535
605
  }
536
606
 
607
+ /**
608
+ * Account hierarchy M3 - Present on line items from invoices with type
609
+ * USAGE_CONSOLIDATED. Indicates the original customer, contract, invoice and line
610
+ * item from which this line item was copied.
611
+ */
612
+ export interface Origin {
613
+ contract_id: string;
614
+
615
+ customer_id: string;
616
+
617
+ invoice_id: string;
618
+
619
+ line_item_id: string;
620
+ }
621
+
537
622
  /**
538
623
  * Only present for line items paying for a postpaid commit true-up.
539
624
  */
@@ -617,6 +702,14 @@ export namespace Invoice {
617
702
  }
618
703
  }
619
704
 
705
+ export interface ConstituentInvoice {
706
+ contract_id: string;
707
+
708
+ customer_id: string;
709
+
710
+ invoice_id: string;
711
+ }
712
+
620
713
  export interface CorrectionRecord {
621
714
  corrected_invoice_id: string;
622
715
 
@@ -637,7 +730,13 @@ export namespace Invoice {
637
730
  | 'azure_marketplace'
638
731
  | 'quickbooks_online'
639
732
  | 'workday'
640
- | 'gcp_marketplace';
733
+ | 'gcp_marketplace'
734
+ | 'metronome';
735
+
736
+ /**
737
+ * Error message from the billing provider, if available.
738
+ */
739
+ billing_provider_error?: string;
641
740
 
642
741
  external_status?:
643
742
  | 'DRAFT'
@@ -654,7 +753,49 @@ export namespace Invoice {
654
753
 
655
754
  invoice_id?: string;
656
755
 
756
+ /**
757
+ * The subtotal amount invoiced, if available from the billing provider.
758
+ */
759
+ invoiced_sub_total?: number;
760
+
761
+ /**
762
+ * The total amount invoiced, if available from the billing provider.
763
+ */
764
+ invoiced_total?: number;
765
+
657
766
  issued_at_timestamp?: string;
767
+
768
+ /**
769
+ * A URL to the PDF of the invoice, if available from the billing provider.
770
+ */
771
+ pdf_url?: string;
772
+
773
+ /**
774
+ * Tax details for the invoice, if available from the billing provider.
775
+ */
776
+ tax?: CorrectedExternalInvoice.Tax;
777
+ }
778
+
779
+ export namespace CorrectedExternalInvoice {
780
+ /**
781
+ * Tax details for the invoice, if available from the billing provider.
782
+ */
783
+ export interface Tax {
784
+ /**
785
+ * The total tax amount applied to the invoice.
786
+ */
787
+ total_tax_amount?: number;
788
+
789
+ /**
790
+ * The total taxable amount of the invoice.
791
+ */
792
+ total_taxable_amount?: number;
793
+
794
+ /**
795
+ * The transaction ID associated with the tax calculation.
796
+ */
797
+ transaction_id?: string;
798
+ }
658
799
  }
659
800
  }
660
801
 
@@ -667,7 +808,13 @@ export namespace Invoice {
667
808
  | 'azure_marketplace'
668
809
  | 'quickbooks_online'
669
810
  | 'workday'
670
- | 'gcp_marketplace';
811
+ | 'gcp_marketplace'
812
+ | 'metronome';
813
+
814
+ /**
815
+ * Error message from the billing provider, if available.
816
+ */
817
+ billing_provider_error?: string;
671
818
 
672
819
  external_status?:
673
820
  | 'DRAFT'
@@ -684,7 +831,49 @@ export namespace Invoice {
684
831
 
685
832
  invoice_id?: string;
686
833
 
834
+ /**
835
+ * The subtotal amount invoiced, if available from the billing provider.
836
+ */
837
+ invoiced_sub_total?: number;
838
+
839
+ /**
840
+ * The total amount invoiced, if available from the billing provider.
841
+ */
842
+ invoiced_total?: number;
843
+
687
844
  issued_at_timestamp?: string;
845
+
846
+ /**
847
+ * A URL to the PDF of the invoice, if available from the billing provider.
848
+ */
849
+ pdf_url?: string;
850
+
851
+ /**
852
+ * Tax details for the invoice, if available from the billing provider.
853
+ */
854
+ tax?: ExternalInvoice.Tax;
855
+ }
856
+
857
+ export namespace ExternalInvoice {
858
+ /**
859
+ * Tax details for the invoice, if available from the billing provider.
860
+ */
861
+ export interface Tax {
862
+ /**
863
+ * The total tax amount applied to the invoice.
864
+ */
865
+ total_tax_amount?: number;
866
+
867
+ /**
868
+ * The total taxable amount of the invoice.
869
+ */
870
+ total_taxable_amount?: number;
871
+
872
+ /**
873
+ * The transaction ID associated with the tax calculation.
874
+ */
875
+ transaction_id?: string;
876
+ }
688
877
  }
689
878
 
690
879
  export interface InvoiceAdjustment {
@@ -702,6 +891,16 @@ export namespace Invoice {
702
891
  credit_grant_id?: string;
703
892
  }
704
893
 
894
+ /**
895
+ * Account hierarchy M3 - Required for account hierarchy usage invoices. An object
896
+ * containing the contract and customer UUIDs that pay for this invoice.
897
+ */
898
+ export interface Payer {
899
+ contract_id: string;
900
+
901
+ customer_id: string;
902
+ }
903
+
705
904
  /**
706
905
  * Only present for contract invoices with reseller royalties.
707
906
  */
@@ -891,6 +1090,12 @@ export interface InvoiceListBreakdownsParams extends CursorPageParams {
891
1090
  window_size?: 'HOUR' | 'DAY';
892
1091
  }
893
1092
 
1093
+ export interface InvoiceRetrievePdfParams {
1094
+ customer_id: string;
1095
+
1096
+ invoice_id: string;
1097
+ }
1098
+
894
1099
  export declare namespace Invoices {
895
1100
  export {
896
1101
  type Invoice as Invoice,
@@ -903,5 +1108,6 @@ export declare namespace Invoices {
903
1108
  type InvoiceListParams as InvoiceListParams,
904
1109
  type InvoiceAddChargeParams as InvoiceAddChargeParams,
905
1110
  type InvoiceListBreakdownsParams as InvoiceListBreakdownsParams,
1111
+ type InvoiceRetrievePdfParams as InvoiceRetrievePdfParams,
906
1112
  };
907
1113
  }
@@ -9,7 +9,8 @@ import { path } from '../../../internal/utils/path';
9
9
 
10
10
  export class Plans extends APIResource {
11
11
  /**
12
- * List the given customer's plans in reverse-chronological order.
12
+ * List the given customer's plans in reverse-chronological order. This is a Plans
13
+ * (deprecated) endpoint. New clients should implement using Contracts.
13
14
  *
14
15
  * @example
15
16
  * ```ts
@@ -35,7 +36,8 @@ export class Plans extends APIResource {
35
36
  /**
36
37
  * Associate an existing customer with a plan for a specified date range. See the
37
38
  * [price adjustments documentation](https://plans-docs.metronome.com/pricing/managing-plans/#price-adjustments)
38
- * for details on the price adjustments.
39
+ * for details on the price adjustments. This is a Plans (deprecated) endpoint. New
40
+ * clients should implement using Contracts.
39
41
  *
40
42
  * @example
41
43
  * ```ts
@@ -53,7 +55,8 @@ export class Plans extends APIResource {
53
55
  }
54
56
 
55
57
  /**
56
- * Change the end date of a customer's plan.
58
+ * Change the end date of a customer's plan. This is a Plans (deprecated) endpoint.
59
+ * New clients should implement using Contracts.
57
60
  *
58
61
  * @example
59
62
  * ```ts
@@ -75,7 +78,8 @@ export class Plans extends APIResource {
75
78
  /**
76
79
  * Lists a customer plans adjustments. See the
77
80
  * [price adjustments documentation](https://plans-docs.metronome.com/pricing/managing-plans/#price-adjustments)
78
- * for details.
81
+ * for details. This is a Plans (deprecated) endpoint. New clients should implement
82
+ * using Contracts.
79
83
  *
80
84
  * @example
81
85
  * ```ts
@@ -121,6 +121,17 @@ export {
121
121
  type InvoiceRegenerateParams,
122
122
  type InvoiceVoidParams,
123
123
  } from './invoices';
124
+ export {
125
+ Payments,
126
+ type Payment,
127
+ type PaymentStatus,
128
+ type PaymentAttemptResponse,
129
+ type PaymentCancelResponse,
130
+ type PaymentListParams,
131
+ type PaymentAttemptParams,
132
+ type PaymentCancelParams,
133
+ type PaymentsBodyCursorPage,
134
+ } from './payments';
124
135
  export {
125
136
  Plans,
126
137
  type PlanDetail,
@@ -143,6 +154,11 @@ export {
143
154
  type PricingUnitListResponsesCursorPage,
144
155
  } from './pricing-units';
145
156
  export { Services, type ServiceListResponse } from './services';
157
+ export {
158
+ Settings,
159
+ type SettingUpsertAvalaraCredentialsResponse,
160
+ type SettingUpsertAvalaraCredentialsParams,
161
+ } from './settings/index';
146
162
  export {
147
163
  Usage,
148
164
  type UsageListResponse,
@@ -0,0 +1,172 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import * as Shared from '../shared';
5
+ import { APIPromise } from '../../core/api-promise';
6
+ import { BodyCursorPage, type BodyCursorPageParams, PagePromise } from '../../core/pagination';
7
+ import { RequestOptions } from '../../internal/request-options';
8
+
9
+ export class Payments extends APIResource {
10
+ /**
11
+ * Fetch all payment attempts for the given invoice.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * // Automatically fetches more pages as needed.
16
+ * for await (const payment of client.v1.payments.list({
17
+ * customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',
18
+ * invoice_id: '6162d87b-e5db-4a33-b7f2-76ce6ead4e85',
19
+ * statuses: ['pending', 'requires_intervention'],
20
+ * })) {
21
+ * // ...
22
+ * }
23
+ * ```
24
+ */
25
+ list(body: PaymentListParams, options?: RequestOptions): PagePromise<PaymentsBodyCursorPage, Payment> {
26
+ return this._client.getAPIList('/v1/payments/list', BodyCursorPage<Payment>, {
27
+ body,
28
+ method: 'post',
29
+ ...options,
30
+ });
31
+ }
32
+
33
+ /**
34
+ * Trigger a new attempt by canceling any existing attempts for this invoice and
35
+ * creating a new Payment. This will trigger another attempt to charge the
36
+ * Customer's configured Payment Gateway. Payment can only be attempted if all of
37
+ * the following are true:
38
+ *
39
+ * - The Metronome Invoice is finalized
40
+ * - PLG Invoicing is configured for the Customer
41
+ * - You cannot attempt payments for invoices that have already been `paid` or
42
+ * `voided`.
43
+ *
44
+ * Attempting to payment on an ineligible Invoice or Customer will result in a
45
+ * `400` response.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * const response = await client.v1.payments.attempt({
50
+ * customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',
51
+ * invoice_id: '6162d87b-e5db-4a33-b7f2-76ce6ead4e85',
52
+ * });
53
+ * ```
54
+ */
55
+ attempt(body: PaymentAttemptParams, options?: RequestOptions): APIPromise<PaymentAttemptResponse> {
56
+ return this._client.post('/v1/payments/attempt', { body, ...options });
57
+ }
58
+
59
+ /**
60
+ * Cancel an existing payment attempt for an invoice.
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * const response = await client.v1.payments.cancel({
65
+ * customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',
66
+ * invoice_id: '6162d87b-e5db-4a33-b7f2-76ce6ead4e85',
67
+ * });
68
+ * ```
69
+ */
70
+ cancel(body: PaymentCancelParams, options?: RequestOptions): APIPromise<PaymentCancelResponse> {
71
+ return this._client.post('/v1/payments/cancel', { body, ...options });
72
+ }
73
+ }
74
+
75
+ export type PaymentsBodyCursorPage = BodyCursorPage<Payment>;
76
+
77
+ export interface Payment {
78
+ id: string;
79
+
80
+ amount?: number;
81
+
82
+ amount_paid?: number;
83
+
84
+ contract_id?: string;
85
+
86
+ created_at?: string;
87
+
88
+ customer_id?: string;
89
+
90
+ error_message?: string;
91
+
92
+ fiat_credit_type?: Shared.CreditTypeData;
93
+
94
+ invoice_id?: string;
95
+
96
+ payment_gateway?: Payment.PaymentGateway;
97
+
98
+ status?: PaymentStatus;
99
+
100
+ updated_at?: string;
101
+ }
102
+
103
+ export namespace Payment {
104
+ export interface PaymentGateway {
105
+ stripe: PaymentGateway.Stripe;
106
+
107
+ type: 'stripe';
108
+ }
109
+
110
+ export namespace PaymentGateway {
111
+ export interface Stripe {
112
+ payment_intent_id: string;
113
+
114
+ error?: Stripe.Error;
115
+
116
+ payment_method_id?: string;
117
+ }
118
+
119
+ export namespace Stripe {
120
+ export interface Error {
121
+ code?: string;
122
+
123
+ decline_code?: string;
124
+
125
+ type?: string;
126
+ }
127
+ }
128
+ }
129
+ }
130
+
131
+ export type PaymentStatus = 'pending' | 'requires_intervention' | 'paid' | 'canceled';
132
+
133
+ export interface PaymentAttemptResponse {
134
+ data: Payment;
135
+ }
136
+
137
+ export interface PaymentCancelResponse {
138
+ data: Payment;
139
+ }
140
+
141
+ export interface PaymentListParams extends BodyCursorPageParams {
142
+ customer_id: string;
143
+
144
+ invoice_id: string;
145
+
146
+ statuses?: Array<PaymentStatus>;
147
+ }
148
+
149
+ export interface PaymentAttemptParams {
150
+ customer_id: string;
151
+
152
+ invoice_id: string;
153
+ }
154
+
155
+ export interface PaymentCancelParams {
156
+ customer_id: string;
157
+
158
+ invoice_id: string;
159
+ }
160
+
161
+ export declare namespace Payments {
162
+ export {
163
+ type Payment as Payment,
164
+ type PaymentStatus as PaymentStatus,
165
+ type PaymentAttemptResponse as PaymentAttemptResponse,
166
+ type PaymentCancelResponse as PaymentCancelResponse,
167
+ type PaymentsBodyCursorPage as PaymentsBodyCursorPage,
168
+ type PaymentListParams as PaymentListParams,
169
+ type PaymentAttemptParams as PaymentAttemptParams,
170
+ type PaymentCancelParams as PaymentCancelParams,
171
+ };
172
+ }
@@ -10,7 +10,8 @@ import { path } from '../../internal/utils/path';
10
10
 
11
11
  export class Plans extends APIResource {
12
12
  /**
13
- * List all available plans.
13
+ * List all available plans. This is a Plans (deprecated) endpoint. New clients
14
+ * should implement using Contracts.
14
15
  *
15
16
  * @example
16
17
  * ```ts
@@ -28,7 +29,8 @@ export class Plans extends APIResource {
28
29
  }
29
30
 
30
31
  /**
31
- * Fetch high level details of a specific plan.
32
+ * Fetch high level details of a specific plan. This is a Plans (deprecated)
33
+ * endpoint. New clients should implement using Contracts.
32
34
  *
33
35
  * @example
34
36
  * ```ts
@@ -43,7 +45,8 @@ export class Plans extends APIResource {
43
45
  }
44
46
 
45
47
  /**
46
- * Fetches a list of charges of a specific plan.
48
+ * Fetches a list of charges of a specific plan. This is a Plans (deprecated)
49
+ * endpoint. New clients should implement using Contracts.
47
50
  *
48
51
  * @example
49
52
  * ```ts
@@ -69,7 +72,8 @@ export class Plans extends APIResource {
69
72
 
70
73
  /**
71
74
  * Fetches a list of customers on a specific plan (by default, only currently
72
- * active plans are included)
75
+ * active plans are included). This is a Plans (deprecated) endpoint. New clients
76
+ * should implement using Contracts.
73
77
  *
74
78
  * @example
75
79
  * ```ts