// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; import * as BusinessPartnersAPI from './business-partners'; import * as WorkersAPI from './workers'; import { APIPromise } from '../core/api-promise'; import { RequestOptions } from '../internal/request-options'; import { path } from '../internal/utils/path'; /** * Unassigned shifts that are part of a schedule */ export class UnassignedShifts extends APIResource { /** * Update custom fields for a unassigned shift. The request body should contain a * dictionary mapping custom field names to their values. * * - Requires: `API Tier 2` * * @example * ```ts * const response = * await client.unassignedShifts.updateCustomfields('id'); * ``` */ updateCustomfields( id: string, body: UnassignedShiftUpdateCustomfieldsParams, options?: RequestOptions, ): APIPromise { return this._client.patch(path`/unassignedshifts/${id}/customfields/`, { body, ...options }); } /** * Assign a worker to an unassigned shift (open shift). The shift must be an open * shift and not at capacity. * * - Requires: `API Tier 2` * * @example * ```ts * const response = await client.unassignedShifts.assign( * 'id', * { worker_id: 'worker_id' }, * ); * ``` */ assign( id: string, body: UnassignedShiftAssignParams, options?: RequestOptions, ): APIPromise { return this._client.post(path`/unassignedshifts/${id}/assign/`, { body, ...options }); } } /** * Meta information for the response. */ export interface UnassignedShiftUpdateCustomfieldsResponse extends BusinessPartnersAPI.Meta { /** * Identifier field */ id: string; /** * Record creation date */ created_at: string; /** * Whether the shift is published */ is_published: boolean; /** * The ID of the schedule */ schedule_id: string; /** * The data of the shift */ shift_data: UnassignedShiftUpdateCustomfieldsResponse.ShiftData; /** * The target count of the shift */ target_count: number; /** * Record update date */ updated_at: string; /** * The number of assigned shifts */ assigned_count?: number; /** * The IDs of the assigned shifts that are part of this unassigned shift */ assigned_shift_ids?: Array; /** * Custom fields for the unassigned shift */ custom_fields?: Array; /** * Configuration for an open shift. If present, this is an open shift (workers can * sign up). If absent/None, this is an empty shift (placeholder). */ open_shift_config?: unknown; /** * The published version of the shift */ published_version?: UnassignedShiftUpdateCustomfieldsResponse.PublishedVersion; /** * The schedule * * Expandable field */ schedule?: UnassignedShiftUpdateCustomfieldsResponse.Schedule; } export namespace UnassignedShiftUpdateCustomfieldsResponse { /** * The data of the shift */ export interface ShiftData { /** * The end time of the shift */ end_time: string; /** * The start time of the shift */ start_time: string; /** * Notes for the shift, max length 256 characters */ notes?: string; /** * The breaks of the shift */ shift_breaks?: Array; /** * The segments of the shift */ shift_segments?: Array; } export namespace ShiftData { export interface ShiftBreak { /** * The duration of the shift break in minutes (input only for creation) */ duration_minutes: number; /** * The start time of the shift break */ start_time: string; /** * The type of the shift break */ type: 'MEAL' | 'REST'; /** * The end time of the shift break (calculated from start_time + duration_minutes) */ end_time?: string; } export interface ShiftSegment { /** * The duration of the shift segment in minutes (input only for creation) */ duration_minutes: number; /** * The start time of the shift segment */ start_time: string; /** * The end time of the shift segment (calculated from start_time + * duration_minutes) */ end_time?: string; /** * The IDs of the job codes associated with the shift segment */ job_codes_id?: Array; } } /** * The published version of the shift */ export interface PublishedVersion { /** * The end time of the shift */ end_time: string; /** * The start time of the shift */ start_time: string; /** * Notes for the shift, max length 256 characters */ notes?: string; /** * The breaks of the shift */ shift_breaks?: Array; /** * The segments of the shift */ shift_segments?: Array; } export namespace PublishedVersion { export interface ShiftBreak { /** * The duration of the shift break in minutes (input only for creation) */ duration_minutes: number; /** * The start time of the shift break */ start_time: string; /** * The type of the shift break */ type: 'MEAL' | 'REST'; /** * The end time of the shift break (calculated from start_time + duration_minutes) */ end_time?: string; } export interface ShiftSegment { /** * The duration of the shift segment in minutes (input only for creation) */ duration_minutes: number; /** * The start time of the shift segment */ start_time: string; /** * The end time of the shift segment (calculated from start_time + * duration_minutes) */ end_time?: string; /** * The IDs of the job codes associated with the shift segment */ job_codes_id?: Array; } } /** * The schedule * * Expandable field */ export interface Schedule { /** * Identifier field */ id: string; /** * Record creation date */ created_at: string; /** * Record update date */ updated_at: string; /** * Whether the requesting role can edit the schedule. */ can_edit?: boolean; /** * The managers of the schedule. * * Expandable field */ managers?: Array; /** * The IDs of the managers of the schedule. */ managers_id?: Array; /** * The members of the schedule. * * Expandable field */ members?: Array; /** * The IDs of the members of the schedule. */ members_id?: Array; /** * The name of the schedule. */ name?: string; /** * The observers of the schedule. * * Expandable field */ observers?: Array; /** * The IDs of the observers of the schedule. */ observers_id?: Array; /** * The settings of the schedule. */ settings?: Schedule.Settings; } export namespace Schedule { /** * The settings of the schedule. */ export interface Settings { /** * The IANA timezone identifier for the schedule (e.g., 'America/New_York'). * Accepted values are defined by the tz database, listed here: * https://en.wikipedia.org/wiki/List_of_tz_database_time_zones */ timezone?: string; } } } export interface UnassignedShiftAssignResponse { /** * The current number of assigned workers for this shift */ assigned_count?: number; /** * List of shift assignment IDs for this shift */ assigned_shift_ids?: Array; /** * The ID of the newly created shift assignment */ assignment_id?: string; /** * The target number of workers for this shift */ target_count?: number; } export interface UnassignedShiftUpdateCustomfieldsParams { /** * Example custom field name. Replace with your actual custom field names. */ FieldName1?: string; [k: string]: unknown; } export interface UnassignedShiftAssignParams { /** * The ID of the worker (role) to assign to the shift */ worker_id: string; } export declare namespace UnassignedShifts { export { type UnassignedShiftUpdateCustomfieldsResponse as UnassignedShiftUpdateCustomfieldsResponse, type UnassignedShiftAssignResponse as UnassignedShiftAssignResponse, type UnassignedShiftUpdateCustomfieldsParams as UnassignedShiftUpdateCustomfieldsParams, type UnassignedShiftAssignParams as UnassignedShiftAssignParams, }; }