// 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 LeaveTypesAPI from './leave-types'; 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'; /** * Leave requests submitted by workers */ export class LeaveRequests extends APIResource { /** * A list of leave requests. * * - Requires: `API Tier 2` * - Filterable fields: `worker_id`, `requester_id`, `reviewer_id`, `status`, * `leave_policy_id`, `leave_type_id`, `start_date`, `end_date` * - Expandable fields: `worker`, `requester`, `leave_type`, `reviewer` * - Sortable fields: `id`, `created_at`, `updated_at` */ list( query: LeaveRequestListParams | null | undefined = {}, options?: RequestOptions, ): PagePromise { return this._client.getAPIList('/leave-requests/', PageCursorURL, { query, ...options, }); } /** * Create a new leave request */ create(body: LeaveRequestCreateParams, options?: RequestOptions): APIPromise { return this._client.post('/leave-requests/', { body, ...options }); } /** * Retrieve a specific leave request */ retrieve( id: string, query: LeaveRequestRetrieveParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.get(path`/leave-requests/${id}/`, { query, ...options }); } /** * Update a specific leave request. */ update( id: string, body: LeaveRequestUpdateParams, options?: RequestOptions, ): APIPromise { return this._client.patch(path`/leave-requests/${id}/`, { body, ...options }); } } export type LeaveRequestListResponsesPageCursorURL = PageCursorURL; export interface LeaveRequest { /** * The end date of the leave request. */ end_date: string; /** * The start date of the leave request. */ start_date: string; /** * The status of the leave request. */ status: 'PENDING' | 'APPROVED' | 'REJECTED' | 'CANCELED'; /** * The ID of the worker associated with the leave request. */ worker_id: string; /** * The comments associated with the leave request. */ comments?: string; /** * The number of hours to take off on the end date. */ end_date_custom_hours?: number; /** * The end time of the leave request. */ end_time?: string; /** * The ID of the leave event associated with the leave request, if any. */ leave_event_id?: string; /** * The ID of the leave policy associated with the leave request, either * leave_policy_id or leave_type_id must be provided. */ leave_policy_id?: string; /** * The ID of the leave type associated with the leave request, either * leave_policy_id or leave_type_id must be provided. */ leave_type_id?: string; /** * The reason for the leave request. */ reason_for_leave?: string; /** * The ID of the worker who requested the leave request. */ requester_id?: string; /** * The timestamp of when the leave request was reviewed. */ reviewed_at?: string; /** * The ID of the worker who reviewed the leave request. */ reviewer_id?: string; /** * The number of hours to take off on the start date. */ start_date_custom_hours?: number; /** * The start time of the leave request. */ start_time?: string; } export interface LeaveRequestListResponse { /** * Identifier field */ id: string; /** * Record creation date */ created_at: string; /** * The end date of the leave request. */ end_date: string; /** * The start date of the leave request. */ start_date: string; /** * The status of the leave request. */ status: 'PENDING' | 'APPROVED' | 'REJECTED' | 'CANCELED'; /** * Record update date */ updated_at: string; /** * The ID of the worker associated with the leave request. */ worker_id: string; /** * The comments associated with the leave request. */ comments?: string; /** * The specific dates taken off and the amount of time taken off for each one. */ days_take_off?: Array; /** * The end time of the leave request. */ end_time?: string; /** * Whether the leave request is managed by an external system. */ is_managed_by_external_system?: boolean; /** * The ID of the leave event associated with the leave request, if any. */ leave_event_id?: string; /** * The ID of the leave policy associated with the leave request, either * leave_policy_id or leave_type_id must be provided. */ leave_policy_id?: string; /** * The leave type associated with the leave request. * * Expandable field */ leave_type?: LeaveTypesAPI.LeaveType; /** * The ID of the leave type associated with the leave request, either * leave_policy_id or leave_type_id must be provided. */ leave_type_id?: string; /** * The number of minutes requested for the leave request. */ number_of_minutes_requested?: number; /** * The reason for the leave request. */ reason_for_leave?: string; /** * The worker who requested the leave request. * * Expandable field */ requester?: WorkersAPI.Worker; /** * The ID of the worker who requested the leave request. */ requester_id?: string; /** * The timestamp of when the leave request was reviewed. */ reviewed_at?: string; /** * The worker who reviewed the leave request. * * Expandable field */ reviewer?: WorkersAPI.Worker; /** * The ID of the worker who reviewed the leave request. */ reviewer_id?: string; /** * The start time of the leave request. */ start_time?: string; /** * The worker associated with the leave request. * * Expandable field */ worker?: WorkersAPI.Worker; } export namespace LeaveRequestListResponse { export interface DaysTakeOff { /** * The date of the day off. */ date: string; /** * The number of minutes taken off for the day. */ number_of_minutes_taken_off: number; } } export interface LeaveRequestCreateResponse { /** * Identifier field */ id: string; /** * Record creation date */ created_at: string; /** * The end date of the leave request. */ end_date: string; /** * The start date of the leave request. */ start_date: string; /** * The status of the leave request. */ status: 'PENDING' | 'APPROVED' | 'REJECTED' | 'CANCELED'; /** * Record update date */ updated_at: string; /** * The ID of the worker associated with the leave request. */ worker_id: string; /** * The comments associated with the leave request. */ comments?: string; /** * The specific dates taken off and the amount of time taken off for each one. */ days_take_off?: Array; /** * The end time of the leave request. */ end_time?: string; /** * Whether the leave request is managed by an external system. */ is_managed_by_external_system?: boolean; /** * The ID of the leave event associated with the leave request, if any. */ leave_event_id?: string; /** * The ID of the leave policy associated with the leave request, either * leave_policy_id or leave_type_id must be provided. */ leave_policy_id?: string; /** * The leave type associated with the leave request. * * Expandable field */ leave_type?: LeaveTypesAPI.LeaveType; /** * The ID of the leave type associated with the leave request, either * leave_policy_id or leave_type_id must be provided. */ leave_type_id?: string; /** * The number of minutes requested for the leave request. */ number_of_minutes_requested?: number; /** * The reason for the leave request. */ reason_for_leave?: string; /** * The worker who requested the leave request. * * Expandable field */ requester?: WorkersAPI.Worker; /** * The ID of the worker who requested the leave request. */ requester_id?: string; /** * The timestamp of when the leave request was reviewed. */ reviewed_at?: string; /** * The worker who reviewed the leave request. * * Expandable field */ reviewer?: WorkersAPI.Worker; /** * The ID of the worker who reviewed the leave request. */ reviewer_id?: string; /** * The start time of the leave request. */ start_time?: string; /** * The worker associated with the leave request. * * Expandable field */ worker?: WorkersAPI.Worker; } export namespace LeaveRequestCreateResponse { export interface DaysTakeOff { /** * The date of the day off. */ date: string; /** * The number of minutes taken off for the day. */ number_of_minutes_taken_off: number; } } /** * Meta information for the response. */ export interface LeaveRequestRetrieveResponse extends BusinessPartnersAPI.Meta { /** * Identifier field */ id: string; /** * Record creation date */ created_at: string; /** * The end date of the leave request. */ end_date: string; /** * The start date of the leave request. */ start_date: string; /** * The status of the leave request. */ status: 'PENDING' | 'APPROVED' | 'REJECTED' | 'CANCELED'; /** * Record update date */ updated_at: string; /** * The ID of the worker associated with the leave request. */ worker_id: string; /** * The comments associated with the leave request. */ comments?: string; /** * The specific dates taken off and the amount of time taken off for each one. */ days_take_off?: Array; /** * The end time of the leave request. */ end_time?: string; /** * Whether the leave request is managed by an external system. */ is_managed_by_external_system?: boolean; /** * The ID of the leave event associated with the leave request, if any. */ leave_event_id?: string; /** * The ID of the leave policy associated with the leave request, either * leave_policy_id or leave_type_id must be provided. */ leave_policy_id?: string; /** * The leave type associated with the leave request. * * Expandable field */ leave_type?: LeaveTypesAPI.LeaveType; /** * The ID of the leave type associated with the leave request, either * leave_policy_id or leave_type_id must be provided. */ leave_type_id?: string; /** * The number of minutes requested for the leave request. */ number_of_minutes_requested?: number; /** * The reason for the leave request. */ reason_for_leave?: string; /** * The worker who requested the leave request. * * Expandable field */ requester?: WorkersAPI.Worker; /** * The ID of the worker who requested the leave request. */ requester_id?: string; /** * The timestamp of when the leave request was reviewed. */ reviewed_at?: string; /** * The worker who reviewed the leave request. * * Expandable field */ reviewer?: WorkersAPI.Worker; /** * The ID of the worker who reviewed the leave request. */ reviewer_id?: string; /** * The start time of the leave request. */ start_time?: string; /** * The worker associated with the leave request. * * Expandable field */ worker?: WorkersAPI.Worker; } export namespace LeaveRequestRetrieveResponse { export interface DaysTakeOff { /** * The date of the day off. */ date: string; /** * The number of minutes taken off for the day. */ number_of_minutes_taken_off: number; } } export interface LeaveRequestUpdateResponse { /** * Identifier field */ id: string; /** * Record creation date */ created_at: string; /** * The end date of the leave request. */ end_date: string; /** * The start date of the leave request. */ start_date: string; /** * The status of the leave request. */ status: 'PENDING' | 'APPROVED' | 'REJECTED' | 'CANCELED'; /** * Record update date */ updated_at: string; /** * The ID of the worker associated with the leave request. */ worker_id: string; /** * The comments associated with the leave request. */ comments?: string; /** * The specific dates taken off and the amount of time taken off for each one. */ days_take_off?: Array; /** * The end time of the leave request. */ end_time?: string; /** * Whether the leave request is managed by an external system. */ is_managed_by_external_system?: boolean; /** * The ID of the leave event associated with the leave request, if any. */ leave_event_id?: string; /** * The ID of the leave policy associated with the leave request, either * leave_policy_id or leave_type_id must be provided. */ leave_policy_id?: string; /** * The leave type associated with the leave request. * * Expandable field */ leave_type?: LeaveTypesAPI.LeaveType; /** * The ID of the leave type associated with the leave request, either * leave_policy_id or leave_type_id must be provided. */ leave_type_id?: string; /** * The number of minutes requested for the leave request. */ number_of_minutes_requested?: number; /** * The reason for the leave request. */ reason_for_leave?: string; /** * The worker who requested the leave request. * * Expandable field */ requester?: WorkersAPI.Worker; /** * The ID of the worker who requested the leave request. */ requester_id?: string; /** * The timestamp of when the leave request was reviewed. */ reviewed_at?: string; /** * The worker who reviewed the leave request. * * Expandable field */ reviewer?: WorkersAPI.Worker; /** * The ID of the worker who reviewed the leave request. */ reviewer_id?: string; /** * The start time of the leave request. */ start_time?: string; /** * The worker associated with the leave request. * * Expandable field */ worker?: WorkersAPI.Worker; } export namespace LeaveRequestUpdateResponse { export interface DaysTakeOff { /** * The date of the day off. */ date: string; /** * The number of minutes taken off for the day. */ number_of_minutes_taken_off: number; } } export interface LeaveRequestListParams { cursor?: string; expand?: string; filter?: string; order_by?: string; } export interface LeaveRequestCreateParams { /** * The end date of the leave request. */ end_date: string; /** * The start date of the leave request. */ start_date: string; /** * The status of the leave request. */ status: 'PENDING' | 'APPROVED' | 'REJECTED' | 'CANCELED'; /** * The ID of the worker associated with the leave request. */ worker_id: string; /** * The comments associated with the leave request. */ comments?: string; /** * The number of hours to take off on the end date. */ end_date_custom_hours?: number; /** * The end time of the leave request. */ end_time?: string; /** * The ID of the leave event associated with the leave request, if any. */ leave_event_id?: string; /** * The ID of the leave policy associated with the leave request, either * leave_policy_id or leave_type_id must be provided. */ leave_policy_id?: string; /** * The ID of the leave type associated with the leave request, either * leave_policy_id or leave_type_id must be provided. */ leave_type_id?: string; /** * The reason for the leave request. */ reason_for_leave?: string; /** * The ID of the worker who requested the leave request. */ requester_id?: string; /** * The timestamp of when the leave request was reviewed. */ reviewed_at?: string; /** * The ID of the worker who reviewed the leave request. */ reviewer_id?: string; /** * The number of hours to take off on the start date. */ start_date_custom_hours?: number; /** * The start time of the leave request. */ start_time?: string; } export interface LeaveRequestRetrieveParams { expand?: string; } export interface LeaveRequestUpdateParams { /** * The end date of the leave request. */ end_date: string; /** * The start date of the leave request. */ start_date: string; /** * The status of the leave request. */ status: 'PENDING' | 'APPROVED' | 'REJECTED' | 'CANCELED'; /** * The ID of the worker associated with the leave request. */ worker_id: string; /** * The comments associated with the leave request. */ comments?: string; /** * The number of hours to take off on the end date. */ end_date_custom_hours?: number; /** * The end time of the leave request. */ end_time?: string; /** * The ID of the leave event associated with the leave request, if any. */ leave_event_id?: string; /** * The ID of the leave policy associated with the leave request, either * leave_policy_id or leave_type_id must be provided. */ leave_policy_id?: string; /** * The ID of the leave type associated with the leave request, either * leave_policy_id or leave_type_id must be provided. */ leave_type_id?: string; /** * The reason for the leave request. */ reason_for_leave?: string; /** * The ID of the worker who requested the leave request. */ requester_id?: string; /** * The timestamp of when the leave request was reviewed. */ reviewed_at?: string; /** * The ID of the worker who reviewed the leave request. */ reviewer_id?: string; /** * The number of hours to take off on the start date. */ start_date_custom_hours?: number; /** * The start time of the leave request. */ start_time?: string; } export declare namespace LeaveRequests { export { type LeaveRequest as LeaveRequest, type LeaveRequestListResponse as LeaveRequestListResponse, type LeaveRequestCreateResponse as LeaveRequestCreateResponse, type LeaveRequestRetrieveResponse as LeaveRequestRetrieveResponse, type LeaveRequestUpdateResponse as LeaveRequestUpdateResponse, type LeaveRequestListResponsesPageCursorURL as LeaveRequestListResponsesPageCursorURL, type LeaveRequestListParams as LeaveRequestListParams, type LeaveRequestCreateParams as LeaveRequestCreateParams, type LeaveRequestRetrieveParams as LeaveRequestRetrieveParams, type LeaveRequestUpdateParams as LeaveRequestUpdateParams, }; }