// 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 JobPayRateExceptionsAPI from './job-pay-rate-exceptions'; 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 JobAssignments extends APIResource { /** * A list of job assignments. * * - Requires: `API Tier 2` * - Filterable fields: `worker_id`, `job_code_id` * - Expandable fields: `worker`, `job_code`, `job_pay_rate_exceptions` * - Sortable fields: `id`, `created_at`, `updated_at` */ list( query: JobAssignmentListParams | null | undefined = {}, options?: RequestOptions, ): PagePromise { return this._client.getAPIList('/job-assignments/', PageCursorURL, { query, ...options }); } /** * Create a new job assignment */ create(body: JobAssignmentCreateParams, options?: RequestOptions): APIPromise { return this._client.post('/job-assignments/', { body, ...options }); } /** * Retrieve a specific job assignment */ retrieve( id: string, query: JobAssignmentRetrieveParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.get(path`/job-assignments/${id}/`, { query, ...options }); } /** * Update a specific job assignment. */ update(id: string, body: JobAssignmentUpdateParams, options?: RequestOptions): APIPromise { return this._client.patch(path`/job-assignments/${id}/`, { body, ...options }); } /** * Delete a job assignment */ delete( id: string, body: JobAssignmentDeleteParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.delete(path`/job-assignments/${id}/`, { body, ...options, headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), }); } /** * A list of attribute change logs. * * - Requires: `API Tier 2` * - Expandable fields: `changed_by_worker` * - Sortable fields: `id` */ listChangeLog( jobAssignmentID: string, query: JobAssignmentListChangeLogParams | null | undefined = {}, options?: RequestOptions, ): PagePromise { return this._client.getAPIList( path`/job-assignments/${jobAssignmentID}/change-log/`, PageCursorURL, { query, ...options }, ); } } export type JobAssignmentsPageCursorURL = PageCursorURL; export type AttributeChangeDetailsPageCursorURL = PageCursorURL; export interface AttributeChangeDetails { /** * Identifier field */ id: string; /** * List of attributes that were modified as part of the change. */ attribute_changes?: Array; /** * Worker who made the change * * Expandable field */ changed_by_worker?: WorkersAPI.Worker; /** * Identifier of worker who made the change */ changed_by_worker_id?: string; /** * The time the change was requested by worker */ created_at?: string; /** * The time the change was scheduled to take effect on */ effective_from_date?: string; /** * Reason provided by worker for making the change */ reason?: string; /** * The time the change was applied */ updated_at?: string; } export namespace AttributeChangeDetails { export interface AttributeChange { /** * The name of attribute changed. */ attribute_name?: string; /** * New value of attribute, after the change */ new_attribute_value?: unknown; /** * Old value of attribute, before the change. */ old_attribute_value?: unknown; } } export interface JobAssignment { /** * Identifier field */ id: string; /** * Record creation date */ created_at: string; /** * Identifier of job that is assigned to worker */ job_code_id: string; /** * Record update date */ updated_at: string; /** * Identifier of worker to whom job is assigned. */ worker_id: string; /** * Base compensation rate of worker */ base_pay_rate?: number; /** * Job that is assigned to worker * * Expandable field */ job_code?: JobCodesAPI.JobCode; /** * The pay rate for job assigned to worker. This can be different from the job's * standard pay rate and can be overriden for a worker. */ job_pay_rate?: number; /** * Pay rate exceptions applicable for the worker based on certain exception * dimension values. * * Expandable field */ job_pay_rate_exceptions?: Array; /** * Identifier of pay rate exceptions applicable for the worker based on certain * exception dimension values. */ job_pay_rate_exceptions_id?: Array; /** * Worker to whom job is assigned. * * Expandable field */ worker?: WorkersAPI.Worker; } /** * Meta information for the response. */ export interface JobAssignmentRetrieveResponse extends BusinessPartnersAPI.Meta, JobAssignment {} export interface JobAssignmentListParams { cursor?: string; expand?: string; filter?: string; order_by?: string; } export interface JobAssignmentCreateParams { /** * Identifier of job that is assigned to worker */ job_code_id: string; /** * Identifier of worker to whom job is assigned. */ worker_id: string; /** * Reason recorded on the change (e.g., the reason for scheduling an unassignment). */ change_reason?: string; /** * Date and time the change becomes effective (ISO 8601 format, e.g., * 2025-11-07T17:00:00.000+00:00); defaults to current time in UTC if not provided. * job_pay_rate_effective_from is ignored if this field is provided. */ effective_from?: string; /** * The pay rate for job assigned to worker. This can be different from the job's * standard pay rate and can be overriden for a worker. */ job_pay_rate?: number; /** * This field is deprecated and will be removed in a future version, use the new * change_reason field instead. */ job_pay_rate_change_reason?: string; /** * This field is deprecated and will be removed in a future version, use the new * effective_from field instead. */ job_pay_rate_effective_from?: string; } export interface JobAssignmentRetrieveParams { expand?: string; } export interface JobAssignmentUpdateParams { /** * Identifier of job that is assigned to worker */ job_code_id: string; /** * Identifier of worker to whom job is assigned. */ worker_id: string; /** * Reason recorded on the change (e.g., the reason for scheduling an unassignment). */ change_reason?: string; /** * Date and time the change becomes effective (ISO 8601 format, e.g., * 2025-11-07T17:00:00.000+00:00); defaults to current time in UTC if not provided. * job_pay_rate_effective_from is ignored if this field is provided. */ effective_from?: string; /** * The pay rate for job assigned to worker. This can be different from the job's * standard pay rate and can be overriden for a worker. */ job_pay_rate?: number; /** * This field is deprecated and will be removed in a future version, use the new * change_reason field instead. */ job_pay_rate_change_reason?: string; /** * This field is deprecated and will be removed in a future version, use the new * effective_from field instead. */ job_pay_rate_effective_from?: string; } export interface JobAssignmentDeleteParams { /** * Reason recorded on the scheduled unassignment. */ change_reason?: string; /** * Date and time the unassignment becomes effective (ISO 8601 format, e.g., * 2025-11-07T17:00:00.000+00:00). When provided, schedules a future unassignment * instead of deleting the job assignment immediately. */ effective_from?: string; } export interface JobAssignmentListChangeLogParams { cursor?: string; expand?: string; order_by?: string; } export declare namespace JobAssignments { export { type AttributeChangeDetails as AttributeChangeDetails, type JobAssignment as JobAssignment, type JobAssignmentRetrieveResponse as JobAssignmentRetrieveResponse, type JobAssignmentsPageCursorURL as JobAssignmentsPageCursorURL, type AttributeChangeDetailsPageCursorURL as AttributeChangeDetailsPageCursorURL, type JobAssignmentListParams as JobAssignmentListParams, type JobAssignmentCreateParams as JobAssignmentCreateParams, type JobAssignmentRetrieveParams as JobAssignmentRetrieveParams, type JobAssignmentUpdateParams as JobAssignmentUpdateParams, type JobAssignmentDeleteParams as JobAssignmentDeleteParams, type JobAssignmentListChangeLogParams as JobAssignmentListChangeLogParams, }; }