diff --git a/.stats.yml b/.stats.yml index 9bdc000..67feb2f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 91 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/metronome%2Fmetronome-b0024765a98d3608014ecde441861bdb0b1f075cb56bd7c0967104fa7ee020ef.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/metronome%2Fmetronome-a89210f56e000a978cd97348ab656503553f7a93d055561792d012c4a70cd5da.yml diff --git a/src/resources/alerts.ts b/src/resources/alerts.ts index 1fe4ca7..a4da371 100644 --- a/src/resources/alerts.ts +++ b/src/resources/alerts.ts @@ -55,7 +55,8 @@ export interface AlertCreateParams { name: string; /** - * Threshold value of the alert policy + * Threshold value of the alert policy. Depending upon the alert type, this number + * may represent a financial amount, the days remaining, or a percentage reached. */ threshold: number; diff --git a/src/resources/contracts/contracts.ts b/src/resources/contracts/contracts.ts index d71f3d0..00a00a7 100644 --- a/src/resources/contracts/contracts.ts +++ b/src/resources/contracts/contracts.ts @@ -423,12 +423,71 @@ export namespace ContractRetrieveRateScheduleResponse { starting_at: string; + /** + * The rate that will be used to rate a product when it is paid for by a commit. + * This feature requires opt-in before it can be used. Please contact Metronome + * support to enable this feature. + */ + commit_rate?: Data.CommitRate; + ending_before?: string; override_rate?: Shared.Rate; pricing_group_values?: Record; } + + export namespace Data { + /** + * The rate that will be used to rate a product when it is paid for by a commit. + * This feature requires opt-in before it can be used. Please contact Metronome + * support to enable this feature. + */ + export interface CommitRate { + rate_type: + | 'FLAT' + | 'flat' + | 'PERCENTAGE' + | 'percentage' + | 'SUBSCRIPTION' + | 'subscription' + | 'TIERED' + | 'tiered' + | 'CUSTOM' + | 'custom'; + + credit_type?: Shared.CreditType; + + /** + * Commit rate proration configuration. Only valid for SUBSCRIPTION rate_type. + */ + is_prorated?: boolean; + + /** + * Commit rate price. For FLAT rate_type, this must be >=0. For PERCENTAGE + * rate_type, this is a decimal fraction, e.g. use 0.1 for 10%; this must be >=0 + * and <=1. + */ + price?: number; + + /** + * Commit rate quantity. For SUBSCRIPTION rate_type, this must be >=0. + */ + quantity?: number; + + /** + * Only set for TIERED rate_type. + */ + tiers?: Array; + + /** + * Only set for PERCENTAGE rate_type. Defaults to false. If true, rate is computed + * using list prices rather than the standard rates for this product on the + * contract. + */ + use_list_prices?: boolean; + } + } } export interface ContractScheduleProServicesInvoiceResponse { @@ -1265,10 +1324,19 @@ export namespace ContractCreateParams { export interface UsageStatementSchedule { frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL'; + /** + * Required when using CUSTOM_DATE. This option lets you set a historical billing + * anchor date, aligning future billing cycles with a chosen cadence. For example, + * if a contract starts on 2024-09-15 and you set the anchor date to 2024-09-10 + * with a MONTHLY frequency, the first usage statement will cover 09-15 to 10-10. + * Subsequent statements will follow the 10th of each month. + */ + billing_anchor_date?: string; + /** * If not provided, defaults to the first day of the month. */ - day?: 'FIRST_OF_MONTH' | 'CONTRACT_START'; + day?: 'FIRST_OF_MONTH' | 'CONTRACT_START' | 'CUSTOM_DATE' | 'custom_date'; /** * The date Metronome should start generating usage invoices. If unspecified, diff --git a/src/resources/contracts/rate-cards/rate-cards.ts b/src/resources/contracts/rate-cards/rate-cards.ts index b0e5b86..c4be46e 100644 --- a/src/resources/contracts/rate-cards/rate-cards.ts +++ b/src/resources/contracts/rate-cards/rate-cards.ts @@ -57,7 +57,8 @@ export class RateCards extends APIResource { } /** - * Get a specific rate schedule including all rate card entries + * Get all rates for a rate card from starting_at (either in perpetuity or until + * ending_before, if provided) */ retrieveRateSchedule( params: RateCardRetrieveRateScheduleParams, @@ -154,6 +155,13 @@ export namespace RateCardRetrieveResponse { starting_at: string; + /** + * The rate that will be used to rate a product when it is paid for by a commit. + * This feature requires opt-in before it can be used. Please contact Metronome + * support to enable this feature. + */ + commit_rate?: Update.CommitRate; + credit_type?: Shared.CreditType; custom_rate?: Record; @@ -168,6 +176,58 @@ export namespace RateCardRetrieveResponse { tiers?: Array; } + + export namespace Update { + /** + * The rate that will be used to rate a product when it is paid for by a commit. + * This feature requires opt-in before it can be used. Please contact Metronome + * support to enable this feature. + */ + export interface CommitRate { + rate_type: + | 'FLAT' + | 'flat' + | 'PERCENTAGE' + | 'percentage' + | 'SUBSCRIPTION' + | 'subscription' + | 'TIERED' + | 'tiered' + | 'CUSTOM' + | 'custom'; + + credit_type?: Shared.CreditType; + + /** + * Commit rate proration configuration. Only valid for SUBSCRIPTION rate_type. + */ + is_prorated?: boolean; + + /** + * Commit rate price. For FLAT rate_type, this must be >=0. For PERCENTAGE + * rate_type, this is a decimal fraction, e.g. use 0.1 for 10%; this must be >=0 + * and <=1. + */ + price?: number; + + /** + * Commit rate quantity. For SUBSCRIPTION rate_type, this must be >=0. + */ + quantity?: number; + + /** + * Only set for TIERED rate_type. + */ + tiers?: Array; + + /** + * Only set for PERCENTAGE rate_type. Defaults to false. If true, rate is computed + * using list prices rather than the standard rates for this product on the + * contract. + */ + use_list_prices?: boolean; + } + } } export interface Alias { @@ -261,6 +321,13 @@ export namespace RateCardListResponse { starting_at: string; + /** + * The rate that will be used to rate a product when it is paid for by a commit. + * This feature requires opt-in before it can be used. Please contact Metronome + * support to enable this feature. + */ + commit_rate?: Update.CommitRate; + credit_type?: Shared.CreditType; custom_rate?: Record; @@ -275,6 +342,58 @@ export namespace RateCardListResponse { tiers?: Array; } + + export namespace Update { + /** + * The rate that will be used to rate a product when it is paid for by a commit. + * This feature requires opt-in before it can be used. Please contact Metronome + * support to enable this feature. + */ + export interface CommitRate { + rate_type: + | 'FLAT' + | 'flat' + | 'PERCENTAGE' + | 'percentage' + | 'SUBSCRIPTION' + | 'subscription' + | 'TIERED' + | 'tiered' + | 'CUSTOM' + | 'custom'; + + credit_type?: Shared.CreditType; + + /** + * Commit rate proration configuration. Only valid for SUBSCRIPTION rate_type. + */ + is_prorated?: boolean; + + /** + * Commit rate price. For FLAT rate_type, this must be >=0. For PERCENTAGE + * rate_type, this is a decimal fraction, e.g. use 0.1 for 10%; this must be >=0 + * and <=1. + */ + price?: number; + + /** + * Commit rate quantity. For SUBSCRIPTION rate_type, this must be >=0. + */ + quantity?: number; + + /** + * Only set for TIERED rate_type. + */ + tiers?: Array; + + /** + * Only set for PERCENTAGE rate_type. Defaults to false. If true, rate is computed + * using list prices rather than the standard rates for this product on the + * contract. + */ + use_list_prices?: boolean; + } + } } export interface Alias { @@ -312,10 +431,69 @@ export namespace RateCardRetrieveRateScheduleResponse { starting_at: string; + /** + * The rate that will be used to rate a product when it is paid for by a commit. + * This feature requires opt-in before it can be used. Please contact Metronome + * support to enable this feature. + */ + commit_rate?: Data.CommitRate; + ending_before?: string; pricing_group_values?: Record; } + + export namespace Data { + /** + * The rate that will be used to rate a product when it is paid for by a commit. + * This feature requires opt-in before it can be used. Please contact Metronome + * support to enable this feature. + */ + export interface CommitRate { + rate_type: + | 'FLAT' + | 'flat' + | 'PERCENTAGE' + | 'percentage' + | 'SUBSCRIPTION' + | 'subscription' + | 'TIERED' + | 'tiered' + | 'CUSTOM' + | 'custom'; + + credit_type?: Shared.CreditType; + + /** + * Commit rate proration configuration. Only valid for SUBSCRIPTION rate_type. + */ + is_prorated?: boolean; + + /** + * Commit rate price. For FLAT rate_type, this must be >=0. For PERCENTAGE + * rate_type, this is a decimal fraction, e.g. use 0.1 for 10%; this must be >=0 + * and <=1. + */ + price?: number; + + /** + * Commit rate quantity. For SUBSCRIPTION rate_type, this must be >=0. + */ + quantity?: number; + + /** + * Only set for TIERED rate_type. + */ + tiers?: Array; + + /** + * Only set for PERCENTAGE rate_type. Defaults to false. If true, rate is computed + * using list prices rather than the standard rates for this product on the + * contract. + */ + use_list_prices?: boolean; + } + } } export interface RateCardCreateParams { diff --git a/src/resources/contracts/rate-cards/rates.ts b/src/resources/contracts/rate-cards/rates.ts index c2c4a06..ca4f1e8 100644 --- a/src/resources/contracts/rate-cards/rates.ts +++ b/src/resources/contracts/rate-cards/rates.ts @@ -9,7 +9,7 @@ import { CursorPage, type CursorPageParams } from '../../../pagination'; export class Rates extends APIResource { /** - * Get rate card rates for a specific time. + * Get all rates for a rate card at a point in time */ list( params: RateListParams, @@ -62,13 +62,189 @@ export interface RateListResponse { starting_at: string; + /** + * The rate that will be used to rate a product when it is paid for by a commit. + * This feature requires opt-in before it can be used. Please contact Metronome + * support to enable this feature. + */ + commit_rate?: RateListResponse.CommitRate; + ending_before?: string; pricing_group_values?: Record; } +export namespace RateListResponse { + /** + * The rate that will be used to rate a product when it is paid for by a commit. + * This feature requires opt-in before it can be used. Please contact Metronome + * support to enable this feature. + */ + export interface CommitRate { + rate_type: + | 'FLAT' + | 'flat' + | 'PERCENTAGE' + | 'percentage' + | 'SUBSCRIPTION' + | 'subscription' + | 'TIERED' + | 'tiered' + | 'CUSTOM' + | 'custom'; + + credit_type?: Shared.CreditType; + + /** + * Commit rate proration configuration. Only valid for SUBSCRIPTION rate_type. + */ + is_prorated?: boolean; + + /** + * Commit rate price. For FLAT rate_type, this must be >=0. For PERCENTAGE + * rate_type, this is a decimal fraction, e.g. use 0.1 for 10%; this must be >=0 + * and <=1. + */ + price?: number; + + /** + * Commit rate quantity. For SUBSCRIPTION rate_type, this must be >=0. + */ + quantity?: number; + + /** + * Only set for TIERED rate_type. + */ + tiers?: Array; + + /** + * Only set for PERCENTAGE rate_type. Defaults to false. If true, rate is computed + * using list prices rather than the standard rates for this product on the + * contract. + */ + use_list_prices?: boolean; + } +} + export interface RateAddResponse { - data: Shared.Rate; + data: RateAddResponse.Data; +} + +export namespace RateAddResponse { + export interface Data { + rate_type: + | 'FLAT' + | 'flat' + | 'PERCENTAGE' + | 'percentage' + | 'SUBSCRIPTION' + | 'subscription' + | 'CUSTOM' + | 'custom' + | 'TIERED' + | 'tiered'; + + /** + * The rate that will be used to rate a product when it is paid for by a commit. + * This feature requires opt-in before it can be used. Please contact Metronome + * support to enable this feature. + */ + commit_rate?: Data.CommitRate; + + credit_type?: Shared.CreditType; + + /** + * Only set for CUSTOM rate_type. This field is interpreted by custom rate + * processors. + */ + custom_rate?: Record; + + /** + * Default proration configuration. Only valid for SUBSCRIPTION rate_type. + */ + is_prorated?: boolean; + + /** + * Default price. For FLAT rate_type, this must be >=0. For PERCENTAGE rate_type, + * this is a decimal fraction, e.g. use 0.1 for 10%; this must be >=0 and <=1. + */ + price?: number; + + /** + * if pricing groups are used, this will contain the values used to calculate the + * price + */ + pricing_group_values?: Record; + + /** + * Default quantity. For SUBSCRIPTION rate_type, this must be >=0. + */ + quantity?: number; + + /** + * Only set for TIERED rate_type. + */ + tiers?: Array; + + /** + * Only set for PERCENTAGE rate_type. Defaults to false. If true, rate is computed + * using list prices rather than the standard rates for this product on the + * contract. + */ + use_list_prices?: boolean; + } + + export namespace Data { + /** + * The rate that will be used to rate a product when it is paid for by a commit. + * This feature requires opt-in before it can be used. Please contact Metronome + * support to enable this feature. + */ + export interface CommitRate { + rate_type: + | 'FLAT' + | 'flat' + | 'PERCENTAGE' + | 'percentage' + | 'SUBSCRIPTION' + | 'subscription' + | 'TIERED' + | 'tiered' + | 'CUSTOM' + | 'custom'; + + credit_type?: Shared.CreditType; + + /** + * Commit rate proration configuration. Only valid for SUBSCRIPTION rate_type. + */ + is_prorated?: boolean; + + /** + * Commit rate price. For FLAT rate_type, this must be >=0. For PERCENTAGE + * rate_type, this is a decimal fraction, e.g. use 0.1 for 10%; this must be >=0 + * and <=1. + */ + price?: number; + + /** + * Commit rate quantity. For SUBSCRIPTION rate_type, this must be >=0. + */ + quantity?: number; + + /** + * Only set for TIERED rate_type. + */ + tiers?: Array; + + /** + * Only set for PERCENTAGE rate_type. Defaults to false. If true, rate is computed + * using list prices rather than the standard rates for this product on the + * contract. + */ + use_list_prices?: boolean; + } + } } export interface RateAddManyResponse { @@ -144,6 +320,13 @@ export interface RateAddParams { */ starting_at: string; + /** + * The rate that will be used to rate a product when it is paid for by a commit. + * This feature requires opt-in before it can be used. Please contact Metronome + * support to enable this feature. + */ + commit_rate?: RateAddParams.CommitRate; + /** * "The Metronome ID of the credit type to associate with price, defaults to USD * (cents) if not passed. Used by all rate_types except type PERCENTAGE. PERCENTAGE @@ -198,6 +381,58 @@ export interface RateAddParams { use_list_prices?: boolean; } +export namespace RateAddParams { + /** + * The rate that will be used to rate a product when it is paid for by a commit. + * This feature requires opt-in before it can be used. Please contact Metronome + * support to enable this feature. + */ + export interface CommitRate { + rate_type: + | 'FLAT' + | 'flat' + | 'PERCENTAGE' + | 'percentage' + | 'SUBSCRIPTION' + | 'subscription' + | 'TIERED' + | 'tiered' + | 'CUSTOM' + | 'custom'; + + credit_type?: Shared.CreditType; + + /** + * Commit rate proration configuration. Only valid for SUBSCRIPTION rate_type. + */ + is_prorated?: boolean; + + /** + * Commit rate price. For FLAT rate_type, this must be >=0. For PERCENTAGE + * rate_type, this is a decimal fraction, e.g. use 0.1 for 10%; this must be >=0 + * and <=1. + */ + price?: number; + + /** + * Commit rate quantity. For SUBSCRIPTION rate_type, this must be >=0. + */ + quantity?: number; + + /** + * Only set for TIERED rate_type. + */ + tiers?: Array; + + /** + * Only set for PERCENTAGE rate_type. Defaults to false. If true, rate is computed + * using list prices rather than the standard rates for this product on the + * contract. + */ + use_list_prices?: boolean; + } +} + export interface RateAddManyParams { rate_card_id?: string; @@ -220,6 +455,13 @@ export namespace RateAddManyParams { */ starting_at: string; + /** + * The rate that will be used to rate a product when it is paid for by a commit. + * This feature requires opt-in before it can be used. Please contact Metronome + * support to enable this feature. + */ + commit_rate?: Rate.CommitRate; + /** * "The Metronome ID of the credit type to associate with price, defaults to USD * (cents) if not passed. Used by all rate_types except type PERCENTAGE. PERCENTAGE @@ -273,6 +515,58 @@ export namespace RateAddManyParams { */ use_list_prices?: boolean; } + + export namespace Rate { + /** + * The rate that will be used to rate a product when it is paid for by a commit. + * This feature requires opt-in before it can be used. Please contact Metronome + * support to enable this feature. + */ + export interface CommitRate { + rate_type: + | 'FLAT' + | 'flat' + | 'PERCENTAGE' + | 'percentage' + | 'SUBSCRIPTION' + | 'subscription' + | 'TIERED' + | 'tiered' + | 'CUSTOM' + | 'custom'; + + credit_type?: Shared.CreditType; + + /** + * Commit rate proration configuration. Only valid for SUBSCRIPTION rate_type. + */ + is_prorated?: boolean; + + /** + * Commit rate price. For FLAT rate_type, this must be >=0. For PERCENTAGE + * rate_type, this is a decimal fraction, e.g. use 0.1 for 10%; this must be >=0 + * and <=1. + */ + price?: number; + + /** + * Commit rate quantity. For SUBSCRIPTION rate_type, this must be >=0. + */ + quantity?: number; + + /** + * Only set for TIERED rate_type. + */ + tiers?: Array; + + /** + * Only set for PERCENTAGE rate_type. Defaults to false. If true, rate is computed + * using list prices rather than the standard rates for this product on the + * contract. + */ + use_list_prices?: boolean; + } + } } export namespace Rates { diff --git a/src/resources/credit-grants.ts b/src/resources/credit-grants.ts index f374a2f..fb7b586 100644 --- a/src/resources/credit-grants.ts +++ b/src/resources/credit-grants.ts @@ -389,8 +389,7 @@ export interface CreditGrantCreateParams { customer_id: string; /** - * The credit grant will only apply to billing periods that end before this - * timestamp. + * The credit grant will only apply to usage or charges dated before this timestamp */ expires_at: string; @@ -419,8 +418,8 @@ export interface CreditGrantCreateParams { custom_fields?: Record; /** - * The credit grant will only apply to billing periods that end at or after this - * timestamp. + * The credit grant will only apply to usage or charges dated on or after this + * timestamp */ effective_at?: string; @@ -461,6 +460,9 @@ export namespace CreditGrantCreateParams { export interface GrantAmount { amount: number; + /** + * the ID of the pricing unit to be used + */ credit_type_id: string; } @@ -470,6 +472,9 @@ export namespace CreditGrantCreateParams { export interface PaidAmount { amount: number; + /** + * the ID of the pricing unit to be used + */ credit_type_id: string; } diff --git a/src/resources/shared.ts b/src/resources/shared.ts index 44de68b..e1289eb 100644 --- a/src/resources/shared.ts +++ b/src/resources/shared.ts @@ -326,6 +326,11 @@ export namespace ContractWithoutAmendments { } export interface UsageStatementSchedule { + /** + * Contract usage statements follow a selected cadence based on this date. + */ + billing_anchor_date: string; + frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL'; } diff --git a/tests/api-resources/contracts/contracts.test.ts b/tests/api-resources/contracts/contracts.test.ts index a9c37eb..de3393e 100644 --- a/tests/api-resources/contracts/contracts.test.ts +++ b/tests/api-resources/contracts/contracts.test.ts @@ -696,6 +696,7 @@ describe('resource contracts', () => { }, usage_statement_schedule: { frequency: 'MONTHLY', + billing_anchor_date: '2019-12-27T18:11:19.117Z', day: 'FIRST_OF_MONTH', invoice_generation_starting_at: '2019-12-27T18:11:19.117Z', }, diff --git a/tests/api-resources/contracts/rate-cards/rates.test.ts b/tests/api-resources/contracts/rate-cards/rates.test.ts index e5cc302..c33b9a7 100644 --- a/tests/api-resources/contracts/rate-cards/rates.test.ts +++ b/tests/api-resources/contracts/rate-cards/rates.test.ts @@ -64,6 +64,19 @@ describe('resource rates', () => { rate_card_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', rate_type: 'FLAT', starting_at: '2020-01-01T00:00:00.000Z', + commit_rate: { + rate_type: 'FLAT', + credit_type: { id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', name: 'name' }, + is_prorated: true, + price: 0, + quantity: 0, + tiers: [ + { price: 0, size: 0 }, + { price: 0, size: 0 }, + { price: 0, size: 0 }, + ], + use_list_prices: true, + }, credit_type_id: '2714e483-4ff1-48e4-9e25-ac732e8f24f2', custom_rate: { foo: 'bar' }, ending_before: '2019-12-27T18:11:19.117Z', @@ -110,6 +123,19 @@ describe('resource rates', () => { product_id: '13117714-3f05-48e5-a6e9-a66093f13b4d', rate_type: 'FLAT', starting_at: '2020-01-01T00:00:00.000Z', + commit_rate: { + rate_type: 'FLAT', + credit_type: { id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', name: 'name' }, + is_prorated: true, + price: 0, + quantity: 0, + tiers: [ + { price: 0, size: 0 }, + { price: 0, size: 0 }, + { price: 0, size: 0 }, + ], + use_list_prices: true, + }, credit_type_id: '2714e483-4ff1-48e4-9e25-ac732e8f24f2', custom_rate: { foo: 'bar' }, ending_before: '2019-12-27T18:11:19.117Z', @@ -129,6 +155,19 @@ describe('resource rates', () => { product_id: '13117714-3f05-48e5-a6e9-a66093f13b4d', rate_type: 'FLAT', starting_at: '2020-01-01T00:00:00.000Z', + commit_rate: { + rate_type: 'FLAT', + credit_type: { id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', name: 'name' }, + is_prorated: true, + price: 0, + quantity: 0, + tiers: [ + { price: 0, size: 0 }, + { price: 0, size: 0 }, + { price: 0, size: 0 }, + ], + use_list_prices: true, + }, credit_type_id: '2714e483-4ff1-48e4-9e25-ac732e8f24f2', custom_rate: { foo: 'bar' }, ending_before: '2019-12-27T18:11:19.117Z',