@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
package/src/client.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type { APIResponseProps } from './internal/parse';
|
|
|
11
11
|
import { getPlatformHeaders } from './internal/detect-platform';
|
|
12
12
|
import * as Shims from './internal/shims';
|
|
13
13
|
import * as Opts from './internal/request-options';
|
|
14
|
-
import
|
|
14
|
+
import { stringifyQuery } from './internal/utils/query';
|
|
15
15
|
import { VERSION } from './version';
|
|
16
16
|
import * as Errors from './core/error';
|
|
17
17
|
import * as Pagination from './core/pagination';
|
|
@@ -233,8 +233,8 @@ export class Metronome {
|
|
|
233
233
|
return buildHeaders([{ Authorization: `Bearer ${this.bearerToken}` }]);
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
-
protected stringifyQuery(query: Record<string, unknown>): string {
|
|
237
|
-
return
|
|
236
|
+
protected stringifyQuery(query: object | Record<string, unknown>): string {
|
|
237
|
+
return stringifyQuery(query);
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
private getUserAgent(): string {
|
|
@@ -266,12 +266,13 @@ export class Metronome {
|
|
|
266
266
|
: new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
|
|
267
267
|
|
|
268
268
|
const defaultQuery = this.defaultQuery();
|
|
269
|
-
|
|
270
|
-
|
|
269
|
+
const pathQuery = Object.fromEntries(url.searchParams);
|
|
270
|
+
if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
|
|
271
|
+
query = { ...pathQuery, ...defaultQuery, ...query };
|
|
271
272
|
}
|
|
272
273
|
|
|
273
274
|
if (typeof query === 'object' && query && !Array.isArray(query)) {
|
|
274
|
-
url.search = this.stringifyQuery(query
|
|
275
|
+
url.search = this.stringifyQuery(query);
|
|
275
276
|
}
|
|
276
277
|
|
|
277
278
|
return url.toString();
|
|
@@ -455,7 +456,7 @@ export class Metronome {
|
|
|
455
456
|
loggerFor(this).info(`${responseInfo} - ${retryMessage}`);
|
|
456
457
|
|
|
457
458
|
const errText = await response.text().catch((err: any) => castToError(err).message);
|
|
458
|
-
const errJSON = safeJSON(errText);
|
|
459
|
+
const errJSON = safeJSON(errText) as any;
|
|
459
460
|
const errMessage = errJSON ? undefined : errText;
|
|
460
461
|
|
|
461
462
|
loggerFor(this).debug(
|
|
@@ -492,9 +493,14 @@ export class Metronome {
|
|
|
492
493
|
getAPIList<Item, PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>>(
|
|
493
494
|
path: string,
|
|
494
495
|
Page: new (...args: any[]) => PageClass,
|
|
495
|
-
opts?: RequestOptions
|
|
496
|
+
opts?: PromiseOrValue<RequestOptions>,
|
|
496
497
|
): Pagination.PagePromise<PageClass, Item> {
|
|
497
|
-
return this.requestAPIList(
|
|
498
|
+
return this.requestAPIList(
|
|
499
|
+
Page,
|
|
500
|
+
opts && 'then' in opts ?
|
|
501
|
+
opts.then((opts) => ({ method: 'get', path, ...opts }))
|
|
502
|
+
: { method: 'get', path, ...opts },
|
|
503
|
+
);
|
|
498
504
|
}
|
|
499
505
|
|
|
500
506
|
requestAPIList<
|
|
@@ -502,7 +508,7 @@ export class Metronome {
|
|
|
502
508
|
PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>,
|
|
503
509
|
>(
|
|
504
510
|
Page: new (...args: ConstructorParameters<typeof Pagination.AbstractPage>) => PageClass,
|
|
505
|
-
options: FinalRequestOptions
|
|
511
|
+
options: PromiseOrValue<FinalRequestOptions>,
|
|
506
512
|
): Pagination.PagePromise<PageClass, Item> {
|
|
507
513
|
const request = this.makeRequest(options, null, undefined);
|
|
508
514
|
return new Pagination.PagePromise<PageClass, Item>(this as any as Metronome, request, Page);
|
|
@@ -515,9 +521,10 @@ export class Metronome {
|
|
|
515
521
|
controller: AbortController,
|
|
516
522
|
): Promise<Response> {
|
|
517
523
|
const { signal, method, ...options } = init || {};
|
|
518
|
-
|
|
524
|
+
const abort = this._makeAbort(controller);
|
|
525
|
+
if (signal) signal.addEventListener('abort', abort, { once: true });
|
|
519
526
|
|
|
520
|
-
const timeout = setTimeout(
|
|
527
|
+
const timeout = setTimeout(abort, ms);
|
|
521
528
|
|
|
522
529
|
const isReadableBody =
|
|
523
530
|
((globalThis as any).ReadableStream && options.body instanceof (globalThis as any).ReadableStream) ||
|
|
@@ -594,9 +601,9 @@ export class Metronome {
|
|
|
594
601
|
}
|
|
595
602
|
}
|
|
596
603
|
|
|
597
|
-
// If the API asks us to wait a certain amount of time
|
|
598
|
-
//
|
|
599
|
-
if (
|
|
604
|
+
// If the API asks us to wait a certain amount of time, just do what it
|
|
605
|
+
// says, but otherwise calculate a default
|
|
606
|
+
if (timeoutMillis === undefined) {
|
|
600
607
|
const maxRetries = options.maxRetries ?? this.maxRetries;
|
|
601
608
|
timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
|
|
602
609
|
}
|
|
@@ -684,6 +691,12 @@ export class Metronome {
|
|
|
684
691
|
return headers.values;
|
|
685
692
|
}
|
|
686
693
|
|
|
694
|
+
private _makeAbort(controller: AbortController) {
|
|
695
|
+
// note: we can't just inline this method inside `fetchWithTimeout()` because then the closure
|
|
696
|
+
// would capture all request options, and cause a memory leak.
|
|
697
|
+
return () => controller.abort();
|
|
698
|
+
}
|
|
699
|
+
|
|
687
700
|
private buildBody({ options: { body, headers: rawHeaders } }: { options: FinalRequestOptions }): {
|
|
688
701
|
bodyHeaders: HeadersLike;
|
|
689
702
|
body: BodyInit | undefined;
|
|
@@ -716,6 +729,14 @@ export class Metronome {
|
|
|
716
729
|
(Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))
|
|
717
730
|
) {
|
|
718
731
|
return { bodyHeaders: undefined, body: Shims.ReadableStreamFrom(body as AsyncIterable<Uint8Array>) };
|
|
732
|
+
} else if (
|
|
733
|
+
typeof body === 'object' &&
|
|
734
|
+
headers.values.get('content-type') === 'application/x-www-form-urlencoded'
|
|
735
|
+
) {
|
|
736
|
+
return {
|
|
737
|
+
bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
738
|
+
body: this.stringifyQuery(body),
|
|
739
|
+
};
|
|
719
740
|
} else {
|
|
720
741
|
return this.#encoder({ body, headers });
|
|
721
742
|
}
|
|
@@ -771,6 +792,7 @@ export declare namespace Metronome {
|
|
|
771
792
|
|
|
772
793
|
export { V1 as V1 };
|
|
773
794
|
|
|
795
|
+
export type BalanceFilter = API.BalanceFilter;
|
|
774
796
|
export type BaseThresholdCommit = API.BaseThresholdCommit;
|
|
775
797
|
export type BaseUsageFilter = API.BaseUsageFilter;
|
|
776
798
|
export type Commit = API.Commit;
|
package/src/internal/parse.ts
CHANGED
|
@@ -29,6 +29,12 @@ export async function defaultParseResponse<T>(client: Metronome, props: APIRespo
|
|
|
29
29
|
const mediaType = contentType?.split(';')[0]?.trim();
|
|
30
30
|
const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
|
|
31
31
|
if (isJSON) {
|
|
32
|
+
const contentLength = response.headers.get('content-length');
|
|
33
|
+
if (contentLength === '0') {
|
|
34
|
+
// if there is no content we can't do anything
|
|
35
|
+
return undefined as T;
|
|
36
|
+
}
|
|
37
|
+
|
|
32
38
|
const json = await response.json();
|
|
33
39
|
return json as T;
|
|
34
40
|
}
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export const readEnv = (env: string): string | undefined => {
|
|
11
11
|
if (typeof (globalThis as any).process !== 'undefined') {
|
|
12
|
-
return (globalThis as any).process.env?.[env]?.trim()
|
|
12
|
+
return (globalThis as any).process.env?.[env]?.trim() || undefined;
|
|
13
13
|
}
|
|
14
14
|
if (typeof (globalThis as any).Deno !== 'undefined') {
|
|
15
|
-
return (globalThis as any).Deno.env?.get?.(env)?.trim();
|
|
15
|
+
return (globalThis as any).Deno.env?.get?.(env)?.trim() || undefined;
|
|
16
16
|
}
|
|
17
17
|
return undefined;
|
|
18
18
|
};
|
package/src/internal/utils.ts
CHANGED
package/src/resources/shared.ts
CHANGED
|
@@ -3,6 +3,23 @@
|
|
|
3
3
|
import * as Shared from './shared';
|
|
4
4
|
import { BodyCursorPage } from '../core/pagination';
|
|
5
5
|
|
|
6
|
+
export interface BalanceFilter {
|
|
7
|
+
/**
|
|
8
|
+
* The balance type to filter by.
|
|
9
|
+
*/
|
|
10
|
+
balance_types?: Array<'PREPAID_COMMIT' | 'POSTPAID_COMMIT' | 'CREDIT'>;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Custom fields to compute balance across. Must match all custom fields
|
|
14
|
+
*/
|
|
15
|
+
custom_fields?: { [key: string]: string };
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Specific IDs to compute balance across.
|
|
19
|
+
*/
|
|
20
|
+
ids?: Array<string>;
|
|
21
|
+
}
|
|
22
|
+
|
|
6
23
|
export interface BaseThresholdCommit {
|
|
7
24
|
/**
|
|
8
25
|
* The commit product that will be used to generate the line item for commit
|
|
@@ -17,6 +34,12 @@ export interface BaseThresholdCommit {
|
|
|
17
34
|
* will default to the commit product name.
|
|
18
35
|
*/
|
|
19
36
|
name?: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The priority of the commit, used to determine drawdown order. Lower priority
|
|
40
|
+
* commits are consumed first. Defaults to 100 if not specified.
|
|
41
|
+
*/
|
|
42
|
+
priority?: number;
|
|
20
43
|
}
|
|
21
44
|
|
|
22
45
|
export interface BaseUsageFilter {
|
|
@@ -407,10 +430,12 @@ export namespace CommitHierarchyConfiguration {
|
|
|
407
430
|
* list rate when consuming a credit or commit.
|
|
408
431
|
*/
|
|
409
432
|
export interface CommitRate {
|
|
410
|
-
rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'CUSTOM';
|
|
433
|
+
rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM';
|
|
411
434
|
|
|
412
435
|
/**
|
|
413
|
-
* Commit rate price. For FLAT rate_type, this must be >=0.
|
|
436
|
+
* Commit rate price. For FLAT rate_type, this must be >=0. For PERCENTAGE
|
|
437
|
+
* rate_type, this is a decimal fraction, e.g. use 0.1 for 10%; this must be >=0
|
|
438
|
+
* and <=1.
|
|
414
439
|
*/
|
|
415
440
|
price?: number;
|
|
416
441
|
|
|
@@ -438,8 +463,16 @@ export interface CommitSpecifier {
|
|
|
438
463
|
}
|
|
439
464
|
|
|
440
465
|
export interface CommitSpecifierInput {
|
|
466
|
+
/**
|
|
467
|
+
* If provided, the specifier will apply to product usage with these set of
|
|
468
|
+
* presentation group values.
|
|
469
|
+
*/
|
|
441
470
|
presentation_group_values?: { [key: string]: string };
|
|
442
471
|
|
|
472
|
+
/**
|
|
473
|
+
* If provided, the specifier will apply to product usage with these set of pricing
|
|
474
|
+
* group values.
|
|
475
|
+
*/
|
|
443
476
|
pricing_group_values?: { [key: string]: string };
|
|
444
477
|
|
|
445
478
|
/**
|
|
@@ -481,12 +514,12 @@ export interface Contract {
|
|
|
481
514
|
*/
|
|
482
515
|
customer_billing_provider_configuration?: Contract.CustomerBillingProviderConfiguration;
|
|
483
516
|
|
|
484
|
-
prepaid_balance_threshold_configuration?: PrepaidBalanceThresholdConfiguration;
|
|
485
|
-
|
|
486
517
|
/**
|
|
487
|
-
*
|
|
518
|
+
* ID of the package this contract was created from, if applicable.
|
|
488
519
|
*/
|
|
489
|
-
|
|
520
|
+
package_id?: string;
|
|
521
|
+
|
|
522
|
+
prepaid_balance_threshold_configuration?: PrepaidBalanceThresholdConfiguration;
|
|
490
523
|
|
|
491
524
|
/**
|
|
492
525
|
* Determines which scheduled and commit charges to consolidate onto the Contract's
|
|
@@ -1054,6 +1087,8 @@ export namespace ContractV2 {
|
|
|
1054
1087
|
export interface Override {
|
|
1055
1088
|
id: string;
|
|
1056
1089
|
|
|
1090
|
+
created_at: string;
|
|
1091
|
+
|
|
1057
1092
|
starting_at: string;
|
|
1058
1093
|
|
|
1059
1094
|
applicable_product_tags?: Array<string>;
|
|
@@ -1096,12 +1131,10 @@ export namespace ContractV2 {
|
|
|
1096
1131
|
product_tags?: Array<string>;
|
|
1097
1132
|
|
|
1098
1133
|
recurring_commit_ids?: Array<string>;
|
|
1099
|
-
|
|
1100
|
-
recurring_credit_ids?: Array<string>;
|
|
1101
1134
|
}
|
|
1102
1135
|
|
|
1103
1136
|
export interface OverwriteRate {
|
|
1104
|
-
rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'CUSTOM';
|
|
1137
|
+
rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM';
|
|
1105
1138
|
|
|
1106
1139
|
credit_type?: Shared.CreditTypeData;
|
|
1107
1140
|
|
|
@@ -1240,6 +1273,7 @@ export namespace ContractV2 {
|
|
|
1240
1273
|
| Credit.CreditCreditedLedgerEntry
|
|
1241
1274
|
| Credit.CreditManualLedgerEntry
|
|
1242
1275
|
| Credit.CreditSeatBasedAdjustmentLedgerEntry
|
|
1276
|
+
| Credit.CreditRolloverLedgerEntry
|
|
1243
1277
|
>;
|
|
1244
1278
|
|
|
1245
1279
|
name?: string;
|
|
@@ -1260,6 +1294,8 @@ export namespace ContractV2 {
|
|
|
1260
1294
|
*/
|
|
1261
1295
|
recurring_credit_id?: string;
|
|
1262
1296
|
|
|
1297
|
+
rolled_over_from?: Credit.RolledOverFrom;
|
|
1298
|
+
|
|
1263
1299
|
/**
|
|
1264
1300
|
* This field's availability is dependent on your client's configuration.
|
|
1265
1301
|
*/
|
|
@@ -1370,6 +1406,24 @@ export namespace ContractV2 {
|
|
|
1370
1406
|
|
|
1371
1407
|
type: 'CREDIT_SEAT_BASED_ADJUSTMENT';
|
|
1372
1408
|
}
|
|
1409
|
+
|
|
1410
|
+
export interface CreditRolloverLedgerEntry {
|
|
1411
|
+
amount: number;
|
|
1412
|
+
|
|
1413
|
+
new_contract_id: string;
|
|
1414
|
+
|
|
1415
|
+
segment_id: string;
|
|
1416
|
+
|
|
1417
|
+
timestamp: string;
|
|
1418
|
+
|
|
1419
|
+
type: 'CREDIT_ROLLOVER';
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
export interface RolledOverFrom {
|
|
1423
|
+
contract_id: string;
|
|
1424
|
+
|
|
1425
|
+
credit_id: string;
|
|
1426
|
+
}
|
|
1373
1427
|
}
|
|
1374
1428
|
|
|
1375
1429
|
/**
|
|
@@ -1433,8 +1487,8 @@ export namespace ContractV2 {
|
|
|
1433
1487
|
|
|
1434
1488
|
export interface ParentBehavior {
|
|
1435
1489
|
/**
|
|
1436
|
-
*
|
|
1437
|
-
*
|
|
1490
|
+
* Indicates the desired behavior of consolidated invoices generated by the parent
|
|
1491
|
+
* in a customer hierarchy
|
|
1438
1492
|
*
|
|
1439
1493
|
* **CONCATENATE**: Statements on the invoices of child customers will be appended
|
|
1440
1494
|
* to the consolidated invoice
|
|
@@ -1452,15 +1506,15 @@ export namespace ContractV2 {
|
|
|
1452
1506
|
parent: ChildHierarchyConfigurationV2.Parent;
|
|
1453
1507
|
|
|
1454
1508
|
/**
|
|
1455
|
-
*
|
|
1456
|
-
*
|
|
1457
|
-
*
|
|
1509
|
+
* Indicates which customer should pay for the child's invoice charges **SELF**:
|
|
1510
|
+
* The child pays for its own invoice charges **PARENT**: The parent pays for the
|
|
1511
|
+
* child's invoice charges
|
|
1458
1512
|
*/
|
|
1459
1513
|
payer?: 'SELF' | 'PARENT';
|
|
1460
1514
|
|
|
1461
1515
|
/**
|
|
1462
|
-
*
|
|
1463
|
-
*
|
|
1516
|
+
* Indicates the behavior of the child's invoice statements on the parent's
|
|
1517
|
+
* invoices.
|
|
1464
1518
|
*
|
|
1465
1519
|
* **CONSOLIDATE**: Child's invoice statements will be added to parent's
|
|
1466
1520
|
* consolidated invoices
|
|
@@ -2291,6 +2345,7 @@ export interface Credit {
|
|
|
2291
2345
|
| Credit.CreditCreditedLedgerEntry
|
|
2292
2346
|
| Credit.CreditManualLedgerEntry
|
|
2293
2347
|
| Credit.CreditSeatBasedAdjustmentLedgerEntry
|
|
2348
|
+
| Credit.CreditRolloverLedgerEntry
|
|
2294
2349
|
>;
|
|
2295
2350
|
|
|
2296
2351
|
name?: string;
|
|
@@ -2314,6 +2369,8 @@ export interface Credit {
|
|
|
2314
2369
|
*/
|
|
2315
2370
|
recurring_credit_id?: string;
|
|
2316
2371
|
|
|
2372
|
+
rolled_over_from?: Credit.RolledOverFrom;
|
|
2373
|
+
|
|
2317
2374
|
/**
|
|
2318
2375
|
* This field's availability is dependent on your client's configuration.
|
|
2319
2376
|
*/
|
|
@@ -2434,6 +2491,24 @@ export namespace Credit {
|
|
|
2434
2491
|
type: 'CREDIT_SEAT_BASED_ADJUSTMENT';
|
|
2435
2492
|
}
|
|
2436
2493
|
|
|
2494
|
+
export interface CreditRolloverLedgerEntry {
|
|
2495
|
+
amount: number;
|
|
2496
|
+
|
|
2497
|
+
new_contract_id: string;
|
|
2498
|
+
|
|
2499
|
+
segment_id: string;
|
|
2500
|
+
|
|
2501
|
+
timestamp: string;
|
|
2502
|
+
|
|
2503
|
+
type: 'CREDIT_ROLLOVER';
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2506
|
+
export interface RolledOverFrom {
|
|
2507
|
+
contract_id: string;
|
|
2508
|
+
|
|
2509
|
+
credit_id: string;
|
|
2510
|
+
}
|
|
2511
|
+
|
|
2437
2512
|
/**
|
|
2438
2513
|
* The subscription configuration for this credit, if it was generated from a
|
|
2439
2514
|
* recurring credit with a subscription attached.
|
|
@@ -2536,8 +2611,8 @@ export namespace HierarchyConfiguration {
|
|
|
2536
2611
|
|
|
2537
2612
|
export interface ParentBehavior {
|
|
2538
2613
|
/**
|
|
2539
|
-
*
|
|
2540
|
-
*
|
|
2614
|
+
* Indicates the desired behavior of consolidated invoices generated by the parent
|
|
2615
|
+
* in a customer hierarchy
|
|
2541
2616
|
*
|
|
2542
2617
|
* **CONCATENATE**: Statements on the invoices of child customers will be appended
|
|
2543
2618
|
* to the consolidated invoice
|
|
@@ -2555,8 +2630,7 @@ export namespace HierarchyConfiguration {
|
|
|
2555
2630
|
parent: ChildHierarchyConfiguration.Parent;
|
|
2556
2631
|
|
|
2557
2632
|
/**
|
|
2558
|
-
*
|
|
2559
|
-
* invoice charges
|
|
2633
|
+
* Indicates which customer should pay for the child's invoice charges
|
|
2560
2634
|
*
|
|
2561
2635
|
* **SELF**: The child pays for its own invoice charges
|
|
2562
2636
|
*
|
|
@@ -2565,8 +2639,8 @@ export namespace HierarchyConfiguration {
|
|
|
2565
2639
|
payer?: 'SELF' | 'PARENT';
|
|
2566
2640
|
|
|
2567
2641
|
/**
|
|
2568
|
-
*
|
|
2569
|
-
*
|
|
2642
|
+
* Indicates the behavior of the child's invoice statements on the parent's
|
|
2643
|
+
* invoices.
|
|
2570
2644
|
*
|
|
2571
2645
|
* **CONSOLIDATE**: Child's invoice statements will be added to parent's
|
|
2572
2646
|
* consolidated invoices
|
|
@@ -2596,6 +2670,8 @@ export interface ID {
|
|
|
2596
2670
|
export interface Override {
|
|
2597
2671
|
id: string;
|
|
2598
2672
|
|
|
2673
|
+
created_at: string;
|
|
2674
|
+
|
|
2599
2675
|
starting_at: string;
|
|
2600
2676
|
|
|
2601
2677
|
applicable_product_tags?: Array<string>;
|
|
@@ -2637,7 +2713,7 @@ export interface Override {
|
|
|
2637
2713
|
*/
|
|
2638
2714
|
quantity?: number;
|
|
2639
2715
|
|
|
2640
|
-
rate_type?: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'CUSTOM';
|
|
2716
|
+
rate_type?: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM';
|
|
2641
2717
|
|
|
2642
2718
|
target?: 'COMMIT_RATE' | 'LIST_RATE';
|
|
2643
2719
|
|
|
@@ -2670,8 +2746,6 @@ export namespace Override {
|
|
|
2670
2746
|
product_tags?: Array<string>;
|
|
2671
2747
|
|
|
2672
2748
|
recurring_commit_ids?: Array<string>;
|
|
2673
|
-
|
|
2674
|
-
recurring_credit_ids?: Array<string>;
|
|
2675
2749
|
}
|
|
2676
2750
|
|
|
2677
2751
|
export interface Product {
|
|
@@ -2688,7 +2762,7 @@ export interface OverrideTier {
|
|
|
2688
2762
|
}
|
|
2689
2763
|
|
|
2690
2764
|
export interface OverwriteRate {
|
|
2691
|
-
rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'CUSTOM';
|
|
2765
|
+
rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM';
|
|
2692
2766
|
|
|
2693
2767
|
credit_type?: CreditTypeData;
|
|
2694
2768
|
|
|
@@ -2745,7 +2819,7 @@ export interface PaymentGateConfig {
|
|
|
2745
2819
|
* not wish Metronome to calculate tax on your behalf. Leaving this field blank
|
|
2746
2820
|
* will default to NONE.
|
|
2747
2821
|
*/
|
|
2748
|
-
tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | '
|
|
2822
|
+
tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED';
|
|
2749
2823
|
}
|
|
2750
2824
|
|
|
2751
2825
|
export namespace PaymentGateConfig {
|
|
@@ -2807,7 +2881,7 @@ export interface PaymentGateConfigV2 {
|
|
|
2807
2881
|
* not wish Metronome to calculate tax on your behalf. Leaving this field blank
|
|
2808
2882
|
* will default to NONE.
|
|
2809
2883
|
*/
|
|
2810
|
-
tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | '
|
|
2884
|
+
tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED';
|
|
2811
2885
|
}
|
|
2812
2886
|
|
|
2813
2887
|
export namespace PaymentGateConfigV2 {
|
|
@@ -2873,6 +2947,8 @@ export interface PrepaidBalanceThresholdConfiguration {
|
|
|
2873
2947
|
* commit amount will be in terms of this credit type instead of the fiat currency.
|
|
2874
2948
|
*/
|
|
2875
2949
|
custom_credit_type_id?: string;
|
|
2950
|
+
|
|
2951
|
+
discount_configuration?: PrepaidBalanceThresholdConfiguration.DiscountConfiguration;
|
|
2876
2952
|
}
|
|
2877
2953
|
|
|
2878
2954
|
export namespace PrepaidBalanceThresholdConfiguration {
|
|
@@ -2899,6 +2975,15 @@ export namespace PrepaidBalanceThresholdConfiguration {
|
|
|
2899
2975
|
*/
|
|
2900
2976
|
specifiers?: Array<Shared.CommitSpecifierInput>;
|
|
2901
2977
|
}
|
|
2978
|
+
|
|
2979
|
+
export interface DiscountConfiguration {
|
|
2980
|
+
/**
|
|
2981
|
+
* The fraction of the original amount that the customer pays after applying the
|
|
2982
|
+
* discount. For example, 0.85 means the customer pays 85% of the original amount
|
|
2983
|
+
* (a 15% discount).
|
|
2984
|
+
*/
|
|
2985
|
+
payment_fraction: number;
|
|
2986
|
+
}
|
|
2902
2987
|
}
|
|
2903
2988
|
|
|
2904
2989
|
export interface PrepaidBalanceThresholdConfigurationV2 {
|
|
@@ -2929,10 +3014,12 @@ export interface PrepaidBalanceThresholdConfigurationV2 {
|
|
|
2929
3014
|
* commit amount will be in terms of this credit type instead of the fiat currency.
|
|
2930
3015
|
*/
|
|
2931
3016
|
custom_credit_type_id?: string;
|
|
3017
|
+
|
|
3018
|
+
discount_configuration?: PrepaidBalanceThresholdConfigurationV2.DiscountConfiguration;
|
|
2932
3019
|
}
|
|
2933
3020
|
|
|
2934
3021
|
export namespace PrepaidBalanceThresholdConfigurationV2 {
|
|
2935
|
-
export interface Commit extends Shared.
|
|
3022
|
+
export interface Commit extends Shared.BaseThresholdCommit {
|
|
2936
3023
|
/**
|
|
2937
3024
|
* Which products the threshold commit applies to. If applicable_product_ids,
|
|
2938
3025
|
* applicable_product_tags or specifiers are not provided, the commit applies to
|
|
@@ -2957,6 +3044,15 @@ export namespace PrepaidBalanceThresholdConfigurationV2 {
|
|
|
2957
3044
|
*/
|
|
2958
3045
|
specifiers?: Array<Shared.CommitSpecifierInput>;
|
|
2959
3046
|
}
|
|
3047
|
+
|
|
3048
|
+
export interface DiscountConfiguration {
|
|
3049
|
+
/**
|
|
3050
|
+
* The fraction of the original amount that the customer pays after applying the
|
|
3051
|
+
* discount. For example, 0.85 means the customer pays 85% of the original amount
|
|
3052
|
+
* (a 15% discount).
|
|
3053
|
+
*/
|
|
3054
|
+
payment_fraction: number;
|
|
3055
|
+
}
|
|
2960
3056
|
}
|
|
2961
3057
|
|
|
2962
3058
|
export interface PropertyFilter {
|
|
@@ -3026,7 +3122,7 @@ export interface ProService {
|
|
|
3026
3122
|
}
|
|
3027
3123
|
|
|
3028
3124
|
export interface Rate {
|
|
3029
|
-
rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'CUSTOM' | 'TIERED';
|
|
3125
|
+
rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'CUSTOM' | 'TIERED' | 'TIERED_PERCENTAGE';
|
|
3030
3126
|
|
|
3031
3127
|
credit_type?: CreditTypeData;
|
|
3032
3128
|
|
|
@@ -3178,10 +3274,23 @@ export interface SpendThresholdConfiguration {
|
|
|
3178
3274
|
* hits this amount, a threshold charge will be initiated.
|
|
3179
3275
|
*/
|
|
3180
3276
|
threshold_amount: number;
|
|
3277
|
+
|
|
3278
|
+
discount_configuration?: SpendThresholdConfiguration.DiscountConfiguration;
|
|
3279
|
+
}
|
|
3280
|
+
|
|
3281
|
+
export namespace SpendThresholdConfiguration {
|
|
3282
|
+
export interface DiscountConfiguration {
|
|
3283
|
+
/**
|
|
3284
|
+
* The fraction of the original amount that the customer pays after applying the
|
|
3285
|
+
* discount. For example, 0.85 means the customer pays 85% of the original amount
|
|
3286
|
+
* (a 15% discount).
|
|
3287
|
+
*/
|
|
3288
|
+
payment_fraction: number;
|
|
3289
|
+
}
|
|
3181
3290
|
}
|
|
3182
3291
|
|
|
3183
3292
|
export interface SpendThresholdConfigurationV2 {
|
|
3184
|
-
commit:
|
|
3293
|
+
commit: BaseThresholdCommit;
|
|
3185
3294
|
|
|
3186
3295
|
/**
|
|
3187
3296
|
* When set to false, the contract will not be evaluated against the
|
|
@@ -3197,6 +3306,19 @@ export interface SpendThresholdConfigurationV2 {
|
|
|
3197
3306
|
* hits this amount, a threshold charge will be initiated.
|
|
3198
3307
|
*/
|
|
3199
3308
|
threshold_amount: number;
|
|
3309
|
+
|
|
3310
|
+
discount_configuration?: SpendThresholdConfigurationV2.DiscountConfiguration;
|
|
3311
|
+
}
|
|
3312
|
+
|
|
3313
|
+
export namespace SpendThresholdConfigurationV2 {
|
|
3314
|
+
export interface DiscountConfiguration {
|
|
3315
|
+
/**
|
|
3316
|
+
* The fraction of the original amount that the customer pays after applying the
|
|
3317
|
+
* discount. For example, 0.85 means the customer pays 85% of the original amount
|
|
3318
|
+
* (a 15% discount).
|
|
3319
|
+
*/
|
|
3320
|
+
payment_fraction: number;
|
|
3321
|
+
}
|
|
3200
3322
|
}
|
|
3201
3323
|
|
|
3202
3324
|
export interface Subscription {
|
|
@@ -3338,6 +3460,13 @@ export interface UpdateBaseThresholdCommit {
|
|
|
3338
3460
|
*/
|
|
3339
3461
|
name?: string;
|
|
3340
3462
|
|
|
3463
|
+
/**
|
|
3464
|
+
* The priority of the commit, used to determine drawdown order. Lower priority
|
|
3465
|
+
* commits are consumed first. Defaults to 100 if not specified. On updates, set to
|
|
3466
|
+
* null to clear a previously configured priority.
|
|
3467
|
+
*/
|
|
3468
|
+
priority?: number | null;
|
|
3469
|
+
|
|
3341
3470
|
/**
|
|
3342
3471
|
* The commit product that will be used to generate the line item for commit
|
|
3343
3472
|
* payment.
|
|
@@ -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
|
+
* [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)
|
|
10
|
+
*/
|
|
8
11
|
export class Alerts extends APIResource {
|
|
9
12
|
/**
|
|
10
13
|
* Create a new threshold notification to monitor customer spending, balances, and
|
|
@@ -4,6 +4,9 @@ import { APIResource } from '../../core/resource';
|
|
|
4
4
|
import { CursorPage, type CursorPageParams, PagePromise } from '../../core/pagination';
|
|
5
5
|
import { RequestOptions } from '../../internal/request-options';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* [Security](https://docs.metronome.com/developer-resources/security/) endpoints allow you to retrieve security-related data.
|
|
9
|
+
*/
|
|
7
10
|
export class AuditLogs extends APIResource {
|
|
8
11
|
/**
|
|
9
12
|
* Get a comprehensive audit trail of all operations performed in your Metronome
|
|
@@ -7,6 +7,9 @@ import { CursorPage, type CursorPageParams, PagePromise } from '../../core/pagin
|
|
|
7
7
|
import { RequestOptions } from '../../internal/request-options';
|
|
8
8
|
import { path } from '../../internal/utils/path';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* [Billable metrics](https://docs.metronome.com/understanding-metronome/how-metronome-works#billable-metrics) in Metronome represent the various consumption components that Metronome meters and aggregates.
|
|
12
|
+
*/
|
|
10
13
|
export class BillableMetrics extends APIResource {
|
|
11
14
|
/**
|
|
12
15
|
* Create billable metrics programmatically with this endpoint—an essential step in
|