// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; import { APIPromise } from '../core/api-promise'; import { RequestOptions } from '../internal/request-options'; import { path } from '../internal/utils/path'; export class Prices extends APIResource { /** * Create Price */ create(body: PriceCreateParams, options?: RequestOptions): APIPromise { return this._client.post('/api/v1/prices', { body, ...options }); } /** * Update Price */ update(id: string, body: PriceUpdateParams, options?: RequestOptions): APIPromise { return this._client.put(path`/api/v1/prices/${id}`, { body, ...options }); } /** * List Prices */ list( query: PriceListParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.get('/api/v1/prices', { query, ...options }); } } export interface SinglePaymentPriceClientSelectSchema { id: string; active: boolean; /** * Epoch milliseconds. */ createdAt: number; /** * Currency code */ currency: | 'USD' | 'AED' | 'AFN' | 'ALL' | 'AMD' | 'ANG' | 'AOA' | 'ARS' | 'AUD' | 'AWG' | 'AZN' | 'BAM' | 'BBD' | 'BDT' | 'BGN' | 'BIF' | 'BMD' | 'BND' | 'BOB' | 'BRL' | 'BSD' | 'BWP' | 'BYN' | 'BZD' | 'CAD' | 'CDF' | 'CHF' | 'CLP' | 'CNY' | 'COP' | 'CRC' | 'CVE' | 'CZK' | 'DJF' | 'DKK' | 'DOP' | 'DZD' | 'EGP' | 'ETB' | 'EUR' | 'FJD' | 'FKP' | 'GBP' | 'GEL' | 'GIP' | 'GMD' | 'GNF' | 'GTQ' | 'GYD' | 'HKD' | 'HNL' | 'HTG' | 'HUF' | 'IDR' | 'ILS' | 'INR' | 'ISK' | 'JMD' | 'JPY' | 'KES' | 'KGS' | 'KHR' | 'KMF' | 'KRW' | 'KYD' | 'KZT' | 'LAK' | 'LBP' | 'LKR' | 'LRD' | 'LSL' | 'MAD' | 'MDL' | 'MGA' | 'MKD' | 'MMK' | 'MNT' | 'MOP' | 'MUR' | 'MVR' | 'MWK' | 'MXN' | 'MYR' | 'MZN' | 'NAD' | 'NGN' | 'NIO' | 'NOK' | 'NPR' | 'NZD' | 'PAB' | 'PEN' | 'PGK' | 'PHP' | 'PKR' | 'PLN' | 'PYG' | 'QAR' | 'RON' | 'RSD' | 'RUB' | 'RWF' | 'SAR' | 'SBD' | 'SCR' | 'SEK' | 'SGD' | 'SHP' | 'SLE' | 'SOS' | 'SRD' | 'STD' | 'SZL' | 'THB' | 'TJS' | 'TOP' | 'TRY' | 'TTD' | 'TWD' | 'TZS' | 'UAH' | 'UGX' | 'UYU' | 'UZS' | 'VND' | 'VUV' | 'WST' | 'XAF' | 'XCD' | 'XOF' | 'XPF' | 'YER' | 'ZAR' | 'ZMW'; /** * Whether or not this price is the default price. For product prices, this * indicates the default price for that product. For usage prices, this indicates * the default price for that usage meter. */ isDefault: boolean; livemode: boolean; name: string | null; pricingModelId: string; /** * The product this price belongs to. Required for single payment prices. */ productId: string; slug: string | null; type: 'single_payment'; /** * The price per unit. This should be in the smallest unit of the currency. For * example, if the currency is USD, GBP, CAD, EUR or SGD, the price should be in * cents. */ unitPrice: number; /** * Epoch milliseconds. */ updatedAt: number; /** * Omitted. */ intervalCount?: null; /** * Omitted. */ intervalUnit?: null; /** * Omitted. */ trialPeriodDays?: null; /** * Omitted. */ usageEventsPerUnit?: null; /** * Omitted. */ usageMeterId?: null; } export interface SubscriptionPriceClientSelectSchema { id: string; active: boolean; /** * Epoch milliseconds. */ createdAt: number; /** * Currency code */ currency: | 'USD' | 'AED' | 'AFN' | 'ALL' | 'AMD' | 'ANG' | 'AOA' | 'ARS' | 'AUD' | 'AWG' | 'AZN' | 'BAM' | 'BBD' | 'BDT' | 'BGN' | 'BIF' | 'BMD' | 'BND' | 'BOB' | 'BRL' | 'BSD' | 'BWP' | 'BYN' | 'BZD' | 'CAD' | 'CDF' | 'CHF' | 'CLP' | 'CNY' | 'COP' | 'CRC' | 'CVE' | 'CZK' | 'DJF' | 'DKK' | 'DOP' | 'DZD' | 'EGP' | 'ETB' | 'EUR' | 'FJD' | 'FKP' | 'GBP' | 'GEL' | 'GIP' | 'GMD' | 'GNF' | 'GTQ' | 'GYD' | 'HKD' | 'HNL' | 'HTG' | 'HUF' | 'IDR' | 'ILS' | 'INR' | 'ISK' | 'JMD' | 'JPY' | 'KES' | 'KGS' | 'KHR' | 'KMF' | 'KRW' | 'KYD' | 'KZT' | 'LAK' | 'LBP' | 'LKR' | 'LRD' | 'LSL' | 'MAD' | 'MDL' | 'MGA' | 'MKD' | 'MMK' | 'MNT' | 'MOP' | 'MUR' | 'MVR' | 'MWK' | 'MXN' | 'MYR' | 'MZN' | 'NAD' | 'NGN' | 'NIO' | 'NOK' | 'NPR' | 'NZD' | 'PAB' | 'PEN' | 'PGK' | 'PHP' | 'PKR' | 'PLN' | 'PYG' | 'QAR' | 'RON' | 'RSD' | 'RUB' | 'RWF' | 'SAR' | 'SBD' | 'SCR' | 'SEK' | 'SGD' | 'SHP' | 'SLE' | 'SOS' | 'SRD' | 'STD' | 'SZL' | 'THB' | 'TJS' | 'TOP' | 'TRY' | 'TTD' | 'TWD' | 'TZS' | 'UAH' | 'UGX' | 'UYU' | 'UZS' | 'VND' | 'VUV' | 'WST' | 'XAF' | 'XCD' | 'XOF' | 'XPF' | 'YER' | 'ZAR' | 'ZMW'; /** * A positive integer */ intervalCount: number; intervalUnit: 'day' | 'week' | 'month' | 'year'; /** * Whether or not this price is the default price. For product prices, this * indicates the default price for that product. For usage prices, this indicates * the default price for that usage meter. */ isDefault: boolean; livemode: boolean; name: string | null; pricingModelId: string; /** * The product this price belongs to. Required for subscription prices. */ productId: string; slug: string | null; type: 'subscription'; /** * The price per unit. This should be in the smallest unit of the currency. For * example, if the currency is USD, GBP, CAD, EUR or SGD, the price should be in * cents. */ unitPrice: number; /** * Epoch milliseconds. */ updatedAt: number; /** * Omitted. */ usageEventsPerUnit: null; /** * Omitted. */ usageMeterId: null; /** * The trial period in days. If the trial period is 0 or null, there will be no * trial period. */ trialPeriodDays?: number | null; } export interface UsagePriceClientSelectSchema { id: string; active: boolean; /** * Epoch milliseconds. */ createdAt: number; /** * Currency code */ currency: | 'USD' | 'AED' | 'AFN' | 'ALL' | 'AMD' | 'ANG' | 'AOA' | 'ARS' | 'AUD' | 'AWG' | 'AZN' | 'BAM' | 'BBD' | 'BDT' | 'BGN' | 'BIF' | 'BMD' | 'BND' | 'BOB' | 'BRL' | 'BSD' | 'BWP' | 'BYN' | 'BZD' | 'CAD' | 'CDF' | 'CHF' | 'CLP' | 'CNY' | 'COP' | 'CRC' | 'CVE' | 'CZK' | 'DJF' | 'DKK' | 'DOP' | 'DZD' | 'EGP' | 'ETB' | 'EUR' | 'FJD' | 'FKP' | 'GBP' | 'GEL' | 'GIP' | 'GMD' | 'GNF' | 'GTQ' | 'GYD' | 'HKD' | 'HNL' | 'HTG' | 'HUF' | 'IDR' | 'ILS' | 'INR' | 'ISK' | 'JMD' | 'JPY' | 'KES' | 'KGS' | 'KHR' | 'KMF' | 'KRW' | 'KYD' | 'KZT' | 'LAK' | 'LBP' | 'LKR' | 'LRD' | 'LSL' | 'MAD' | 'MDL' | 'MGA' | 'MKD' | 'MMK' | 'MNT' | 'MOP' | 'MUR' | 'MVR' | 'MWK' | 'MXN' | 'MYR' | 'MZN' | 'NAD' | 'NGN' | 'NIO' | 'NOK' | 'NPR' | 'NZD' | 'PAB' | 'PEN' | 'PGK' | 'PHP' | 'PKR' | 'PLN' | 'PYG' | 'QAR' | 'RON' | 'RSD' | 'RUB' | 'RWF' | 'SAR' | 'SBD' | 'SCR' | 'SEK' | 'SGD' | 'SHP' | 'SLE' | 'SOS' | 'SRD' | 'STD' | 'SZL' | 'THB' | 'TJS' | 'TOP' | 'TRY' | 'TTD' | 'TWD' | 'TZS' | 'UAH' | 'UGX' | 'UYU' | 'UZS' | 'VND' | 'VUV' | 'WST' | 'XAF' | 'XCD' | 'XOF' | 'XPF' | 'YER' | 'ZAR' | 'ZMW'; /** * A positive integer */ intervalCount: number; intervalUnit: 'day' | 'week' | 'month' | 'year'; /** * Whether or not this price is the default price. For product prices, this * indicates the default price for that product. For usage prices, this indicates * the default price for that usage meter. */ isDefault: boolean; livemode: boolean; name: string | null; pricingModelId: string; productId: null; slug: string | null; /** * Omitted. */ trialPeriodDays: null; type: 'usage'; /** * The price per unit. This should be in the smallest unit of the currency. For * example, if the currency is USD, GBP, CAD, EUR or SGD, the price should be in * cents. */ unitPrice: number; /** * Epoch milliseconds. */ updatedAt: number; /** * The number of usage events per unit. Used to determine how to map usage events * to quantities when raising invoices for usage. */ usageEventsPerUnit: number; /** * The usage meter that uses this price. All usage events on that meter must be * associated with a price that is also associated with that usage meter. */ usageMeterId: string; } export interface PriceCreateResponse { price: | SubscriptionPriceClientSelectSchema | SinglePaymentPriceClientSelectSchema | UsagePriceClientSelectSchema; } export interface PriceUpdateResponse { price: | SubscriptionPriceClientSelectSchema | SinglePaymentPriceClientSelectSchema | UsagePriceClientSelectSchema; } export interface PriceListResponse { data: Array< SubscriptionPriceClientSelectSchema | SinglePaymentPriceClientSelectSchema | UsagePriceClientSelectSchema >; hasMore: boolean; total: number; currentCursor?: string; nextCursor?: string; } export interface PriceCreateParams { price: | PriceCreateParams.SubscriptionPriceClientInsertSchema | PriceCreateParams.SinglePaymentPriceClientInsertSchema | PriceCreateParams.UsagePriceClientInsertSchema; } export namespace PriceCreateParams { export interface SubscriptionPriceClientInsertSchema { /** * A positive integer */ intervalCount: number; intervalUnit: 'day' | 'week' | 'month' | 'year'; /** * Whether or not this price is the default price. For product prices, this * indicates the default price for that product. For usage prices, this indicates * the default price for that usage meter. */ isDefault: boolean; /** * The product this price belongs to. Required for subscription prices. */ productId: string; type: 'subscription'; /** * The price per unit. This should be in the smallest unit of the currency. For * example, if the currency is USD, GBP, CAD, EUR or SGD, the price should be in * cents. */ unitPrice: number; active?: boolean; name?: string | null; slug?: string | null; /** * The trial period in days. If the trial period is 0 or null, there will be no * trial period. */ trialPeriodDays?: number | null; /** * Omitted. */ usageEventsPerUnit?: null; /** * Omitted. */ usageMeterId?: null; } export interface SinglePaymentPriceClientInsertSchema { /** * Whether or not this price is the default price. For product prices, this * indicates the default price for that product. For usage prices, this indicates * the default price for that usage meter. */ isDefault: boolean; /** * The product this price belongs to. Required for single payment prices. */ productId: string; type: 'single_payment'; /** * The price per unit. This should be in the smallest unit of the currency. For * example, if the currency is USD, GBP, CAD, EUR or SGD, the price should be in * cents. */ unitPrice: number; active?: boolean; /** * Omitted. */ intervalCount?: null; /** * Omitted. */ intervalUnit?: null; name?: string | null; slug?: string | null; /** * Omitted. */ trialPeriodDays?: null; /** * Omitted. */ usageEventsPerUnit?: null; /** * Omitted. */ usageMeterId?: null; } export interface UsagePriceClientInsertSchema { /** * A positive integer */ intervalCount: number; intervalUnit: 'day' | 'week' | 'month' | 'year'; /** * Whether or not this price is the default price. For product prices, this * indicates the default price for that product. For usage prices, this indicates * the default price for that usage meter. */ isDefault: boolean; type: 'usage'; /** * The price per unit. This should be in the smallest unit of the currency. For * example, if the currency is USD, GBP, CAD, EUR or SGD, the price should be in * cents. */ unitPrice: number; /** * The number of usage events per unit. Used to determine how to map usage events * to quantities when raising invoices for usage. */ usageEventsPerUnit: number; /** * The usage meter that uses this price. All usage events on that meter must be * associated with a price that is also associated with that usage meter. */ usageMeterId: string; active?: boolean; name?: string | null; /** * Omitted. */ productId?: null; slug?: string | null; /** * Omitted. */ trialPeriodDays?: null; } } export interface PriceUpdateParams { price: | PriceUpdateParams.SubscriptionPriceClientUpdateSchema | PriceUpdateParams.SinglePaymentPriceClientUpdateSchema | PriceUpdateParams.UsagePriceClientUpdateSchema; } export namespace PriceUpdateParams { export interface SubscriptionPriceClientUpdateSchema { id: string; /** * Whether or not this price is the default price. For product prices, this * indicates the default price for that product. For usage prices, this indicates * the default price for that usage meter. */ isDefault: boolean; type: 'subscription'; active?: boolean; name?: string | null; slug?: string | null; } export interface SinglePaymentPriceClientUpdateSchema { id: string; /** * Whether or not this price is the default price. For product prices, this * indicates the default price for that product. For usage prices, this indicates * the default price for that usage meter. */ isDefault: boolean; type: 'single_payment'; active?: boolean; name?: string | null; slug?: string | null; } export interface UsagePriceClientUpdateSchema { id: string; /** * Whether or not this price is the default price. For product prices, this * indicates the default price for that product. For usage prices, this indicates * the default price for that usage meter. */ isDefault: boolean; type: 'usage'; active?: boolean; name?: string | null; slug?: string | null; } } export interface PriceListParams { cursor?: string; limit?: string; } export declare namespace Prices { export { type SinglePaymentPriceClientSelectSchema as SinglePaymentPriceClientSelectSchema, type SubscriptionPriceClientSelectSchema as SubscriptionPriceClientSelectSchema, type UsagePriceClientSelectSchema as UsagePriceClientSelectSchema, type PriceCreateResponse as PriceCreateResponse, type PriceUpdateResponse as PriceUpdateResponse, type PriceListResponse as PriceListResponse, type PriceCreateParams as PriceCreateParams, type PriceUpdateParams as PriceUpdateParams, type PriceListParams as PriceListParams, }; }