// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../../../core/resource'; import * as Shared from '../../../shared'; import { APIPromise } from '../../../../core/api-promise'; import { RequestOptions } from '../../../../internal/request-options'; /** * Rate cards are used to define default pricing for products. */ export class ProductOrders extends APIResource { /** * The ordering of products on a rate card determines the order in which the * products will appear on customers' invoices. Use this endpoint to set the order * of specific products on the rate card by moving them relative to their current * location. * * @example * ```ts * const productOrder = * await client.v1.contracts.rateCards.productOrders.update({ * product_moves: [ * { * product_id: '13117714-3f05-48e5-a6e9-a66093f13b4d', * position: 0, * }, * { * product_id: 'b086f2f4-9851-4466-9ca0-30d53e6a42ac', * position: 1, * }, * ], * rate_card_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', * }); * ``` */ update(body: ProductOrderUpdateParams, options?: RequestOptions): APIPromise { return this._client.post('/v1/contract-pricing/rate-cards/moveRateCardProducts', { body, ...options }); } /** * The ordering of products on a rate card determines the order in which the * products will appear on customers' invoices. Use this endpoint to set the order * of products on the rate card. * * @example * ```ts * const response = * await client.v1.contracts.rateCards.productOrders.set({ * product_order: [ * '13117714-3f05-48e5-a6e9-a66093f13b4d', * 'b086f2f4-9851-4466-9ca0-30d53e6a42ac', * ], * rate_card_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', * }); * ``` */ set(body: ProductOrderSetParams, options?: RequestOptions): APIPromise { return this._client.post('/v1/contract-pricing/rate-cards/setRateCardProductsOrder', { body, ...options, }); } } export interface ProductOrderUpdateResponse { data: Shared.ID; } export interface ProductOrderSetResponse { data: Shared.ID; } export interface ProductOrderUpdateParams { product_moves: Array; /** * ID of the rate card to update */ rate_card_id: string; } export namespace ProductOrderUpdateParams { export interface ProductMove { /** * 0-based index of the new position of the product */ position: number; /** * ID of the product to move */ product_id: string; } } export interface ProductOrderSetParams { product_order: Array; /** * ID of the rate card to update */ rate_card_id: string; } export declare namespace ProductOrders { export { type ProductOrderUpdateResponse as ProductOrderUpdateResponse, type ProductOrderSetResponse as ProductOrderSetResponse, type ProductOrderUpdateParams as ProductOrderUpdateParams, type ProductOrderSetParams as ProductOrderSetParams, }; }