// 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 { APIPromise } from '../core/api-promise'; import { PageCursorURL, PagePromise } from '../core/pagination'; import { RequestOptions } from '../internal/request-options'; import { path } from '../internal/utils/path'; /** * Departments used by the company */ export class Departments extends APIResource { /** * A list of departments. * * - Requires: `API Tier 1` * - Expandable fields: `parent`, `department_hierarchy` * - Sortable fields: `id`, `created_at`, `updated_at` */ list( query: DepartmentListParams | null | undefined = {}, options?: RequestOptions, ): PagePromise { return this._client.getAPIList('/departments/', PageCursorURL, { query, ...options }); } /** * Create a new department */ create(body: DepartmentCreateParams, options?: RequestOptions): APIPromise { return this._client.post('/departments/', { body, ...options }); } /** * Retrieve a specific department */ retrieve( id: string, query: DepartmentRetrieveParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.get(path`/departments/${id}/`, { query, ...options }); } /** * Update a specific department. */ update(id: string, body: DepartmentUpdateParams, options?: RequestOptions): APIPromise { return this._client.patch(path`/departments/${id}/`, { body, ...options }); } } export type DepartmentsPageCursorURL = PageCursorURL; export interface Department { /** * Identifier field */ id: string; /** * Record creation date */ created_at: string; /** * The name of the department. */ name: string; /** * Record update date */ updated_at: string; /** * List of departments in the department hierarchy. Refer department_hierarchy_ids * for department hierarchy order. * * Expandable field */ department_hierarchy?: Array; /** * The identifier of departments in the department hierarchy ordered from parent * department to child department. */ department_hierarchy_id?: Array; /** * The parent department. * * Expandable field */ parent?: Department; /** * The parent department. */ parent_id?: string; /** * Reference code of the department. */ reference_code?: string; } /** * Meta information for the response. */ export interface DepartmentRetrieveResponse extends BusinessPartnersAPI.Meta, Department {} export interface DepartmentListParams { cursor?: string; expand?: string; order_by?: string; } export interface DepartmentCreateParams { /** * The name of the department. */ name: string; /** * The parent department. */ parent_id?: string; /** * Reference code of the department. */ reference_code?: string; } export interface DepartmentRetrieveParams { expand?: string; } export interface DepartmentUpdateParams { /** * The name of the department. */ name: string; /** * The parent department. */ parent_id?: string; /** * Reference code of the department. */ reference_code?: string; } export declare namespace Departments { export { type Department as Department, type DepartmentRetrieveResponse as DepartmentRetrieveResponse, type DepartmentsPageCursorURL as DepartmentsPageCursorURL, type DepartmentListParams as DepartmentListParams, type DepartmentCreateParams as DepartmentCreateParams, type DepartmentRetrieveParams as DepartmentRetrieveParams, type DepartmentUpdateParams as DepartmentUpdateParams, }; }