// 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` * * @example HTTP * Representative request and response shapes. * ``` * GET /departments/?expand=expand&order_by=order_by&limit=50&cursor=cursor HTTP/1.1 * Host: rest.ripplingapis.com * Accept: application/json * Rippling-Api-Version: 2024-08-01 * * HTTP/1.1 200 OK * Content-Type: application/json * * { * "__meta": { * "redacted_fields": [ * { * "name": "date_of_birth", * "reason": "Insufficient entitlements" * } * ] * }, * "results": [ * { * "id": "string", * "created_at": "string", * "updated_at": "string", * "name": "string", * "parent_id": "string", * "parent": { * "id": "string", * "created_at": "string", * "updated_at": "string", * "name": "string", * "parent_id": "string", * "parent": {}, * "reference_code": "string", * "department_hierarchy_id": [], * "department_hierarchy": [] * }, * "reference_code": "string", * "department_hierarchy_id": [ * "string" * ], * "department_hierarchy": [ * {} * ] * } * ], * "next_link": "string" * } * ``` */ list( query: DepartmentListParams | null | undefined = {}, options?: RequestOptions, ): PagePromise { return this._client.getAPIList('/departments/', PageCursorURL, { query, ...options }); } /** * Create a new department * * @example HTTP * Representative request and response shapes. * ``` * POST /departments/ HTTP/1.1 * Host: rest.ripplingapis.com * Content-Type: application/json * Accept: application/json * Rippling-Api-Version: 2024-08-01 * * { * "name": "name" * } * * HTTP/1.1 200 OK * Content-Type: application/json * * { * "id": "string", * "created_at": "string", * "updated_at": "string", * "name": "string", * "parent_id": "string", * "parent": { * "id": "string", * "created_at": "string", * "updated_at": "string", * "name": "string", * "parent_id": "string", * "parent": { * "id": "string", * "created_at": "string", * "updated_at": "string", * "name": "string", * "parent_id": "string", * "parent": { * "id": "string", * "created_at": "string", * "updated_at": "string", * "name": "string", * "parent_id": "string", * "parent": {}, * "reference_code": "string", * "department_hierarchy_id": [], * "department_hierarchy": [] * }, * "reference_code": "string", * "department_hierarchy_id": [ * "string" * ], * "department_hierarchy": [ * {} * ] * }, * "reference_code": "string", * "department_hierarchy_id": [ * "string" * ], * "department_hierarchy": [ * { * "id": "string", * "created_at": "string", * "updated_at": "string", * "name": "string", * "parent_id": "string", * "parent": {}, * "reference_code": "string", * "department_hierarchy_id": [], * "department_hierarchy": [] * } * ] * }, * "reference_code": "string", * "department_hierarchy_id": [ * "string" * ], * "department_hierarchy": [ * { * "id": "string", * "created_at": "string", * "updated_at": "string", * "name": "string", * "parent_id": "string", * "parent": { * "id": "string", * "created_at": "string", * "updated_at": "string", * "name": "string", * "parent_id": "string", * "parent": {}, * "reference_code": "string", * "department_hierarchy_id": [], * "department_hierarchy": [] * }, * "reference_code": "string", * "department_hierarchy_id": [ * "string" * ], * "department_hierarchy": [ * {} * ] * } * ] * } * ``` */ create(body: DepartmentCreateParams, options?: RequestOptions): APIPromise { return this._client.post('/departments/', { body, ...options }); } /** * Retrieve a specific department * * @example HTTP * Representative request and response shapes. * ``` * GET /departments/{id}/?expand=expand HTTP/1.1 * Host: rest.ripplingapis.com * Accept: application/json * Rippling-Api-Version: 2024-08-01 * * HTTP/1.1 200 OK * Content-Type: application/json * * { * "__meta": { * "redacted_fields": [ * {} * ] * } * } * ``` */ retrieve( id: string, query: DepartmentRetrieveParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.get(path`/departments/${id}/`, { query, ...options }); } /** * Update a specific department. * * @example HTTP * Representative request and response shapes. * ``` * PATCH /departments/{id}/ HTTP/1.1 * Host: rest.ripplingapis.com * Content-Type: application/json * Accept: application/json * Rippling-Api-Version: 2024-08-01 * * {} * * HTTP/1.1 200 OK * Content-Type: application/json * * { * "id": "string", * "created_at": "string", * "updated_at": "string", * "name": "string", * "parent_id": "string", * "parent": { * "id": "string", * "created_at": "string", * "updated_at": "string", * "name": "string", * "parent_id": "string", * "parent": { * "id": "string", * "created_at": "string", * "updated_at": "string", * "name": "string", * "parent_id": "string", * "parent": { * "id": "string", * "created_at": "string", * "updated_at": "string", * "name": "string", * "parent_id": "string", * "parent": {}, * "reference_code": "string", * "department_hierarchy_id": [], * "department_hierarchy": [] * }, * "reference_code": "string", * "department_hierarchy_id": [ * "string" * ], * "department_hierarchy": [ * {} * ] * }, * "reference_code": "string", * "department_hierarchy_id": [ * "string" * ], * "department_hierarchy": [ * { * "id": "string", * "created_at": "string", * "updated_at": "string", * "name": "string", * "parent_id": "string", * "parent": {}, * "reference_code": "string", * "department_hierarchy_id": [], * "department_hierarchy": [] * } * ] * }, * "reference_code": "string", * "department_hierarchy_id": [ * "string" * ], * "department_hierarchy": [ * { * "id": "string", * "created_at": "string", * "updated_at": "string", * "name": "string", * "parent_id": "string", * "parent": { * "id": "string", * "created_at": "string", * "updated_at": "string", * "name": "string", * "parent_id": "string", * "parent": {}, * "reference_code": "string", * "department_hierarchy_id": [], * "department_hierarchy": [] * }, * "reference_code": "string", * "department_hierarchy_id": [ * "string" * ], * "department_hierarchy": [ * {} * ] * } * ] * } * ``` */ update( id: string, body: DepartmentUpdateParams | null | undefined = {}, 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; /** * The maximum number of results to return. Defaults to 50. Maximum is 100. */ limit?: number; 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, }; }