/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { paySchedulesAssign } from "../funcs/paySchedulesAssign.js"; import { paySchedulesCreate } from "../funcs/paySchedulesCreate.js"; import { paySchedulesGet } from "../funcs/paySchedulesGet.js"; import { paySchedulesGetAll } from "../funcs/paySchedulesGetAll.js"; import { paySchedulesGetAssignments } from "../funcs/paySchedulesGetAssignments.js"; import { paySchedulesGetPayPeriods } from "../funcs/paySchedulesGetPayPeriods.js"; import { paySchedulesGetPreview } from "../funcs/paySchedulesGetPreview.js"; import { paySchedulesGetUnprocessedTerminationPeriods } from "../funcs/paySchedulesGetUnprocessedTerminationPeriods.js"; import { paySchedulesPreviewAssignment } from "../funcs/paySchedulesPreviewAssignment.js"; import { paySchedulesUpdate } from "../funcs/paySchedulesUpdate.js"; import { ClientSDK, RequestOptions } from "../lib/sdks.js"; import { GetV1CompaniesCompanyIdPayPeriodsRequest, GetV1CompaniesCompanyIdPayPeriodsResponse, } from "../models/operations/getv1companiescompanyidpayperiods.js"; import { GetV1CompaniesCompanyIdPaySchedulesRequest, GetV1CompaniesCompanyIdPaySchedulesResponse, } from "../models/operations/getv1companiescompanyidpayschedules.js"; import { GetV1CompaniesCompanyIdPaySchedulesAssignmentsRequest, GetV1CompaniesCompanyIdPaySchedulesAssignmentsResponse, } from "../models/operations/getv1companiescompanyidpayschedulesassignments.js"; import { GetV1CompaniesCompanyIdPaySchedulesPayScheduleIdRequest, GetV1CompaniesCompanyIdPaySchedulesPayScheduleIdResponse, } from "../models/operations/getv1companiescompanyidpayschedulespayscheduleid.js"; import { GetV1CompaniesCompanyIdPaySchedulesPreviewRequest, GetV1CompaniesCompanyIdPaySchedulesPreviewResponse, } from "../models/operations/getv1companiescompanyidpayschedulespreview.js"; import { GetV1CompaniesCompanyIdUnprocessedTerminationPayPeriodsRequest, GetV1CompaniesCompanyIdUnprocessedTerminationPayPeriodsResponse, } from "../models/operations/getv1companiescompanyidunprocessedterminationpayperiods.js"; import { PostV1CompaniesCompanyIdPaySchedulesRequest, PostV1CompaniesCompanyIdPaySchedulesResponse, } from "../models/operations/postv1companiescompanyidpayschedules.js"; import { PostV1CompaniesCompanyIdPaySchedulesAssignRequest, PostV1CompaniesCompanyIdPaySchedulesAssignResponse, } from "../models/operations/postv1companiescompanyidpayschedulesassign.js"; import { PostV1CompaniesCompanyIdPaySchedulesAssignmentPreviewRequest, PostV1CompaniesCompanyIdPaySchedulesAssignmentPreviewResponse, } from "../models/operations/postv1companiescompanyidpayschedulesassignmentpreview.js"; import { PutV1CompaniesCompanyIdPaySchedulesPayScheduleIdRequest, PutV1CompaniesCompanyIdPaySchedulesPayScheduleIdResponse, } from "../models/operations/putv1companiescompanyidpayschedulespayscheduleid.js"; import { unwrapAsync } from "../types/fp.js"; export class PaySchedules extends ClientSDK { /** * Get the pay schedules for a company * * @remarks * Returns all pay schedules for a company. The pay schedule object captures the details of when employees work and when they should be paid. A company can have multiple pay schedules. * * scope: `pay_schedules:read` */ async getAll( request: GetV1CompaniesCompanyIdPaySchedulesRequest, options?: RequestOptions, ): Promise { return unwrapAsync(paySchedulesGetAll( this, request, options, )); } /** * Create a new pay schedule * * @remarks * If a company does not have any pay schedules, this endpoint will create a single pay schedule and assign it to all employees. This is a common use case during company onboarding. * * If a company has an existing active pay schedule and want to support multiple pay schedules, this endpoint will create a pay schedule that is not assigned to any employee. * * Be sure to **[check state laws](https://www.dol.gov/agencies/whd/state/payday)** to know what schedule is right for your customers. * * > If an onboarded company misses their first pay date, Gusto will automatically adjust the pay schedule to the next available pay date. * * ### Webhooks * - `pay_schedule.created`: Fires when a pay schedule is successfully created. * * ### Related guides * - [Create a pay schedule](doc:create-a-pay-schedule) * - [Pay Schedules](doc:pay-schedule-info) * - [Manage Pay Schedules via API](doc:manage-pay-schedules-api) * * scope: `pay_schedules:write` */ async create( request: PostV1CompaniesCompanyIdPaySchedulesRequest, options?: RequestOptions, ): Promise { return unwrapAsync(paySchedulesCreate( this, request, options, )); } /** * Preview pay schedule dates * * @remarks * Provides a preview of a pay schedule with the specified parameters for the next 18 months. Use this before creating or updating a pay schedule to show expected check dates, pay period boundaries, and payroll deadlines. * * ### Related guides * - [Create a pay schedule](doc:create-a-pay-schedule) * - [Manage Pay Schedules via API](doc:manage-pay-schedules-api) * * scope: `pay_schedules:write` */ async getPreview( request: GetV1CompaniesCompanyIdPaySchedulesPreviewRequest, options?: RequestOptions, ): Promise { return unwrapAsync(paySchedulesGetPreview( this, request, options, )); } /** * Get a pay schedule * * @remarks * Returns a single pay schedule by UUID. The pay schedule object in Gusto captures the details of when employees work and when they should be paid. A company can have multiple pay schedules. * * scope: `pay_schedules:read` */ async get( request: GetV1CompaniesCompanyIdPaySchedulesPayScheduleIdRequest, options?: RequestOptions, ): Promise { return unwrapAsync(paySchedulesGet( this, request, options, )); } /** * Update a pay schedule * * @remarks * Updates a pay schedule. The `version` parameter from the GET response is required for [optimistic concurrency](doc:api-fundamentals); a mismatch returns 409 Conflict. * * ### Effect on payrolls * Updating a pay schedule will delete any unprocessed regular payrolls whose pay period end date is today or in the future. Already-processed payrolls are not affected. * * ### Pay schedules may be automatically adjusted * If an onboarded company misses their first pay date, Gusto will automatically adjust the pay schedule to the next available pay date. * * ### Webhooks * - `pay_schedule.updated`: Fires when a pay schedule is successfully updated. * * ### Related guides * - [Create a pay schedule](doc:create-a-pay-schedule) * - [Manage Pay Schedules via API](doc:manage-pay-schedules-api) * * scope: `pay_schedules:write` */ async update( request: PutV1CompaniesCompanyIdPaySchedulesPayScheduleIdRequest, options?: RequestOptions, ): Promise { return unwrapAsync(paySchedulesUpdate( this, request, options, )); } /** * Get pay periods for a company * * @remarks * Pay periods are the foundation of payroll. Compensation, time & attendance, taxes, and expense reports all rely on when they happened. * * To begin submitting information for a given payroll, we need to agree on the time period. * * By default, this endpoint returns pay periods starting from 6 months ago to the date today. Use the `start_date` and `end_date` parameters to change the scope of the response. End dates can be up to 3 months in the future and there is no limit on start dates. * * Starting in version 2023-04-01, the `eligible_employees` attribute was removed from the response. The eligible employees for a payroll are determined by the employee_compensations returned from the [PUT /v1/companies/{company_id}/payrolls/{payroll_id}/prepare](ref:put-v1-companies-company_id-payrolls-payroll_id-prepare) endpoint. * * scope: `payrolls:read` */ async getPayPeriods( request: GetV1CompaniesCompanyIdPayPeriodsRequest, options?: RequestOptions, ): Promise { return unwrapAsync(paySchedulesGetPayPeriods( this, request, options, )); } /** * Get termination pay periods for a company * * @remarks * When a payroll admin terminates an employee and selects "Dismissal Payroll" as the employee's final payroll, their last pay period will appear on the list. * * This endpoint returns the unprocessed pay periods for past and future terminated employees in a given company. * * scope: `payrolls:read` */ async getUnprocessedTerminationPeriods( request: GetV1CompaniesCompanyIdUnprocessedTerminationPayPeriodsRequest, options?: RequestOptions, ): Promise { return unwrapAsync(paySchedulesGetUnprocessedTerminationPeriods( this, request, options, )); } /** * Get pay schedule assignments for a company * * @remarks * This endpoint returns the current pay schedule assignment for a company, with pay schedule and employee/department mappings depending on the pay schedule type. * * scope: `pay_schedules:read` */ async getAssignments( request: GetV1CompaniesCompanyIdPaySchedulesAssignmentsRequest, options?: RequestOptions, ): Promise { return unwrapAsync(paySchedulesGetAssignments( this, request, options, )); } /** * Preview pay schedule assignments for a company * * @remarks * This endpoint returns the employee changes, including pay period and transition pay periods, for changing the pay schedule. * * scope: `pay_schedules:write` */ async previewAssignment( request: PostV1CompaniesCompanyIdPaySchedulesAssignmentPreviewRequest, options?: RequestOptions, ): Promise { return unwrapAsync(paySchedulesPreviewAssignment( this, request, options, )); } /** * Assign pay schedules for a company * * @remarks * This endpoint assigns employees to pay schedules based on the schedule type. * For `by_employee` and `by_department` schedules, use the `partial_assignment` parameter to control the assignment scope. Set it to `true` for partial assignments (only some employees or departments at a time) and `false` for full assignments (all employees or departments at once). * * scope: `pay_schedules:write` */ async assign( request: PostV1CompaniesCompanyIdPaySchedulesAssignRequest, options?: RequestOptions, ): Promise { return unwrapAsync(paySchedulesAssign( this, request, options, )); } }