// 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 { PageCursorURL, PagePromise } from '../core/pagination'; import { RequestOptions } from '../internal/request-options'; import { path } from '../internal/utils/path'; /** * Shift assignments assigned to workers */ export class Shiftassignments extends APIResource { /** * A list of shift assignments. * * - Requires: `API Tier 2` * - Filterable fields: `worker_id`, `schedule_id`, `shift_data.start_time`, * `shift_data.end_time` * - Expandable fields: `worker`, `schedule` * - Sortable fields: `id`, `created_at`, `updated_at` */ list( query: ShiftassignmentListParams | null | undefined = {}, options?: RequestOptions, ): PagePromise { return this._client.getAPIList('/shiftassignments/', PageCursorURL, { query, ...options, }); } /** * Create a new shift assignment */ create( body: ShiftassignmentCreateParams, options?: RequestOptions, ): APIPromise { return this._client.post('/shiftassignments/', { body, ...options }); } /** * Retrieve a specific shift assignment */ retrieve( id: string, query: ShiftassignmentRetrieveParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.get(path`/shiftassignments/${id}/`, { query, ...options }); } /** * Update a specific shift assignment. */ update( id: string, body: ShiftassignmentUpdateParams, options?: RequestOptions, ): APIPromise { return this._client.patch(path`/shiftassignments/${id}/`, { body, ...options }); } } export type ShiftassignmentListResponsesPageCursorURL = PageCursorURL; export interface ShiftassignmentListResponse { /** * Identifier field */ id: string; /** * Record creation date */ created_at: string; /** * Whether the shift assignment is published. If true, the published_version will * be the same as the shift_data */ is_published: boolean; /** * The ID of the schedule */ schedule_id: string; /** * The data of the shift */ shift_data: ShiftassignmentListResponse.ShiftData; /** * Record update date */ updated_at: string; /** * The ID of the worker. Empty string '' to unassign if shift is from an open/empty * shift. */ worker_id: string; /** * Whether the shift assignment can be edited */ can_edit?: boolean; /** * Custom fields for the shift assignment */ custom_fields?: Array; /** * The published version of the shift assignment, if it exists. If filled but * is_published is false, the shift_data is the latest version. */ published_version?: ShiftassignmentListResponse.PublishedVersion; /** * The schedule * * Expandable field */ schedule?: ShiftassignmentListResponse.Schedule; /** * The worker * * Expandable field */ worker?: WorkersAPI.Worker; } export namespace ShiftassignmentListResponse { /** * 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 assignment, if it exists. If filled but * is_published is false, the shift_data is the latest version. */ 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 ShiftassignmentCreateResponse { /** * Identifier field */ id: string; /** * Record creation date */ created_at: string; /** * Whether the shift assignment is published. If true, the published_version will * be the same as the shift_data */ is_published: boolean; /** * The ID of the schedule */ schedule_id: string; /** * The data of the shift */ shift_data: ShiftassignmentCreateResponse.ShiftData; /** * Record update date */ updated_at: string; /** * The ID of the worker. Empty string '' to unassign if shift is from an open/empty * shift. */ worker_id: string; /** * Whether the shift assignment can be edited */ can_edit?: boolean; /** * Custom fields for the shift assignment */ custom_fields?: Array; /** * The published version of the shift assignment, if it exists. If filled but * is_published is false, the shift_data is the latest version. */ published_version?: ShiftassignmentCreateResponse.PublishedVersion; /** * The schedule * * Expandable field */ schedule?: ShiftassignmentCreateResponse.Schedule; /** * The worker * * Expandable field */ worker?: WorkersAPI.Worker; } export namespace ShiftassignmentCreateResponse { /** * 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 assignment, if it exists. If filled but * is_published is false, the shift_data is the latest version. */ 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; } } } /** * Meta information for the response. */ export interface ShiftassignmentRetrieveResponse extends BusinessPartnersAPI.Meta { /** * Identifier field */ id: string; /** * Record creation date */ created_at: string; /** * Whether the shift assignment is published. If true, the published_version will * be the same as the shift_data */ is_published: boolean; /** * The ID of the schedule */ schedule_id: string; /** * The data of the shift */ shift_data: ShiftassignmentRetrieveResponse.ShiftData; /** * Record update date */ updated_at: string; /** * The ID of the worker. Empty string '' to unassign if shift is from an open/empty * shift. */ worker_id: string; /** * Whether the shift assignment can be edited */ can_edit?: boolean; /** * Custom fields for the shift assignment */ custom_fields?: Array; /** * The published version of the shift assignment, if it exists. If filled but * is_published is false, the shift_data is the latest version. */ published_version?: ShiftassignmentRetrieveResponse.PublishedVersion; /** * The schedule * * Expandable field */ schedule?: ShiftassignmentRetrieveResponse.Schedule; /** * The worker * * Expandable field */ worker?: WorkersAPI.Worker; } export namespace ShiftassignmentRetrieveResponse { /** * 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 assignment, if it exists. If filled but * is_published is false, the shift_data is the latest version. */ 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 ShiftassignmentUpdateResponse { /** * Identifier field */ id: string; /** * Record creation date */ created_at: string; /** * Whether the shift assignment is published. If true, the published_version will * be the same as the shift_data */ is_published: boolean; /** * The ID of the schedule */ schedule_id: string; /** * The data of the shift */ shift_data: ShiftassignmentUpdateResponse.ShiftData; /** * Record update date */ updated_at: string; /** * The ID of the worker. Empty string '' to unassign if shift is from an open/empty * shift. */ worker_id: string; /** * Whether the shift assignment can be edited */ can_edit?: boolean; /** * Custom fields for the shift assignment */ custom_fields?: Array; /** * The published version of the shift assignment, if it exists. If filled but * is_published is false, the shift_data is the latest version. */ published_version?: ShiftassignmentUpdateResponse.PublishedVersion; /** * The schedule * * Expandable field */ schedule?: ShiftassignmentUpdateResponse.Schedule; /** * The worker * * Expandable field */ worker?: WorkersAPI.Worker; } export namespace ShiftassignmentUpdateResponse { /** * 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 assignment, if it exists. If filled but * is_published is false, the shift_data is the latest version. */ 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 ShiftassignmentListParams { cursor?: string; expand?: string; filter?: string; order_by?: string; } export interface ShiftassignmentCreateParams { /** * Whether the shift assignment is published. If true, the published_version will * be the same as the shift_data */ is_published: boolean; /** * The ID of the schedule */ schedule_id: string; /** * The data of the shift */ shift_data: ShiftassignmentCreateParams.ShiftData; /** * The ID of the worker. Empty string '' to unassign if shift is from an open/empty * shift. */ worker_id: string; } export namespace ShiftassignmentCreateParams { /** * 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'; } 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 IDs of the job codes associated with the shift segment */ job_codes_id?: Array; } } } export interface ShiftassignmentRetrieveParams { expand?: string; } export interface ShiftassignmentUpdateParams { /** * Whether the shift assignment is published. If true, the published_version will * be the same as the shift_data */ is_published: boolean; /** * The data of the shift */ shift_data: ShiftassignmentUpdateParams.ShiftData; /** * The ID of the worker. Empty string '' to unassign if shift is from an open/empty * shift. */ worker_id: string; } export namespace ShiftassignmentUpdateParams { /** * 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'; } 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 IDs of the job codes associated with the shift segment */ job_codes_id?: Array; } } } export declare namespace Shiftassignments { export { type ShiftassignmentListResponse as ShiftassignmentListResponse, type ShiftassignmentCreateResponse as ShiftassignmentCreateResponse, type ShiftassignmentRetrieveResponse as ShiftassignmentRetrieveResponse, type ShiftassignmentUpdateResponse as ShiftassignmentUpdateResponse, type ShiftassignmentListResponsesPageCursorURL as ShiftassignmentListResponsesPageCursorURL, type ShiftassignmentListParams as ShiftassignmentListParams, type ShiftassignmentCreateParams as ShiftassignmentCreateParams, type ShiftassignmentRetrieveParams as ShiftassignmentRetrieveParams, type ShiftassignmentUpdateParams as ShiftassignmentUpdateParams, }; }