// 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 Shared from './shared'; 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'; /** * Work locations used by the company */ export class WorkLocations extends APIResource { /** * A list of work locations. * * - Requires: `API Tier 1` * - Sortable fields: `id`, `created_at`, `updated_at` * * @example HTTP * Representative request and response shapes. * ``` * GET /work-locations/?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", * "address": { * "type": "HOME", * "formatted": "string", * "street_address": "string", * "locality": "string", * "region": "string", * "postal_code": "string", * "country": "AF" * } * } * ], * "next_link": "string" * } * ``` */ list( query: WorkLocationListParams | null | undefined = {}, options?: RequestOptions, ): PagePromise { return this._client.getAPIList('/work-locations/', PageCursorURL, { query, ...options }); } /** * Create a new work location * * @example HTTP * Representative request and response shapes. * ``` * POST /work-locations/ HTTP/1.1 * Host: rest.ripplingapis.com * Content-Type: application/json * Accept: application/json * Rippling-Api-Version: 2024-08-01 * * { * "address": {}, * "name": "name" * } * * HTTP/1.1 200 OK * Content-Type: application/json * * { * "id": "string", * "created_at": "string", * "updated_at": "string", * "name": "string", * "address": { * "type": "HOME", * "formatted": "string", * "street_address": "string", * "locality": "string", * "region": "string", * "postal_code": "string", * "country": "AF" * } * } * ``` */ create(body: WorkLocationCreateParams, options?: RequestOptions): APIPromise { return this._client.post('/work-locations/', { body, ...options }); } /** * Retrieve a specific work location * * @example HTTP * Representative request and response shapes. * ``` * GET /work-locations/{id}/ 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, options?: RequestOptions): APIPromise { return this._client.get(path`/work-locations/${id}/`, options); } /** * Update a specific work location. * * @example HTTP * Representative request and response shapes. * ``` * PATCH /work-locations/{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", * "address": { * "type": "HOME", * "formatted": "string", * "street_address": "string", * "locality": "string", * "region": "string", * "postal_code": "string", * "country": "AF" * } * } * ``` */ update( id: string, body: WorkLocationUpdateParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.patch(path`/work-locations/${id}/`, { body, ...options }); } /** * Delete a work location * * @example HTTP * Representative request and response shapes. * ``` * DELETE /work-locations/{id}/ HTTP/1.1 * Host: rest.ripplingapis.com * Rippling-Api-Version: 2024-08-01 * * HTTP/1.1 204 No Content * ``` */ delete(id: string, options?: RequestOptions): APIPromise { return this._client.delete(path`/work-locations/${id}/`, { ...options, headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), }); } } export type WorkLocationsPageCursorURL = PageCursorURL; export interface WorkLocation { /** * Identifier field */ id: string; /** * The address for the work location. */ address: Shared.Address; /** * Record creation date */ created_at: string; /** * The name of the work location. */ name: string; /** * Record update date */ updated_at: string; } /** * Meta information for the response. */ export interface WorkLocationRetrieveResponse extends BusinessPartnersAPI.Meta, WorkLocation {} export interface WorkLocationListParams { cursor?: string; /** * The maximum number of results to return. Defaults to 50. Maximum is 100. */ limit?: number; order_by?: string; } export interface WorkLocationCreateParams { /** * The address for the work location. */ address: WorkLocationCreateParams.Address; /** * The name of the work location. */ name: string; } export namespace WorkLocationCreateParams { /** * The address for the work location. */ export interface Address { /** * The country component, pursuant to SCIM RFC 7643 4.1.2. */ country?: Shared.CountryCode; /** * The city or locality component. */ locality?: string; /** * The zip code or postal code component, pursuant to SCIM RFC 7643 4.1.2. */ postal_code?: string; /** * The state or region component, pursuant to SCIM RFC 7643 4.1.2. */ region?: string; /** * The full street address component, which may include house number, street name, * P.O. box, and multi-line extended street address information, pursuant to SCIM * RFC 7643 4.1.2.. */ street_address?: string; /** * The classification of the address. */ type?: 'HOME' | 'WORK' | 'OTHER'; } } export interface WorkLocationUpdateParams { /** * The address for the work location. */ address?: WorkLocationUpdateParams.Address; /** * The name of the work location. */ name?: string; } export namespace WorkLocationUpdateParams { /** * The address for the work location. */ export interface Address { /** * The country component, pursuant to SCIM RFC 7643 4.1.2. */ country?: Shared.CountryCode; /** * The city or locality component. */ locality?: string; /** * The zip code or postal code component, pursuant to SCIM RFC 7643 4.1.2. */ postal_code?: string; /** * The state or region component, pursuant to SCIM RFC 7643 4.1.2. */ region?: string; /** * The full street address component, which may include house number, street name, * P.O. box, and multi-line extended street address information, pursuant to SCIM * RFC 7643 4.1.2.. */ street_address?: string; /** * The classification of the address. */ type?: 'HOME' | 'WORK' | 'OTHER'; } } export declare namespace WorkLocations { export { type WorkLocation as WorkLocation, type WorkLocationRetrieveResponse as WorkLocationRetrieveResponse, type WorkLocationsPageCursorURL as WorkLocationsPageCursorURL, type WorkLocationListParams as WorkLocationListParams, type WorkLocationCreateParams as WorkLocationCreateParams, type WorkLocationUpdateParams as WorkLocationUpdateParams, }; }