// 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 JobCodesAPI from './job-codes'; import * as WorkersAPI from './workers'; import { APIPromise } from '../core/api-promise'; import { PageCursorURL, PagePromise } from '../core/pagination'; import { buildHeaders } from '../internal/headers'; import { RequestOptions } from '../internal/request-options'; import { path } from '../internal/utils/path'; /** * Job related information for the company */ export class WorkerTimeSplits extends APIResource { /** * A list of worker time splits. * * - Requires: `API Tier 2` * - Filterable fields: `worker_id`, `is_enabled`, `updated_at` * - Expandable fields: `worker`, `job_codes` * - Sortable fields: `id`, `created_at`, `updated_at` */ list( query: WorkerTimeSplitListParams | null | undefined = {}, options?: RequestOptions, ): PagePromise { return this._client.getAPIList('/worker-time-splits/', PageCursorURL, { query, ...options, }); } /** * Create a new worker time split */ create( body: WorkerTimeSplitCreateParams, options?: RequestOptions, ): APIPromise { return this._client.post('/worker-time-splits/', { body, ...options }); } /** * Retrieve a specific worker time split */ retrieve( id: string, query: WorkerTimeSplitRetrieveParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.get(path`/worker-time-splits/${id}/`, { query, ...options }); } /** * Update a specific worker time split. */ update( id: string, body: WorkerTimeSplitUpdateParams, options?: RequestOptions, ): APIPromise { return this._client.patch(path`/worker-time-splits/${id}/`, { body, ...options }); } /** * Delete a worker time split */ delete(id: string, options?: RequestOptions): APIPromise { return this._client.delete(path`/worker-time-splits/${id}/`, { ...options, headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), }); } } export type WorkerTimeSplitListResponsesPageCursorURL = PageCursorURL; /** * Worker time split configuration resource. */ export interface WorkerTimeSplitListResponse { /** * Identifier field */ id: string; /** * Record creation date */ created_at: string; /** * Record update date */ updated_at: string; /** * Identifier of the worker whose time split configuration this represents. */ worker_id: string; /** * Whether hard-coded time splits are active for this worker. */ is_enabled?: boolean; /** * The job codes referenced in this time split configuration. Use ?expand=job_codes * to populate. * * Expandable field */ job_codes?: Array; /** * IDs of all unique job codes referenced across all split rows. */ job_codes_id?: Array; /** * The split rows defining time allocation percentages across job codes. Empty when * is_enabled is false. */ splits?: Array; /** * The worker associated with this time split configuration. * * Expandable field */ worker?: WorkersAPI.Worker; } export namespace WorkerTimeSplitListResponse { /** * A single split row representing a percentage allocation across one or more job * codes. */ export interface Split { /** * IDs of canonical /job-codes/ resources in this split row. */ job_code_ids?: Array; /** * Percentage allocated to this split row. Decimal string with precision 2; must be * greater than zero per row. All rows must sum to 100.00 when is_enabled is true. */ split_percentage?: string; } } /** * Worker time split configuration resource. */ export interface WorkerTimeSplitCreateResponse { /** * Identifier field */ id: string; /** * Record creation date */ created_at: string; /** * Record update date */ updated_at: string; /** * Identifier of the worker whose time split configuration this represents. */ worker_id: string; /** * Whether hard-coded time splits are active for this worker. */ is_enabled?: boolean; /** * The job codes referenced in this time split configuration. Use ?expand=job_codes * to populate. * * Expandable field */ job_codes?: Array; /** * IDs of all unique job codes referenced across all split rows. */ job_codes_id?: Array; /** * The split rows defining time allocation percentages across job codes. Empty when * is_enabled is false. */ splits?: Array; /** * The worker associated with this time split configuration. * * Expandable field */ worker?: WorkersAPI.Worker; } export namespace WorkerTimeSplitCreateResponse { /** * A single split row representing a percentage allocation across one or more job * codes. */ export interface Split { /** * IDs of canonical /job-codes/ resources in this split row. */ job_code_ids?: Array; /** * Percentage allocated to this split row. Decimal string with precision 2; must be * greater than zero per row. All rows must sum to 100.00 when is_enabled is true. */ split_percentage?: string; } } /** * Meta information for the response. */ export interface WorkerTimeSplitRetrieveResponse extends BusinessPartnersAPI.Meta { /** * Identifier field */ id: string; /** * Record creation date */ created_at: string; /** * Record update date */ updated_at: string; /** * Identifier of the worker whose time split configuration this represents. */ worker_id: string; /** * Whether hard-coded time splits are active for this worker. */ is_enabled?: boolean; /** * The job codes referenced in this time split configuration. Use ?expand=job_codes * to populate. * * Expandable field */ job_codes?: Array; /** * IDs of all unique job codes referenced across all split rows. */ job_codes_id?: Array; /** * The split rows defining time allocation percentages across job codes. Empty when * is_enabled is false. */ splits?: Array; /** * The worker associated with this time split configuration. * * Expandable field */ worker?: WorkersAPI.Worker; } export namespace WorkerTimeSplitRetrieveResponse { /** * A single split row representing a percentage allocation across one or more job * codes. */ export interface Split { /** * IDs of canonical /job-codes/ resources in this split row. */ job_code_ids?: Array; /** * Percentage allocated to this split row. Decimal string with precision 2; must be * greater than zero per row. All rows must sum to 100.00 when is_enabled is true. */ split_percentage?: string; } } /** * Worker time split configuration resource. */ export interface WorkerTimeSplitUpdateResponse { /** * Identifier field */ id: string; /** * Record creation date */ created_at: string; /** * Record update date */ updated_at: string; /** * Identifier of the worker whose time split configuration this represents. */ worker_id: string; /** * Whether hard-coded time splits are active for this worker. */ is_enabled?: boolean; /** * The job codes referenced in this time split configuration. Use ?expand=job_codes * to populate. * * Expandable field */ job_codes?: Array; /** * IDs of all unique job codes referenced across all split rows. */ job_codes_id?: Array; /** * The split rows defining time allocation percentages across job codes. Empty when * is_enabled is false. */ splits?: Array; /** * The worker associated with this time split configuration. * * Expandable field */ worker?: WorkersAPI.Worker; } export namespace WorkerTimeSplitUpdateResponse { /** * A single split row representing a percentage allocation across one or more job * codes. */ export interface Split { /** * IDs of canonical /job-codes/ resources in this split row. */ job_code_ids?: Array; /** * Percentage allocated to this split row. Decimal string with precision 2; must be * greater than zero per row. All rows must sum to 100.00 when is_enabled is true. */ split_percentage?: string; } } export interface WorkerTimeSplitListParams { cursor?: string; expand?: string; filter?: string; order_by?: string; } export interface WorkerTimeSplitCreateParams { /** * Identifier of the worker whose time split configuration this represents. */ worker_id: string; /** * Whether hard-coded time splits are active for this worker. */ is_enabled?: boolean; /** * The split rows defining time allocation percentages across job codes. Empty when * is_enabled is false. */ splits?: Array; } export namespace WorkerTimeSplitCreateParams { /** * A single split row representing a percentage allocation across one or more job * codes. */ export interface Split { /** * IDs of canonical /job-codes/ resources in this split row. */ job_code_ids?: Array; /** * Percentage allocated to this split row. Decimal string with precision 2; must be * greater than zero per row. All rows must sum to 100.00 when is_enabled is true. */ split_percentage?: string; } } export interface WorkerTimeSplitRetrieveParams { expand?: string; } export interface WorkerTimeSplitUpdateParams { /** * Identifier of the worker whose time split configuration this represents. */ worker_id: string; /** * Whether hard-coded time splits are active for this worker. */ is_enabled?: boolean; /** * The split rows defining time allocation percentages across job codes. Empty when * is_enabled is false. */ splits?: Array; } export namespace WorkerTimeSplitUpdateParams { /** * A single split row representing a percentage allocation across one or more job * codes. */ export interface Split { /** * IDs of canonical /job-codes/ resources in this split row. */ job_code_ids?: Array; /** * Percentage allocated to this split row. Decimal string with precision 2; must be * greater than zero per row. All rows must sum to 100.00 when is_enabled is true. */ split_percentage?: string; } } export declare namespace WorkerTimeSplits { export { type WorkerTimeSplitListResponse as WorkerTimeSplitListResponse, type WorkerTimeSplitCreateResponse as WorkerTimeSplitCreateResponse, type WorkerTimeSplitRetrieveResponse as WorkerTimeSplitRetrieveResponse, type WorkerTimeSplitUpdateResponse as WorkerTimeSplitUpdateResponse, type WorkerTimeSplitListResponsesPageCursorURL as WorkerTimeSplitListResponsesPageCursorURL, type WorkerTimeSplitListParams as WorkerTimeSplitListParams, type WorkerTimeSplitCreateParams as WorkerTimeSplitCreateParams, type WorkerTimeSplitRetrieveParams as WorkerTimeSplitRetrieveParams, type WorkerTimeSplitUpdateParams as WorkerTimeSplitUpdateParams, }; }