@metronome/sdk 3.0.0 → 3.5.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.
- package/CHANGELOG.md +204 -0
- package/README.md +2 -2
- package/client.d.mts +5 -3
- package/client.d.mts.map +1 -1
- package/client.d.ts +5 -3
- package/client.d.ts.map +1 -1
- package/client.js +26 -10
- package/client.js.map +1 -1
- package/client.mjs +26 -10
- package/client.mjs.map +1 -1
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +5 -0
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +5 -0
- package/internal/parse.mjs.map +1 -1
- package/internal/tslib.js +17 -17
- package/internal/utils/env.js +2 -2
- package/internal/utils/env.js.map +1 -1
- package/internal/utils/env.mjs +2 -2
- package/internal/utils/env.mjs.map +1 -1
- package/internal/utils/query.d.mts +2 -0
- package/internal/utils/query.d.mts.map +1 -0
- package/internal/utils/query.d.ts +2 -0
- package/internal/utils/query.d.ts.map +1 -0
- package/internal/utils/query.js +10 -0
- package/internal/utils/query.js.map +1 -0
- package/internal/utils/query.mjs +6 -0
- package/internal/utils/query.mjs.map +1 -0
- package/internal/utils.d.mts +1 -0
- package/internal/utils.d.ts +1 -0
- package/internal/utils.js +1 -0
- package/internal/utils.js.map +1 -1
- package/internal/utils.mjs +1 -0
- package/package.json +12 -1
- package/resources/shared.d.mts +130 -30
- package/resources/shared.d.mts.map +1 -1
- package/resources/shared.d.ts +130 -30
- package/resources/shared.d.ts.map +1 -1
- package/resources/v1/alerts.d.mts +3 -0
- package/resources/v1/alerts.d.mts.map +1 -1
- package/resources/v1/alerts.d.ts +3 -0
- package/resources/v1/alerts.d.ts.map +1 -1
- package/resources/v1/alerts.js +3 -0
- package/resources/v1/alerts.js.map +1 -1
- package/resources/v1/alerts.mjs +3 -0
- package/resources/v1/alerts.mjs.map +1 -1
- package/resources/v1/audit-logs.d.mts +3 -0
- package/resources/v1/audit-logs.d.mts.map +1 -1
- package/resources/v1/audit-logs.d.ts +3 -0
- package/resources/v1/audit-logs.d.ts.map +1 -1
- package/resources/v1/audit-logs.js +3 -0
- package/resources/v1/audit-logs.js.map +1 -1
- package/resources/v1/audit-logs.mjs +3 -0
- package/resources/v1/audit-logs.mjs.map +1 -1
- package/resources/v1/billable-metrics.d.mts +3 -0
- package/resources/v1/billable-metrics.d.mts.map +1 -1
- package/resources/v1/billable-metrics.d.ts +3 -0
- package/resources/v1/billable-metrics.d.ts.map +1 -1
- package/resources/v1/billable-metrics.js +3 -0
- package/resources/v1/billable-metrics.js.map +1 -1
- package/resources/v1/billable-metrics.mjs +3 -0
- package/resources/v1/billable-metrics.mjs.map +1 -1
- package/resources/v1/contracts/contracts.d.mts +141 -28
- package/resources/v1/contracts/contracts.d.mts.map +1 -1
- package/resources/v1/contracts/contracts.d.ts +141 -28
- package/resources/v1/contracts/contracts.d.ts.map +1 -1
- package/resources/v1/contracts/contracts.js +76 -0
- package/resources/v1/contracts/contracts.js.map +1 -1
- package/resources/v1/contracts/contracts.mjs +76 -0
- package/resources/v1/contracts/contracts.mjs.map +1 -1
- package/resources/v1/contracts/index.d.mts +1 -1
- package/resources/v1/contracts/index.d.mts.map +1 -1
- package/resources/v1/contracts/index.d.ts +1 -1
- package/resources/v1/contracts/index.d.ts.map +1 -1
- package/resources/v1/contracts/index.js.map +1 -1
- package/resources/v1/contracts/index.mjs.map +1 -1
- package/resources/v1/contracts/named-schedules.d.mts +3 -0
- package/resources/v1/contracts/named-schedules.d.mts.map +1 -1
- package/resources/v1/contracts/named-schedules.d.ts +3 -0
- package/resources/v1/contracts/named-schedules.d.ts.map +1 -1
- package/resources/v1/contracts/named-schedules.js +3 -0
- package/resources/v1/contracts/named-schedules.js.map +1 -1
- package/resources/v1/contracts/named-schedules.mjs +3 -0
- package/resources/v1/contracts/named-schedules.mjs.map +1 -1
- package/resources/v1/contracts/products.d.mts +3 -0
- package/resources/v1/contracts/products.d.mts.map +1 -1
- package/resources/v1/contracts/products.d.ts +3 -0
- package/resources/v1/contracts/products.d.ts.map +1 -1
- package/resources/v1/contracts/products.js +3 -0
- package/resources/v1/contracts/products.js.map +1 -1
- package/resources/v1/contracts/products.mjs +3 -0
- package/resources/v1/contracts/products.mjs.map +1 -1
- package/resources/v1/contracts/rate-cards/named-schedules.d.mts +3 -0
- package/resources/v1/contracts/rate-cards/named-schedules.d.mts.map +1 -1
- package/resources/v1/contracts/rate-cards/named-schedules.d.ts +3 -0
- package/resources/v1/contracts/rate-cards/named-schedules.d.ts.map +1 -1
- package/resources/v1/contracts/rate-cards/named-schedules.js +3 -0
- package/resources/v1/contracts/rate-cards/named-schedules.js.map +1 -1
- package/resources/v1/contracts/rate-cards/named-schedules.mjs +3 -0
- package/resources/v1/contracts/rate-cards/named-schedules.mjs.map +1 -1
- package/resources/v1/contracts/rate-cards/product-orders.d.mts +3 -0
- package/resources/v1/contracts/rate-cards/product-orders.d.mts.map +1 -1
- package/resources/v1/contracts/rate-cards/product-orders.d.ts +3 -0
- package/resources/v1/contracts/rate-cards/product-orders.d.ts.map +1 -1
- package/resources/v1/contracts/rate-cards/product-orders.js +3 -0
- package/resources/v1/contracts/rate-cards/product-orders.js.map +1 -1
- package/resources/v1/contracts/rate-cards/product-orders.mjs +3 -0
- package/resources/v1/contracts/rate-cards/product-orders.mjs.map +1 -1
- package/resources/v1/contracts/rate-cards/rate-cards.d.mts +3 -0
- package/resources/v1/contracts/rate-cards/rate-cards.d.mts.map +1 -1
- package/resources/v1/contracts/rate-cards/rate-cards.d.ts +3 -0
- package/resources/v1/contracts/rate-cards/rate-cards.d.ts.map +1 -1
- package/resources/v1/contracts/rate-cards/rate-cards.js +3 -0
- package/resources/v1/contracts/rate-cards/rate-cards.js.map +1 -1
- package/resources/v1/contracts/rate-cards/rate-cards.mjs +3 -0
- package/resources/v1/contracts/rate-cards/rate-cards.mjs.map +1 -1
- package/resources/v1/contracts/rate-cards/rates.d.mts +6 -3
- package/resources/v1/contracts/rate-cards/rates.d.mts.map +1 -1
- package/resources/v1/contracts/rate-cards/rates.d.ts +6 -3
- package/resources/v1/contracts/rate-cards/rates.d.ts.map +1 -1
- package/resources/v1/contracts/rate-cards/rates.js +3 -0
- package/resources/v1/contracts/rate-cards/rates.js.map +1 -1
- package/resources/v1/contracts/rate-cards/rates.mjs +3 -0
- package/resources/v1/contracts/rate-cards/rates.mjs.map +1 -1
- package/resources/v1/credit-grants.d.mts +3 -0
- package/resources/v1/credit-grants.d.mts.map +1 -1
- package/resources/v1/credit-grants.d.ts +3 -0
- package/resources/v1/credit-grants.d.ts.map +1 -1
- package/resources/v1/credit-grants.js +3 -0
- package/resources/v1/credit-grants.js.map +1 -1
- package/resources/v1/credit-grants.mjs +3 -0
- package/resources/v1/credit-grants.mjs.map +1 -1
- package/resources/v1/custom-fields.d.mts +3 -0
- package/resources/v1/custom-fields.d.mts.map +1 -1
- package/resources/v1/custom-fields.d.ts +3 -0
- package/resources/v1/custom-fields.d.ts.map +1 -1
- package/resources/v1/custom-fields.js +3 -0
- package/resources/v1/custom-fields.js.map +1 -1
- package/resources/v1/custom-fields.mjs +3 -0
- package/resources/v1/custom-fields.mjs.map +1 -1
- package/resources/v1/customers/alerts.d.mts +3 -0
- package/resources/v1/customers/alerts.d.mts.map +1 -1
- package/resources/v1/customers/alerts.d.ts +3 -0
- package/resources/v1/customers/alerts.d.ts.map +1 -1
- package/resources/v1/customers/alerts.js +3 -0
- package/resources/v1/customers/alerts.js.map +1 -1
- package/resources/v1/customers/alerts.mjs +3 -0
- package/resources/v1/customers/alerts.mjs.map +1 -1
- package/resources/v1/customers/billing-config.d.mts +3 -0
- package/resources/v1/customers/billing-config.d.mts.map +1 -1
- package/resources/v1/customers/billing-config.d.ts +3 -0
- package/resources/v1/customers/billing-config.d.ts.map +1 -1
- package/resources/v1/customers/billing-config.js +3 -0
- package/resources/v1/customers/billing-config.js.map +1 -1
- package/resources/v1/customers/billing-config.mjs +3 -0
- package/resources/v1/customers/billing-config.mjs.map +1 -1
- package/resources/v1/customers/commits.d.mts +3 -0
- package/resources/v1/customers/commits.d.mts.map +1 -1
- package/resources/v1/customers/commits.d.ts +3 -0
- package/resources/v1/customers/commits.d.ts.map +1 -1
- package/resources/v1/customers/commits.js +3 -0
- package/resources/v1/customers/commits.js.map +1 -1
- package/resources/v1/customers/commits.mjs +3 -0
- package/resources/v1/customers/commits.mjs.map +1 -1
- package/resources/v1/customers/credits.d.mts +3 -0
- package/resources/v1/customers/credits.d.mts.map +1 -1
- package/resources/v1/customers/credits.d.ts +3 -0
- package/resources/v1/customers/credits.d.ts.map +1 -1
- package/resources/v1/customers/credits.js +3 -0
- package/resources/v1/customers/credits.js.map +1 -1
- package/resources/v1/customers/credits.mjs +3 -0
- package/resources/v1/customers/credits.mjs.map +1 -1
- package/resources/v1/customers/customers.d.mts +77 -1
- package/resources/v1/customers/customers.d.mts.map +1 -1
- package/resources/v1/customers/customers.d.ts +77 -1
- package/resources/v1/customers/customers.d.ts.map +1 -1
- package/resources/v1/customers/customers.js +53 -0
- package/resources/v1/customers/customers.js.map +1 -1
- package/resources/v1/customers/customers.mjs +53 -0
- package/resources/v1/customers/customers.mjs.map +1 -1
- package/resources/v1/customers/index.d.mts +1 -1
- package/resources/v1/customers/index.d.mts.map +1 -1
- package/resources/v1/customers/index.d.ts +1 -1
- package/resources/v1/customers/index.d.ts.map +1 -1
- package/resources/v1/customers/index.js.map +1 -1
- package/resources/v1/customers/index.mjs.map +1 -1
- package/resources/v1/customers/invoices.d.mts +20 -12
- package/resources/v1/customers/invoices.d.mts.map +1 -1
- package/resources/v1/customers/invoices.d.ts +20 -12
- package/resources/v1/customers/invoices.d.ts.map +1 -1
- package/resources/v1/customers/invoices.js +3 -0
- package/resources/v1/customers/invoices.js.map +1 -1
- package/resources/v1/customers/invoices.mjs +3 -0
- package/resources/v1/customers/invoices.mjs.map +1 -1
- package/resources/v1/customers/named-schedules.d.mts +3 -0
- package/resources/v1/customers/named-schedules.d.mts.map +1 -1
- package/resources/v1/customers/named-schedules.d.ts +3 -0
- package/resources/v1/customers/named-schedules.d.ts.map +1 -1
- package/resources/v1/customers/named-schedules.js +3 -0
- package/resources/v1/customers/named-schedules.js.map +1 -1
- package/resources/v1/customers/named-schedules.mjs +3 -0
- package/resources/v1/customers/named-schedules.mjs.map +1 -1
- package/resources/v1/customers/plans.d.mts +3 -0
- package/resources/v1/customers/plans.d.mts.map +1 -1
- package/resources/v1/customers/plans.d.ts +3 -0
- package/resources/v1/customers/plans.d.ts.map +1 -1
- package/resources/v1/customers/plans.js +3 -0
- package/resources/v1/customers/plans.js.map +1 -1
- package/resources/v1/customers/plans.mjs +3 -0
- package/resources/v1/customers/plans.mjs.map +1 -1
- package/resources/v1/dashboards.d.mts +3 -0
- package/resources/v1/dashboards.d.mts.map +1 -1
- package/resources/v1/dashboards.d.ts +3 -0
- package/resources/v1/dashboards.d.ts.map +1 -1
- package/resources/v1/dashboards.js +3 -0
- package/resources/v1/dashboards.js.map +1 -1
- package/resources/v1/dashboards.mjs +3 -0
- package/resources/v1/dashboards.mjs.map +1 -1
- package/resources/v1/index.d.mts +3 -2
- package/resources/v1/index.d.mts.map +1 -1
- package/resources/v1/index.d.ts +3 -2
- package/resources/v1/index.d.ts.map +1 -1
- package/resources/v1/index.js +3 -1
- package/resources/v1/index.js.map +1 -1
- package/resources/v1/index.mjs +1 -0
- package/resources/v1/index.mjs.map +1 -1
- package/resources/v1/invoices.d.mts +3 -0
- package/resources/v1/invoices.d.mts.map +1 -1
- package/resources/v1/invoices.d.ts +3 -0
- package/resources/v1/invoices.d.ts.map +1 -1
- package/resources/v1/invoices.js +3 -0
- package/resources/v1/invoices.js.map +1 -1
- package/resources/v1/invoices.mjs +3 -0
- package/resources/v1/invoices.mjs.map +1 -1
- package/resources/v1/packages.d.mts +2353 -0
- package/resources/v1/packages.d.mts.map +1 -0
- package/resources/v1/packages.d.ts +2353 -0
- package/resources/v1/packages.d.ts.map +1 -0
- package/resources/v1/packages.js +160 -0
- package/resources/v1/packages.js.map +1 -0
- package/resources/v1/packages.mjs +156 -0
- package/resources/v1/packages.mjs.map +1 -0
- package/resources/v1/plans.d.mts +3 -0
- package/resources/v1/plans.d.mts.map +1 -1
- package/resources/v1/plans.d.ts +3 -0
- package/resources/v1/plans.d.ts.map +1 -1
- package/resources/v1/plans.js +3 -0
- package/resources/v1/plans.js.map +1 -1
- package/resources/v1/plans.mjs +3 -0
- package/resources/v1/plans.mjs.map +1 -1
- package/resources/v1/pricing-units.d.mts +3 -0
- package/resources/v1/pricing-units.d.mts.map +1 -1
- package/resources/v1/pricing-units.d.ts +3 -0
- package/resources/v1/pricing-units.d.ts.map +1 -1
- package/resources/v1/pricing-units.js +3 -0
- package/resources/v1/pricing-units.js.map +1 -1
- package/resources/v1/pricing-units.mjs +3 -0
- package/resources/v1/pricing-units.mjs.map +1 -1
- package/resources/v1/services.d.mts +3 -0
- package/resources/v1/services.d.mts.map +1 -1
- package/resources/v1/services.d.ts +3 -0
- package/resources/v1/services.d.ts.map +1 -1
- package/resources/v1/services.js +3 -0
- package/resources/v1/services.js.map +1 -1
- package/resources/v1/services.mjs +3 -0
- package/resources/v1/services.mjs.map +1 -1
- package/resources/v1/settings/billing-providers.d.mts +3 -0
- package/resources/v1/settings/billing-providers.d.mts.map +1 -1
- package/resources/v1/settings/billing-providers.d.ts +3 -0
- package/resources/v1/settings/billing-providers.d.ts.map +1 -1
- package/resources/v1/settings/billing-providers.js +3 -0
- package/resources/v1/settings/billing-providers.js.map +1 -1
- package/resources/v1/settings/billing-providers.mjs +3 -0
- package/resources/v1/settings/billing-providers.mjs.map +1 -1
- package/resources/v1/settings/settings.d.mts +3 -0
- package/resources/v1/settings/settings.d.mts.map +1 -1
- package/resources/v1/settings/settings.d.ts +3 -0
- package/resources/v1/settings/settings.d.ts.map +1 -1
- package/resources/v1/settings/settings.js +3 -0
- package/resources/v1/settings/settings.js.map +1 -1
- package/resources/v1/settings/settings.mjs +3 -0
- package/resources/v1/settings/settings.mjs.map +1 -1
- package/resources/v1/usage.d.mts +81 -12
- package/resources/v1/usage.d.mts.map +1 -1
- package/resources/v1/usage.d.ts +81 -12
- package/resources/v1/usage.d.ts.map +1 -1
- package/resources/v1/usage.js +37 -11
- package/resources/v1/usage.js.map +1 -1
- package/resources/v1/usage.mjs +37 -11
- package/resources/v1/usage.mjs.map +1 -1
- package/resources/v1/v1.d.mts +8 -4
- package/resources/v1/v1.d.mts.map +1 -1
- package/resources/v1/v1.d.ts +8 -4
- package/resources/v1/v1.d.ts.map +1 -1
- package/resources/v1/v1.js +4 -0
- package/resources/v1/v1.js.map +1 -1
- package/resources/v1/v1.mjs +4 -0
- package/resources/v1/v1.mjs.map +1 -1
- package/resources/v2/contracts.d.mts +114 -19
- package/resources/v2/contracts.d.mts.map +1 -1
- package/resources/v2/contracts.d.ts +114 -19
- package/resources/v2/contracts.d.ts.map +1 -1
- package/resources/v2/contracts.js +1 -4
- package/resources/v2/contracts.js.map +1 -1
- package/resources/v2/contracts.mjs +1 -4
- package/resources/v2/contracts.mjs.map +1 -1
- package/resources/webhooks.js +1 -1
- package/resources/webhooks.js.map +1 -1
- package/resources/webhooks.mjs +1 -1
- package/resources/webhooks.mjs.map +1 -1
- package/src/client.ts +37 -15
- package/src/internal/parse.ts +6 -0
- package/src/internal/utils/env.ts +2 -2
- package/src/internal/utils/query.ts +7 -0
- package/src/internal/utils.ts +1 -0
- package/src/resources/shared.ts +160 -31
- package/src/resources/v1/alerts.ts +3 -0
- package/src/resources/v1/audit-logs.ts +3 -0
- package/src/resources/v1/billable-metrics.ts +3 -0
- package/src/resources/v1/contracts/contracts.ts +158 -29
- package/src/resources/v1/contracts/index.ts +2 -0
- package/src/resources/v1/contracts/named-schedules.ts +3 -0
- package/src/resources/v1/contracts/products.ts +3 -0
- package/src/resources/v1/contracts/rate-cards/named-schedules.ts +3 -0
- package/src/resources/v1/contracts/rate-cards/product-orders.ts +3 -0
- package/src/resources/v1/contracts/rate-cards/rate-cards.ts +3 -0
- package/src/resources/v1/contracts/rate-cards/rates.ts +6 -3
- package/src/resources/v1/credit-grants.ts +3 -0
- package/src/resources/v1/custom-fields.ts +3 -0
- package/src/resources/v1/customers/alerts.ts +3 -0
- package/src/resources/v1/customers/billing-config.ts +3 -0
- package/src/resources/v1/customers/commits.ts +3 -0
- package/src/resources/v1/customers/credits.ts +3 -0
- package/src/resources/v1/customers/customers.ts +89 -0
- package/src/resources/v1/customers/index.ts +2 -0
- package/src/resources/v1/customers/invoices.ts +21 -12
- package/src/resources/v1/customers/named-schedules.ts +3 -0
- package/src/resources/v1/customers/plans.ts +3 -0
- package/src/resources/v1/dashboards.ts +3 -0
- package/src/resources/v1/index.ts +19 -0
- package/src/resources/v1/invoices.ts +3 -0
- package/src/resources/v1/packages.ts +3059 -0
- package/src/resources/v1/plans.ts +3 -0
- package/src/resources/v1/pricing-units.ts +3 -0
- package/src/resources/v1/services.ts +3 -0
- package/src/resources/v1/settings/billing-providers.ts +3 -0
- package/src/resources/v1/settings/settings.ts +3 -0
- package/src/resources/v1/usage.ts +80 -12
- package/src/resources/v1/v1.ts +42 -0
- package/src/resources/v2/contracts.ts +139 -21
- package/src/resources/webhooks.ts +1 -1
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -374,6 +374,83 @@ export class Contracts extends APIResource {
|
|
|
374
374
|
return this._client.post('/v1/contracts/createHistoricalInvoices', { body, ...options });
|
|
375
375
|
}
|
|
376
376
|
|
|
377
|
+
/**
|
|
378
|
+
* Retrieve the combined current balance across any grouping of credits and commits
|
|
379
|
+
* for a customer in a single API call.
|
|
380
|
+
*
|
|
381
|
+
* - Display real-time available balance to customers in billing dashboards
|
|
382
|
+
* - Build finance dashboards showing credit utilization across customer segments
|
|
383
|
+
* - Validate expected vs. actual balance during billing reconciliation
|
|
384
|
+
*
|
|
385
|
+
* ### Key response fields:
|
|
386
|
+
*
|
|
387
|
+
* - `balance`: The combined net balance available to use at this moment across all
|
|
388
|
+
* matching commits and credits
|
|
389
|
+
* - `credit_type_id`: The credit type (fiat or custom pricing unit) the balance is
|
|
390
|
+
* denominated in
|
|
391
|
+
*
|
|
392
|
+
* ### Filtering options:
|
|
393
|
+
*
|
|
394
|
+
* Balance filters allow you to scope the calculation to specific subsets of
|
|
395
|
+
* commits and credits. When using multiple filter objects, they are OR'd together
|
|
396
|
+
* — if a commit or credit matches any filter, it's included in the net balance.
|
|
397
|
+
* Within a single filter object, all specified conditions are AND'd together.
|
|
398
|
+
*
|
|
399
|
+
* - **Balance types**: Include any combination of `PREPAID_COMMIT`,
|
|
400
|
+
* `POSTPAID_COMMIT`, and `CREDIT` (e.g., `["PREPAID_COMMIT", "CREDIT"]` to
|
|
401
|
+
* exclude postpaid commits). If not specified, all balance types are included.
|
|
402
|
+
* - **Specific IDs**: Target exact commit or credit IDs for precise balance
|
|
403
|
+
* queries
|
|
404
|
+
* - **Custom fields**: Filter by custom field key-value pairs; when multiple pairs
|
|
405
|
+
* are provided, commits must match all of them
|
|
406
|
+
*
|
|
407
|
+
* **Example**: To get the balance of all free-trial credits OR all
|
|
408
|
+
* signup-promotion commits, you'd pass two filter objects — one filtering for
|
|
409
|
+
* CREDIT with custom field campaign: free-trial, and another filtering for
|
|
410
|
+
* PREPAID_COMMIT with custom field campaign: signup-promotion.
|
|
411
|
+
*
|
|
412
|
+
* ### Usage guidelines:
|
|
413
|
+
*
|
|
414
|
+
* - **Balance ledger details**: Use the
|
|
415
|
+
* [listBalances](https://docs.metronome.com/api-reference/credits-and-commits/list-balances)
|
|
416
|
+
* endpoint instead to understand detailed ledger drawdowns for each individual
|
|
417
|
+
* balance
|
|
418
|
+
* - **Draft invoice handling**: Use `invoice_inclusion_mode` to control whether
|
|
419
|
+
* pending draft invoice deductions are included (`FINALIZED_AND_DRAFT`, the
|
|
420
|
+
* default) or excluded (`FINALIZED`) from the balance calculation
|
|
421
|
+
* - **Account hierarchies**: When querying a child customer, shared commits from
|
|
422
|
+
* parent contracts are not included — query the parent customer directly to see
|
|
423
|
+
* shared commit balances
|
|
424
|
+
* - **Negative balances**: Manual ledger entries can cause negative segment
|
|
425
|
+
* balances; these are treated as zero when calculating the net balance
|
|
426
|
+
* - **Credit types**: If `credit_type_id` is not specified, the balance defaults
|
|
427
|
+
* to USD (cents)
|
|
428
|
+
*
|
|
429
|
+
* @example
|
|
430
|
+
* ```ts
|
|
431
|
+
* const response = await client.v1.contracts.getNetBalance({
|
|
432
|
+
* customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',
|
|
433
|
+
* credit_type_id: '2714e483-4ff1-48e4-9e25-ac732e8f24f2',
|
|
434
|
+
* filters: [
|
|
435
|
+
* {
|
|
436
|
+
* balance_types: ['CREDIT'],
|
|
437
|
+
* custom_fields: { campaign: 'free-trial' },
|
|
438
|
+
* },
|
|
439
|
+
* {
|
|
440
|
+
* balance_types: ['PREPAID_COMMIT', 'POSTPAID_COMMIT'],
|
|
441
|
+
* custom_fields: { campaign: 'signup-promotion' },
|
|
442
|
+
* },
|
|
443
|
+
* ],
|
|
444
|
+
* });
|
|
445
|
+
* ```
|
|
446
|
+
*/
|
|
447
|
+
getNetBalance(
|
|
448
|
+
body: ContractGetNetBalanceParams,
|
|
449
|
+
options?: RequestOptions,
|
|
450
|
+
): APIPromise<ContractGetNetBalanceResponse> {
|
|
451
|
+
return this._client.post('/v1/contracts/customerBalances/getNetBalance', { body, ...options });
|
|
452
|
+
}
|
|
453
|
+
|
|
377
454
|
/**
|
|
378
455
|
* Retrieve a comprehensive view of all available balances (commits and credits)
|
|
379
456
|
* for a customer. This endpoint provides real-time visibility into prepaid funds,
|
|
@@ -400,6 +477,9 @@ export class Contracts extends APIResource {
|
|
|
400
477
|
*
|
|
401
478
|
* ### Usage guidelines:
|
|
402
479
|
*
|
|
480
|
+
* - Use the
|
|
481
|
+
* [getNetBalance](https://docs.metronome.com/api-reference/credits-and-commits/get-the-net-balance-of-a-customer)
|
|
482
|
+
* endpoint to retrieve a single combined current balance
|
|
403
483
|
* - Date filtering: Use `effective_before` to include only balances with access
|
|
404
484
|
* before a specific date (exclusive)
|
|
405
485
|
* - Set `include_balance=true` for calculated balance amounts on each commit or
|
|
@@ -624,6 +704,26 @@ export interface ContractCreateHistoricalInvoicesResponse {
|
|
|
624
704
|
data: Array<InvoicesAPI.Invoice>;
|
|
625
705
|
}
|
|
626
706
|
|
|
707
|
+
export interface ContractGetNetBalanceResponse {
|
|
708
|
+
data: ContractGetNetBalanceResponse.Data;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
export namespace ContractGetNetBalanceResponse {
|
|
712
|
+
export interface Data {
|
|
713
|
+
/**
|
|
714
|
+
* The combined net balance that the customer has access to use at this moment
|
|
715
|
+
* across all pertinent commits and credits.
|
|
716
|
+
*/
|
|
717
|
+
balance: number;
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* The ID of the credit type (can be fiat or a custom pricing unit) that the
|
|
721
|
+
* balance is for.
|
|
722
|
+
*/
|
|
723
|
+
credit_type_id: string;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
|
|
627
727
|
export type ContractListBalancesResponse = Shared.Commit | Shared.Credit;
|
|
628
728
|
|
|
629
729
|
export interface ContractRetrieveRateScheduleResponse {
|
|
@@ -763,12 +863,20 @@ export interface ContractCreateParams {
|
|
|
763
863
|
|
|
764
864
|
overrides?: Array<ContractCreateParams.Override>;
|
|
765
865
|
|
|
766
|
-
|
|
866
|
+
/**
|
|
867
|
+
* Selects the package linked to the specified alias as of the contract's start
|
|
868
|
+
* date. Mutually exclusive with package_id.
|
|
869
|
+
*/
|
|
870
|
+
package_alias?: string;
|
|
767
871
|
|
|
768
872
|
/**
|
|
769
|
-
*
|
|
873
|
+
* If provided, provisions a customer on a package instead of creating a
|
|
874
|
+
* traditional contract. When specified, only customer_id, starting_at, package_id,
|
|
875
|
+
* and uniqueness_key are allowed.
|
|
770
876
|
*/
|
|
771
|
-
|
|
877
|
+
package_id?: string;
|
|
878
|
+
|
|
879
|
+
prepaid_balance_threshold_configuration?: Shared.PrepaidBalanceThresholdConfiguration;
|
|
772
880
|
|
|
773
881
|
/**
|
|
774
882
|
* This field's availability is dependent on your client's configuration.
|
|
@@ -1124,7 +1232,7 @@ export namespace ContractCreateParams {
|
|
|
1124
1232
|
* not wish Metronome to calculate tax on your behalf. Leaving this field blank
|
|
1125
1233
|
* will default to NONE.
|
|
1126
1234
|
*/
|
|
1127
|
-
tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | '
|
|
1235
|
+
tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED';
|
|
1128
1236
|
}
|
|
1129
1237
|
|
|
1130
1238
|
export namespace PaymentGateConfig {
|
|
@@ -1228,6 +1336,11 @@ export namespace ContractCreateParams {
|
|
|
1228
1336
|
|
|
1229
1337
|
rate_type?: 'COMMIT_RATE' | 'LIST_RATE';
|
|
1230
1338
|
|
|
1339
|
+
/**
|
|
1340
|
+
* Fraction of unused segments that will be rolled over. Must be between 0 and 1.
|
|
1341
|
+
*/
|
|
1342
|
+
rollover_fraction?: number;
|
|
1343
|
+
|
|
1231
1344
|
/**
|
|
1232
1345
|
* List of filters that determine what kind of customer usage draws down a commit
|
|
1233
1346
|
* or credit. A customer's usage needs to meet the condition of at least one of the
|
|
@@ -1399,8 +1512,7 @@ export namespace ContractCreateParams {
|
|
|
1399
1512
|
parent_behavior?: HierarchyConfiguration.ParentBehavior;
|
|
1400
1513
|
|
|
1401
1514
|
/**
|
|
1402
|
-
*
|
|
1403
|
-
* invoice charges
|
|
1515
|
+
* Indicates which customer should pay for the child's invoice charges
|
|
1404
1516
|
*
|
|
1405
1517
|
* **SELF**: The child pays for its own invoice charges
|
|
1406
1518
|
*
|
|
@@ -1409,8 +1521,8 @@ export namespace ContractCreateParams {
|
|
|
1409
1521
|
payer?: 'SELF' | 'PARENT';
|
|
1410
1522
|
|
|
1411
1523
|
/**
|
|
1412
|
-
*
|
|
1413
|
-
*
|
|
1524
|
+
* Indicates the behavior of the child's invoice statements on the parent's
|
|
1525
|
+
* invoices.
|
|
1414
1526
|
*
|
|
1415
1527
|
* **CONSOLIDATE**: Child's invoice statements will be added to parent's
|
|
1416
1528
|
* consolidated invoices
|
|
@@ -1430,8 +1542,8 @@ export namespace ContractCreateParams {
|
|
|
1430
1542
|
|
|
1431
1543
|
export interface ParentBehavior {
|
|
1432
1544
|
/**
|
|
1433
|
-
*
|
|
1434
|
-
*
|
|
1545
|
+
* Indicates the desired behavior of consolidated invoices generated by the parent
|
|
1546
|
+
* in a customer hierarchy
|
|
1435
1547
|
*
|
|
1436
1548
|
* **CONCATENATE**: Statements on the invoices of child customers will be appended
|
|
1437
1549
|
* to the consolidated invoice
|
|
@@ -1559,21 +1671,13 @@ export namespace ContractCreateParams {
|
|
|
1559
1671
|
* commits created by the specified recurring commit ids.
|
|
1560
1672
|
*/
|
|
1561
1673
|
recurring_commit_ids?: Array<string>;
|
|
1562
|
-
|
|
1563
|
-
/**
|
|
1564
|
-
* Can only be used for commit specific overrides. Must be used in conjunction with
|
|
1565
|
-
* one of `product_id`, `product_tags`, `pricing_group_values`, or
|
|
1566
|
-
* `presentation_group_values`. If provided, the override will only apply to
|
|
1567
|
-
* credits created by the specified recurring credit ids.
|
|
1568
|
-
*/
|
|
1569
|
-
recurring_credit_ids?: Array<string>;
|
|
1570
1674
|
}
|
|
1571
1675
|
|
|
1572
1676
|
/**
|
|
1573
1677
|
* Required for OVERWRITE type.
|
|
1574
1678
|
*/
|
|
1575
1679
|
export interface OverwriteRate {
|
|
1576
|
-
rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'CUSTOM';
|
|
1680
|
+
rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM';
|
|
1577
1681
|
|
|
1578
1682
|
credit_type_id?: string;
|
|
1579
1683
|
|
|
@@ -2754,7 +2858,7 @@ export namespace ContractAmendParams {
|
|
|
2754
2858
|
* not wish Metronome to calculate tax on your behalf. Leaving this field blank
|
|
2755
2859
|
* will default to NONE.
|
|
2756
2860
|
*/
|
|
2757
|
-
tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | '
|
|
2861
|
+
tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED';
|
|
2758
2862
|
}
|
|
2759
2863
|
|
|
2760
2864
|
export namespace PaymentGateConfig {
|
|
@@ -2858,6 +2962,11 @@ export namespace ContractAmendParams {
|
|
|
2858
2962
|
|
|
2859
2963
|
rate_type?: 'COMMIT_RATE' | 'LIST_RATE';
|
|
2860
2964
|
|
|
2965
|
+
/**
|
|
2966
|
+
* Fraction of unused segments that will be rolled over. Must be between 0 and 1.
|
|
2967
|
+
*/
|
|
2968
|
+
rollover_fraction?: number;
|
|
2969
|
+
|
|
2861
2970
|
/**
|
|
2862
2971
|
* List of filters that determine what kind of customer usage draws down a commit
|
|
2863
2972
|
* or credit. A customer's usage needs to meet the condition of at least one of the
|
|
@@ -3140,21 +3249,13 @@ export namespace ContractAmendParams {
|
|
|
3140
3249
|
* commits created by the specified recurring commit ids.
|
|
3141
3250
|
*/
|
|
3142
3251
|
recurring_commit_ids?: Array<string>;
|
|
3143
|
-
|
|
3144
|
-
/**
|
|
3145
|
-
* Can only be used for commit specific overrides. Must be used in conjunction with
|
|
3146
|
-
* one of `product_id`, `product_tags`, `pricing_group_values`, or
|
|
3147
|
-
* `presentation_group_values`. If provided, the override will only apply to
|
|
3148
|
-
* credits created by the specified recurring credit ids.
|
|
3149
|
-
*/
|
|
3150
|
-
recurring_credit_ids?: Array<string>;
|
|
3151
3252
|
}
|
|
3152
3253
|
|
|
3153
3254
|
/**
|
|
3154
3255
|
* Required for OVERWRITE type.
|
|
3155
3256
|
*/
|
|
3156
3257
|
export interface OverwriteRate {
|
|
3157
|
-
rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'CUSTOM';
|
|
3258
|
+
rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM';
|
|
3158
3259
|
|
|
3159
3260
|
credit_type_id?: string;
|
|
3160
3261
|
|
|
@@ -3483,6 +3584,32 @@ export namespace ContractCreateHistoricalInvoicesParams {
|
|
|
3483
3584
|
}
|
|
3484
3585
|
}
|
|
3485
3586
|
|
|
3587
|
+
export interface ContractGetNetBalanceParams {
|
|
3588
|
+
/**
|
|
3589
|
+
* The ID of the customer.
|
|
3590
|
+
*/
|
|
3591
|
+
customer_id: string;
|
|
3592
|
+
|
|
3593
|
+
/**
|
|
3594
|
+
* The ID of the credit type (can be fiat or a custom pricing unit) to get the
|
|
3595
|
+
* balance for. Defaults to USD (cents) if not specified.
|
|
3596
|
+
*/
|
|
3597
|
+
credit_type_id?: string;
|
|
3598
|
+
|
|
3599
|
+
/**
|
|
3600
|
+
* Balance filters are OR'd together, so if a given commit or credit matches any of
|
|
3601
|
+
* the filters, it will be included in the net balance.
|
|
3602
|
+
*/
|
|
3603
|
+
filters?: Array<Shared.BalanceFilter>;
|
|
3604
|
+
|
|
3605
|
+
/**
|
|
3606
|
+
* Controls which invoices are considered when calculating the remaining balance.
|
|
3607
|
+
* `FINALIZED` considers only deductions from finalized invoices.
|
|
3608
|
+
* `FINALIZED_AND_DRAFT` also includes deductions from pending draft invoices.
|
|
3609
|
+
*/
|
|
3610
|
+
invoice_inclusion_mode?: 'FINALIZED' | 'FINALIZED_AND_DRAFT';
|
|
3611
|
+
}
|
|
3612
|
+
|
|
3486
3613
|
export interface ContractListBalancesParams extends BodyCursorPageParams {
|
|
3487
3614
|
customer_id: string;
|
|
3488
3615
|
|
|
@@ -3729,6 +3856,7 @@ export declare namespace Contracts {
|
|
|
3729
3856
|
type ContractAmendResponse as ContractAmendResponse,
|
|
3730
3857
|
type ContractArchiveResponse as ContractArchiveResponse,
|
|
3731
3858
|
type ContractCreateHistoricalInvoicesResponse as ContractCreateHistoricalInvoicesResponse,
|
|
3859
|
+
type ContractGetNetBalanceResponse as ContractGetNetBalanceResponse,
|
|
3732
3860
|
type ContractListBalancesResponse as ContractListBalancesResponse,
|
|
3733
3861
|
type ContractRetrieveRateScheduleResponse as ContractRetrieveRateScheduleResponse,
|
|
3734
3862
|
type ContractRetrieveSubscriptionQuantityHistoryResponse as ContractRetrieveSubscriptionQuantityHistoryResponse,
|
|
@@ -3742,6 +3870,7 @@ export declare namespace Contracts {
|
|
|
3742
3870
|
type ContractAmendParams as ContractAmendParams,
|
|
3743
3871
|
type ContractArchiveParams as ContractArchiveParams,
|
|
3744
3872
|
type ContractCreateHistoricalInvoicesParams as ContractCreateHistoricalInvoicesParams,
|
|
3873
|
+
type ContractGetNetBalanceParams as ContractGetNetBalanceParams,
|
|
3745
3874
|
type ContractListBalancesParams as ContractListBalancesParams,
|
|
3746
3875
|
type ContractRetrieveRateScheduleParams as ContractRetrieveRateScheduleParams,
|
|
3747
3876
|
type ContractRetrieveSubscriptionQuantityHistoryParams as ContractRetrieveSubscriptionQuantityHistoryParams,
|
|
@@ -8,6 +8,7 @@ export {
|
|
|
8
8
|
type ContractAmendResponse,
|
|
9
9
|
type ContractArchiveResponse,
|
|
10
10
|
type ContractCreateHistoricalInvoicesResponse,
|
|
11
|
+
type ContractGetNetBalanceResponse,
|
|
11
12
|
type ContractListBalancesResponse,
|
|
12
13
|
type ContractRetrieveRateScheduleResponse,
|
|
13
14
|
type ContractRetrieveSubscriptionQuantityHistoryResponse,
|
|
@@ -20,6 +21,7 @@ export {
|
|
|
20
21
|
type ContractAmendParams,
|
|
21
22
|
type ContractArchiveParams,
|
|
22
23
|
type ContractCreateHistoricalInvoicesParams,
|
|
24
|
+
type ContractGetNetBalanceParams,
|
|
23
25
|
type ContractListBalancesParams,
|
|
24
26
|
type ContractRetrieveRateScheduleParams,
|
|
25
27
|
type ContractRetrieveSubscriptionQuantityHistoryParams,
|
|
@@ -5,6 +5,9 @@ import { APIPromise } from '../../../core/api-promise';
|
|
|
5
5
|
import { buildHeaders } from '../../../internal/headers';
|
|
6
6
|
import { RequestOptions } from '../../../internal/request-options';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Named schedules are used for storing custom data that can change over time. Named schedules are often used in custom pricing logic.
|
|
10
|
+
*/
|
|
8
11
|
export class NamedSchedules extends APIResource {
|
|
9
12
|
/**
|
|
10
13
|
* Get a named schedule for the given rate card. This endpoint's availability is
|
|
@@ -7,6 +7,9 @@ import { APIPromise } from '../../../core/api-promise';
|
|
|
7
7
|
import { CursorPage, type CursorPageParams, PagePromise } from '../../../core/pagination';
|
|
8
8
|
import { RequestOptions } from '../../../internal/request-options';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Products are the items that customers purchase.
|
|
12
|
+
*/
|
|
10
13
|
export class Products extends APIResource {
|
|
11
14
|
/**
|
|
12
15
|
* Create a new product object. Products in Metronome represent your company's
|
|
@@ -5,6 +5,9 @@ import { APIPromise } from '../../../../core/api-promise';
|
|
|
5
5
|
import { buildHeaders } from '../../../../internal/headers';
|
|
6
6
|
import { RequestOptions } from '../../../../internal/request-options';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Named schedules are used for storing custom data that can change over time. Named schedules are often used in custom pricing logic.
|
|
10
|
+
*/
|
|
8
11
|
export class NamedSchedules extends APIResource {
|
|
9
12
|
/**
|
|
10
13
|
* Get a named schedule for the given contract. This endpoint's availability is
|
|
@@ -5,6 +5,9 @@ import * as Shared from '../../../shared';
|
|
|
5
5
|
import { APIPromise } from '../../../../core/api-promise';
|
|
6
6
|
import { RequestOptions } from '../../../../internal/request-options';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Rate cards are used to define default pricing for products.
|
|
10
|
+
*/
|
|
8
11
|
export class ProductOrders extends APIResource {
|
|
9
12
|
/**
|
|
10
13
|
* The ordering of products on a rate card determines the order in which the
|
|
@@ -32,6 +32,9 @@ import { APIPromise } from '../../../../core/api-promise';
|
|
|
32
32
|
import { CursorPage, type CursorPageParams, PagePromise } from '../../../../core/pagination';
|
|
33
33
|
import { RequestOptions } from '../../../../internal/request-options';
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Rate cards are used to define default pricing for products.
|
|
37
|
+
*/
|
|
35
38
|
export class RateCards extends APIResource {
|
|
36
39
|
productOrders: ProductOrdersAPI.ProductOrders = new ProductOrdersAPI.ProductOrders(this._client);
|
|
37
40
|
rates: RatesAPI.Rates = new RatesAPI.Rates(this._client);
|
|
@@ -6,6 +6,9 @@ import { APIPromise } from '../../../../core/api-promise';
|
|
|
6
6
|
import { CursorPage, type CursorPageParams, PagePromise } from '../../../../core/pagination';
|
|
7
7
|
import { RequestOptions } from '../../../../internal/request-options';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Rate cards are used to define default pricing for products.
|
|
11
|
+
*/
|
|
9
12
|
export class Rates extends APIResource {
|
|
10
13
|
/**
|
|
11
14
|
* Understand the rate schedule at a given timestamp, optionally filtering the list
|
|
@@ -153,7 +156,7 @@ export interface RateAddResponse {
|
|
|
153
156
|
|
|
154
157
|
export namespace RateAddResponse {
|
|
155
158
|
export interface Data {
|
|
156
|
-
rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'CUSTOM' | 'TIERED';
|
|
159
|
+
rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'CUSTOM' | 'TIERED' | 'TIERED_PERCENTAGE';
|
|
157
160
|
|
|
158
161
|
/**
|
|
159
162
|
* A distinct rate on the rate card. You can choose to use this rate rather than
|
|
@@ -271,7 +274,7 @@ export interface RateAddParams {
|
|
|
271
274
|
*/
|
|
272
275
|
rate_card_id: string;
|
|
273
276
|
|
|
274
|
-
rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'CUSTOM';
|
|
277
|
+
rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM';
|
|
275
278
|
|
|
276
279
|
/**
|
|
277
280
|
* inclusive effective date
|
|
@@ -353,7 +356,7 @@ export namespace RateAddManyParams {
|
|
|
353
356
|
*/
|
|
354
357
|
product_id: string;
|
|
355
358
|
|
|
356
|
-
rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'CUSTOM';
|
|
359
|
+
rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM';
|
|
357
360
|
|
|
358
361
|
/**
|
|
359
362
|
* inclusive effective date
|
|
@@ -13,6 +13,9 @@ import {
|
|
|
13
13
|
} from '../../core/pagination';
|
|
14
14
|
import { RequestOptions } from '../../internal/request-options';
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* [Credit grants](https://docs.metronome.com/invoicing/how-billing-works/manage-credits/) adjust a customer balance for prepayments, reimbursements, promotions, and so on. Use these endpoints to create, retrieve, update, and delete credit grants.
|
|
18
|
+
*/
|
|
16
19
|
export class CreditGrants extends APIResource {
|
|
17
20
|
/**
|
|
18
21
|
* Create a new credit grant. This is a Plans (deprecated) endpoint. New clients
|
|
@@ -10,6 +10,9 @@ import {
|
|
|
10
10
|
import { buildHeaders } from '../../internal/headers';
|
|
11
11
|
import { RequestOptions } from '../../internal/request-options';
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* [Custom fields](https://docs.metronome.com/integrations/custom-fields/) enable adding additional data to Metronome entities. Use these endpoints to create, retrieve, update, and delete custom fields.
|
|
15
|
+
*/
|
|
13
16
|
export class CustomFields extends APIResource {
|
|
14
17
|
/**
|
|
15
18
|
* Creates a new custom field key for a given entity (e.g. billable metric,
|
|
@@ -11,6 +11,9 @@ import {
|
|
|
11
11
|
import { buildHeaders } from '../../../internal/headers';
|
|
12
12
|
import { RequestOptions } from '../../../internal/request-options';
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* [Alerts](https://docs.metronome.com/connecting-metronome/alerts/) monitor customer spending, balances, and other billing factors. Use these endpoints to create, retrieve, and archive customer alerts. To view sample alert payloads by alert type, navigate [here.](https://docs.metronome.com/manage-product-access/create-manage-alerts/#webhook-notifications)
|
|
16
|
+
*/
|
|
14
17
|
export class Alerts extends APIResource {
|
|
15
18
|
/**
|
|
16
19
|
* Retrieve the real-time evaluation status for a specific threshold
|
|
@@ -6,6 +6,9 @@ import { buildHeaders } from '../../../internal/headers';
|
|
|
6
6
|
import { RequestOptions } from '../../../internal/request-options';
|
|
7
7
|
import { path } from '../../../internal/utils/path';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* [Customers](https://docs.metronome.com/provisioning/create-customers/) in Metronome represent your users for all billing and reporting. Use these endpoints to create, retrieve, update, and archive customers and their billing configuration.
|
|
11
|
+
*/
|
|
9
12
|
export class BillingConfig extends APIResource {
|
|
10
13
|
/**
|
|
11
14
|
* Set the billing configuration for a given customer. This is a Plans (deprecated)
|
|
@@ -7,6 +7,9 @@ import { APIPromise } from '../../../core/api-promise';
|
|
|
7
7
|
import { BodyCursorPage, type BodyCursorPageParams, PagePromise } from '../../../core/pagination';
|
|
8
8
|
import { RequestOptions } from '../../../internal/request-options';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Credits and commits are used to manage customer balances.
|
|
12
|
+
*/
|
|
10
13
|
export class Commits extends APIResource {
|
|
11
14
|
/**
|
|
12
15
|
* Creates customer-level commits that establish spending commitments for customers
|
|
@@ -7,6 +7,9 @@ import { APIPromise } from '../../../core/api-promise';
|
|
|
7
7
|
import { BodyCursorPage, type BodyCursorPageParams, PagePromise } from '../../../core/pagination';
|
|
8
8
|
import { RequestOptions } from '../../../internal/request-options';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Credits and commits are used to manage customer balances.
|
|
12
|
+
*/
|
|
10
13
|
export class Credits extends APIResource {
|
|
11
14
|
/**
|
|
12
15
|
* Creates customer-level credits that provide spending allowances or free credit
|
|
@@ -217,6 +217,57 @@ export class Customers extends APIResource {
|
|
|
217
217
|
return this._client.post('/v1/customers/archive', { body, ...options });
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
+
/**
|
|
221
|
+
* Deprecate an existing billing configuration for a customer to handle churn or
|
|
222
|
+
* billing and collection preference changes. Archiving a billing configuration
|
|
223
|
+
* takes effect immediately. If there are active contracts using the configuration,
|
|
224
|
+
* Metronome will archive the configuration on the contract and immediately stop
|
|
225
|
+
* metering to downstream systems.
|
|
226
|
+
*
|
|
227
|
+
* ### Use this endpoint to:
|
|
228
|
+
*
|
|
229
|
+
* - Remove billing provider customer data and configurations when no longer needed
|
|
230
|
+
* - Clean up test or deprecated billing provider configurations
|
|
231
|
+
* - Free up uniqueness keys for reuse with new billing provider configurations
|
|
232
|
+
* - Disable threshold recharge configurations associated with archived billing
|
|
233
|
+
* providers
|
|
234
|
+
*
|
|
235
|
+
* ### Key response fields:
|
|
236
|
+
*
|
|
237
|
+
* A successful response returns:
|
|
238
|
+
*
|
|
239
|
+
* - `success`: Boolean indicating the operation completed successfully
|
|
240
|
+
* - `error`: Null on success, error message on failure
|
|
241
|
+
*
|
|
242
|
+
* ### Usage guidelines:
|
|
243
|
+
*
|
|
244
|
+
* - Archiving a contract configuration during a grace period will result in the
|
|
245
|
+
* invoice not being sent to the customer
|
|
246
|
+
* - Automatically disables both spend-based and credit-based threshold recharge
|
|
247
|
+
* configurations for contracts using the archived billing provider
|
|
248
|
+
* - You can archive multiple configurations for a single customer in a single
|
|
249
|
+
* request, but any validation failures for an individual configuration will
|
|
250
|
+
* prevent the entire operation from succeeding
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```ts
|
|
254
|
+
* const response =
|
|
255
|
+
* await client.v1.customers.archiveBillingConfigurations({
|
|
256
|
+
* customer_billing_provider_configuration_ids: [
|
|
257
|
+
* '4db51251-61de-4bfe-b9ce-495e244f3491',
|
|
258
|
+
* '4db51251-61de-4bfe-b9ce-495e244f3491',
|
|
259
|
+
* ],
|
|
260
|
+
* customer_id: '20a060d1-aa80-41d4-8bb2-4f3091b93903',
|
|
261
|
+
* });
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
archiveBillingConfigurations(
|
|
265
|
+
body: CustomerArchiveBillingConfigurationsParams,
|
|
266
|
+
options?: RequestOptions,
|
|
267
|
+
): APIPromise<CustomerArchiveBillingConfigurationsResponse> {
|
|
268
|
+
return this._client.post('/v1/archiveCustomerBillingProviderConfigurations', { body, ...options });
|
|
269
|
+
}
|
|
270
|
+
|
|
220
271
|
/**
|
|
221
272
|
* Get all billable metrics available for a specific customer. Supports pagination
|
|
222
273
|
* and filtering by current plan status or archived metrics. Use this endpoint to
|
|
@@ -404,6 +455,12 @@ export class Customers extends APIResource {
|
|
|
404
455
|
* configuration: { ... },
|
|
405
456
|
* delivery_method: 'direct_to_billing_provider',
|
|
406
457
|
* },
|
|
458
|
+
* {
|
|
459
|
+
* customer_id: '4db51251-61de-4bfe-b9ce-495e244f3491',
|
|
460
|
+
* billing_provider: 'netsuite',
|
|
461
|
+
* configuration: { ... },
|
|
462
|
+
* delivery_method: 'direct_to_billing_provider',
|
|
463
|
+
* },
|
|
407
464
|
* ],
|
|
408
465
|
* });
|
|
409
466
|
* ```
|
|
@@ -602,6 +659,24 @@ export interface CustomerArchiveResponse {
|
|
|
602
659
|
data: Shared.ID;
|
|
603
660
|
}
|
|
604
661
|
|
|
662
|
+
export interface CustomerArchiveBillingConfigurationsResponse {
|
|
663
|
+
data: CustomerArchiveBillingConfigurationsResponse.Data;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
export namespace CustomerArchiveBillingConfigurationsResponse {
|
|
667
|
+
export interface Data {
|
|
668
|
+
/**
|
|
669
|
+
* Array of billing provider configuration IDs to archive
|
|
670
|
+
*/
|
|
671
|
+
customer_billing_provider_configuration_ids: Array<string>;
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* The customer ID the billing provider configurations belong to
|
|
675
|
+
*/
|
|
676
|
+
customer_id: string;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
|
|
605
680
|
export interface CustomerListBillableMetricsResponse {
|
|
606
681
|
id: string;
|
|
607
682
|
|
|
@@ -1001,6 +1076,18 @@ export interface CustomerArchiveParams {
|
|
|
1001
1076
|
id: string;
|
|
1002
1077
|
}
|
|
1003
1078
|
|
|
1079
|
+
export interface CustomerArchiveBillingConfigurationsParams {
|
|
1080
|
+
/**
|
|
1081
|
+
* Array of billing provider configuration IDs to archive
|
|
1082
|
+
*/
|
|
1083
|
+
customer_billing_provider_configuration_ids: Array<string>;
|
|
1084
|
+
|
|
1085
|
+
/**
|
|
1086
|
+
* The customer ID the billing provider configurations belong to
|
|
1087
|
+
*/
|
|
1088
|
+
customer_id: string;
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1004
1091
|
export interface CustomerListBillableMetricsParams extends CursorPageParams {
|
|
1005
1092
|
/**
|
|
1006
1093
|
* Path param
|
|
@@ -1202,6 +1289,7 @@ export declare namespace Customers {
|
|
|
1202
1289
|
type CustomerCreateResponse as CustomerCreateResponse,
|
|
1203
1290
|
type CustomerRetrieveResponse as CustomerRetrieveResponse,
|
|
1204
1291
|
type CustomerArchiveResponse as CustomerArchiveResponse,
|
|
1292
|
+
type CustomerArchiveBillingConfigurationsResponse as CustomerArchiveBillingConfigurationsResponse,
|
|
1205
1293
|
type CustomerListBillableMetricsResponse as CustomerListBillableMetricsResponse,
|
|
1206
1294
|
type CustomerListCostsResponse as CustomerListCostsResponse,
|
|
1207
1295
|
type CustomerPreviewEventsResponse as CustomerPreviewEventsResponse,
|
|
@@ -1215,6 +1303,7 @@ export declare namespace Customers {
|
|
|
1215
1303
|
type CustomerRetrieveParams as CustomerRetrieveParams,
|
|
1216
1304
|
type CustomerListParams as CustomerListParams,
|
|
1217
1305
|
type CustomerArchiveParams as CustomerArchiveParams,
|
|
1306
|
+
type CustomerArchiveBillingConfigurationsParams as CustomerArchiveBillingConfigurationsParams,
|
|
1218
1307
|
type CustomerListBillableMetricsParams as CustomerListBillableMetricsParams,
|
|
1219
1308
|
type CustomerListCostsParams as CustomerListCostsParams,
|
|
1220
1309
|
type CustomerPreviewEventsParams as CustomerPreviewEventsParams,
|
|
@@ -39,6 +39,7 @@ export {
|
|
|
39
39
|
type CustomerCreateResponse,
|
|
40
40
|
type CustomerRetrieveResponse,
|
|
41
41
|
type CustomerArchiveResponse,
|
|
42
|
+
type CustomerArchiveBillingConfigurationsResponse,
|
|
42
43
|
type CustomerListBillableMetricsResponse,
|
|
43
44
|
type CustomerListCostsResponse,
|
|
44
45
|
type CustomerPreviewEventsResponse,
|
|
@@ -49,6 +50,7 @@ export {
|
|
|
49
50
|
type CustomerRetrieveParams,
|
|
50
51
|
type CustomerListParams,
|
|
51
52
|
type CustomerArchiveParams,
|
|
53
|
+
type CustomerArchiveBillingConfigurationsParams,
|
|
52
54
|
type CustomerListBillableMetricsParams,
|
|
53
55
|
type CustomerListCostsParams,
|
|
54
56
|
type CustomerPreviewEventsParams,
|