// 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 balances for workers */ export class LeaveBalances extends APIResource { /** * A list of leave balances. * * - Requires: `API Tier 2` * - Filterable fields: `worker_id`, `leave_type_id` * - Expandable fields: `worker`, `leave_type` * - Sortable fields: `id`, `created_at`, `updated_at` */ list( query: LeaveBalanceListParams | null | undefined = {}, options?: RequestOptions, ): PagePromise { return this._client.getAPIList('/leave-balances/', PageCursorURL, { query, ...options }); } /** * Retrieve a specific leave balance */ retrieve( id: string, query: LeaveBalanceRetrieveParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.get(path`/leave-balances/${id}/`, { query, ...options }); } } export type LeaveBalancesPageCursorURL = PageCursorURL; export interface LeaveBalance { /** * Identifier field */ id: string; /** * Record creation date */ created_at: string; /** * Record update date */ updated_at: string; /** * The ID of the worker associated with the leave balance. */ worker_id: string; /** * The worker's leave balance excluding future leave requests. If the leave balance * is unlimited, this field will be null. */ balance_excluding_future_requests?: number; /** * The worker's leave balance in days excluding future leave requests. If the leave * balance is unlimited, this field will be null. */ balance_excluding_future_requests_in_days?: number; /** * The worker's leave balance including future leave requests. If the leave balance * is unlimited, this field will be null. */ balance_including_future_requests?: number; /** * The worker's leave balance in days including future leave requests. If the leave * balance is unlimited, this field will be null. */ balance_including_future_requests_in_days?: number; /** * Indicates if the leave balance is unlimited. */ is_balance_unlimited?: boolean; /** * The leave type associated with the leave balance. * * Expandable field */ leave_type?: LeaveTypesAPI.LeaveType; /** * The ID of the leave type associated with the leave balance. */ leave_type_id?: string; /** * The worker associated with the leave balance. * * Expandable field */ worker?: WorkersAPI.Worker; } /** * Meta information for the response. */ export interface LeaveBalanceRetrieveResponse extends BusinessPartnersAPI.Meta, LeaveBalance {} export interface LeaveBalanceListParams { cursor?: string; expand?: string; filter?: string; order_by?: string; } export interface LeaveBalanceRetrieveParams { expand?: string; } export declare namespace LeaveBalances { export { type LeaveBalance as LeaveBalance, type LeaveBalanceRetrieveResponse as LeaveBalanceRetrieveResponse, type LeaveBalancesPageCursorURL as LeaveBalancesPageCursorURL, type LeaveBalanceListParams as LeaveBalanceListParams, type LeaveBalanceRetrieveParams as LeaveBalanceRetrieveParams, }; }