// 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 { buildHeaders } from '../../../internal/headers'; import { RequestOptions } from '../../../internal/request-options'; /** * Named schedules are used for storing custom data that can change over time. Named schedules are often used in custom pricing logic. */ export class NamedSchedules extends APIResource { /** * Get a named schedule for the given rate card. This endpoint's availability is * dependent on your client's configuration. * * @example * ```ts * const namedSchedule = * await client.v1.contracts.namedSchedules.retrieve({ * rate_card_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', * schedule_name: 'my-schedule', * covering_date: '2022-02-15T00:00:00Z', * }); * ``` */ retrieve( body: NamedScheduleRetrieveParams, options?: RequestOptions, ): APIPromise { return this._client.post('/v1/contract-pricing/rate-cards/getNamedSchedule', { body, ...options }); } /** * Update a named schedule for the given rate card. This endpoint's availability is * dependent on your client's configuration. * * @example * ```ts * await client.v1.contracts.namedSchedules.update({ * rate_card_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', * schedule_name: 'my-schedule', * starting_at: '2022-02-01T00:00:00Z', * value: { my_key: 'my_value' }, * ending_before: '2022-02-15T00:00:00Z', * }); * ``` */ update(body: NamedScheduleUpdateParams, options?: RequestOptions): APIPromise { return this._client.post('/v1/contract-pricing/rate-cards/updateNamedSchedule', { body, ...options, headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), }); } } export interface NamedScheduleRetrieveResponse { data: Array; } export namespace NamedScheduleRetrieveResponse { export interface Data { starting_at: string; value: unknown; ending_before?: string; } } export interface NamedScheduleRetrieveParams { /** * ID of the rate card whose named schedule is to be retrieved */ rate_card_id: string; /** * The identifier for the schedule to be retrieved */ schedule_name: string; /** * If provided, at most one schedule segment will be returned (the one that covers * this date). If not provided, all segments will be returned. */ covering_date?: string; } export interface NamedScheduleUpdateParams { /** * ID of the rate card whose named schedule is to be updated */ rate_card_id: string; /** * The identifier for the schedule to be updated */ schedule_name: string; starting_at: string; /** * The value to set for the named schedule. The structure of this object is * specific to the named schedule. */ value: unknown; ending_before?: string; } export declare namespace NamedSchedules { export { type NamedScheduleRetrieveResponse as NamedScheduleRetrieveResponse, type NamedScheduleRetrieveParams as NamedScheduleRetrieveParams, type NamedScheduleUpdateParams as NamedScheduleUpdateParams, }; }