// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; 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'; /** * External earnings inputs for the company */ export class EarningsInputs extends APIResource { /** * A list of earnings-inputs. * * - Requires: `Global Payroll` * * @example HTTP * Representative request and response shapes. * ``` * GET /earnings-inputs/?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", * "run_id": "string", * "worker_id": "string", * "status": "string", * "pay_period_basis_date": "string", * "earning_code": "string", * "assignment_type": "string", * "amount": "string", * "hours": "string", * "earning_start_date": "string", * "earning_end_date": "string", * "time_labels": [ * "string" * ], * "external_id": "string", * "company_entity_id": "string", * "is_overridden": false * } * ], * "next_link": "string" * } * ``` */ list( query: EarningsInputListParams | null | undefined = {}, options?: RequestOptions, ): PagePromise { return this._client.getAPIList('/earnings-inputs/', PageCursorURL, { query, ...options, }); } /** * Create or update earnings-inputs for one worker. Requires Global Payroll admin * write permission for the company and for the target worker. Each earnings line * requires an `external_id`, which identifies the line across requests: resending * a line with the same `external_id` and identical values writes nothing, and * resending it with different values records a new version that replaces the * previous one (last write wins). Retrying a request is therefore safe. There is * no separate idempotency key. * * @example HTTP * Representative request and response shapes. * ``` * POST /earnings-inputs/ 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", * "run_id": "string", * "worker_id": "string", * "status": "string", * "pay_period_basis_date": "string", * "earning_code": "string", * "assignment_type": "string", * "amount": "string", * "hours": "string", * "earning_start_date": "string", * "earning_end_date": "string", * "time_labels": [ * "string" * ], * "external_id": "string", * "company_entity_id": "string", * "is_overridden": false * } * ``` */ create( body: EarningsInputCreateParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.post('/earnings-inputs/', { body, ...options }); } /** * Delete an earnings-input. Requires Global Payroll admin write permission for the * company and for the earnings-input's worker. Deletion is a soft delete: the * earnings-input is removed from payroll and is still returned by * `GET /earnings-inputs/` with `filter=include_deleted eq true`. Deleting it again * returns 404 `PAYROLL_EARNING_INPUT_ALREADY_DELETED`, so a retried delete is safe * to treat as done. An earnings-input on an approved or paid payroll run cannot be * deleted and returns 409 `PAYROLL_EARNING_ALREADY_ASSIGNED`. * * @example HTTP * Representative request and response shapes. * ``` * DELETE /earnings-inputs/{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`/earnings-inputs/${id}/`, { ...options, headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), }); } } export type EarningsInputListResponsesPageCursorURL = PageCursorURL; /** * V2 DTO representing an external earnings input record. * * Used by: * - GET /earnings-inputs/ (list) */ export interface EarningsInputListResponse { /** * Unique identifier for the earnings input. */ id?: string; /** * Earning amount as a string-encoded decimal. */ amount?: string; /** * How the earning is assigned (e.g. BY_PAY_PERIOD). */ assignment_type?: string; /** * Identifier for the legal entity (company entity relationship) this earning is * associated with. Use this to correlate earnings with a specific legal entity in * a multi-entity company. */ company_entity_id?: string; /** * Code identifying the earning type (e.g. regular_salary). */ earning_code?: string; /** * End of the period this earning was earned. Used for regular-rate-of-pay (RROP) * attribution. Distinct from pay_period_basis_date, which selects the pay run. */ earning_end_date?: string; /** * Start of the period this earning was earned. Used for regular-rate-of-pay (RROP) * attribution. Distinct from pay_period_basis_date, which selects the pay run. */ earning_start_date?: string; /** * External reference identifier for this earning. */ external_id?: string; /** * Hours associated with this earning as a string-encoded decimal. */ hours?: string; /** * Whether this earning's amount was manually overridden instead of using the * calculated value. Always false for newly created earnings. */ is_overridden?: boolean; /** * The pay period basis date for this earning. */ pay_period_basis_date?: string; /** * Identifier of the payroll run this earning is assigned to, if any. */ run_id?: string; /** * Current status of the earnings input (e.g. UNASSIGNED, ASSIGNED). */ status?: string; /** * Time tracking labels associated with this earning. */ time_labels?: Array; /** * Identifier of the worker (role ID). */ worker_id?: string; } /** * V2 DTO representing an external earnings input record. * * Used by: * - GET /earnings-inputs/ (list) */ export interface EarningsInputCreateResponse { /** * Unique identifier for the earnings input. */ id?: string; /** * Earning amount as a string-encoded decimal. */ amount?: string; /** * How the earning is assigned (e.g. BY_PAY_PERIOD). */ assignment_type?: string; /** * Identifier for the legal entity (company entity relationship) this earning is * associated with. Use this to correlate earnings with a specific legal entity in * a multi-entity company. */ company_entity_id?: string; /** * Code identifying the earning type (e.g. regular_salary). */ earning_code?: string; /** * End of the period this earning was earned. Used for regular-rate-of-pay (RROP) * attribution. Distinct from pay_period_basis_date, which selects the pay run. */ earning_end_date?: string; /** * Start of the period this earning was earned. Used for regular-rate-of-pay (RROP) * attribution. Distinct from pay_period_basis_date, which selects the pay run. */ earning_start_date?: string; /** * External reference identifier for this earning. */ external_id?: string; /** * Hours associated with this earning as a string-encoded decimal. */ hours?: string; /** * Whether this earning's amount was manually overridden instead of using the * calculated value. Always false for newly created earnings. */ is_overridden?: boolean; /** * The pay period basis date for this earning. */ pay_period_basis_date?: string; /** * Identifier of the payroll run this earning is assigned to, if any. */ run_id?: string; /** * Current status of the earnings input (e.g. UNASSIGNED, ASSIGNED). */ status?: string; /** * Time tracking labels associated with this earning. */ time_labels?: Array; /** * Identifier of the worker (role ID). */ worker_id?: string; } export interface EarningsInputListParams { cursor?: string; /** * The maximum number of results to return. Defaults to 50. Maximum is 100. */ limit?: number; } export interface EarningsInputCreateParams { /** * Earning amount as a string-encoded decimal. */ amount?: string; /** * How the earning is assigned (e.g. BY_PAY_PERIOD). */ assignment_type?: string; /** * Identifier for the legal entity (company entity relationship) this earning is * associated with. Use this to correlate earnings with a specific legal entity in * a multi-entity company. */ company_entity_id?: string; /** * Code identifying the earning type (e.g. regular_salary). */ earning_code?: string; /** * End of the period this earning was earned. Used for regular-rate-of-pay (RROP) * attribution. Distinct from pay_period_basis_date, which selects the pay run. */ earning_end_date?: string; /** * Start of the period this earning was earned. Used for regular-rate-of-pay (RROP) * attribution. Distinct from pay_period_basis_date, which selects the pay run. */ earning_start_date?: string; /** * External reference identifier for this earning. */ external_id?: string; /** * Hours associated with this earning as a string-encoded decimal. */ hours?: string; /** * Whether this earning's amount was manually overridden instead of using the * calculated value. Always false for newly created earnings. */ is_overridden?: boolean; /** * The pay period basis date for this earning. */ pay_period_basis_date?: string; /** * Identifier of the payroll run this earning is assigned to, if any. */ run_id?: string; /** * Current status of the earnings input (e.g. UNASSIGNED, ASSIGNED). */ status?: string; /** * Time tracking labels associated with this earning. */ time_labels?: Array; /** * Identifier of the worker (role ID). */ worker_id?: string; } export declare namespace EarningsInputs { export { type EarningsInputListResponse as EarningsInputListResponse, type EarningsInputCreateResponse as EarningsInputCreateResponse, type EarningsInputListResponsesPageCursorURL as EarningsInputListResponsesPageCursorURL, type EarningsInputListParams as EarningsInputListParams, type EarningsInputCreateParams as EarningsInputCreateParams, }; }