/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { RFCDate } from "../../types/rfcdate.js"; import { ContractorPaymentGroup, ContractorPaymentGroup$inboundSchema, } from "../components/contractorpaymentgroup.js"; import { HTTPMetadata, HTTPMetadata$inboundSchema, } from "../components/httpmetadata.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Determines the date-based API version associated with your API call. If none is provided, your application's [minimum API version](https://docs.gusto.com/embedded-payroll/docs/api-versioning#minimum-api-version) is used. */ export const PostV1CompaniesCompanyIdContractorPaymentGroupsHeaderXGustoAPIVersion = { TwoThousandAndTwentyFiveMinus06Minus15: "2025-06-15", } as const; /** * Determines the date-based API version associated with your API call. If none is provided, your application's [minimum API version](https://docs.gusto.com/embedded-payroll/docs/api-versioning#minimum-api-version) is used. */ export type PostV1CompaniesCompanyIdContractorPaymentGroupsHeaderXGustoAPIVersion = ClosedEnum< typeof PostV1CompaniesCompanyIdContractorPaymentGroupsHeaderXGustoAPIVersion >; export type Options = { /** * The type of option */ type?: string | undefined; /** * Message for the option */ message?: string | undefined; }; export type SubmissionBlockers = { /** * The type of blocker that is blocking the payment submission */ blockerType?: string | undefined; /** * The unblock option selected to resolve the submission blocker */ selectedOption?: string | null | undefined; /** * Optional message related to the blocker */ message?: string | undefined; /** * Optional array of additional options for the blocker */ options?: Array | undefined; }; export const PaymentMethod = { DirectDeposit: "Direct Deposit", Check: "Check", HistoricalPayment: "Historical Payment", } as const; export type PaymentMethod = ClosedEnum; export type ContractorPayments = { /** * The contractor receiving the payment */ contractorUuid?: string | undefined; paymentMethod?: PaymentMethod | undefined; /** * If the contractor is on a fixed wage, this is the fixed wage payment for the contractor, regardless of hours worked */ wage?: string | undefined; /** * If the contractor is on an hourly wage, this is the number of hours that the contractor worked for the payment */ hours?: string | undefined; /** * If the contractor is on an hourly wage, this is the bonus the contractor earned */ bonus?: string | undefined; /** * Reimbursed wages for the contractor */ reimbursement?: string | undefined; }; export type PostV1CompaniesCompanyIdContractorPaymentGroupsRequestBody = { /** * The payment check date */ checkDate: RFCDate; /** * A token used to make contractor payment group creation idempotent. The string must be unique for each group you intend to create. */ creationToken: string; /** * Optional array of submission blockers with selected unblock options. Returned from the preview endpoint and can be submitted with selected_option to resolve blockers. */ submissionBlockers?: Array | undefined; contractorPayments: Array; }; export type PostV1CompaniesCompanyIdContractorPaymentGroupsRequest = { /** * Determines the date-based API version associated with your API call. If none is provided, your application's [minimum API version](https://docs.gusto.com/embedded-payroll/docs/api-versioning#minimum-api-version) is used. */ xGustoAPIVersion?: | PostV1CompaniesCompanyIdContractorPaymentGroupsHeaderXGustoAPIVersion | undefined; /** * The UUID of the company */ companyId: string; requestBody: PostV1CompaniesCompanyIdContractorPaymentGroupsRequestBody; }; export type PostV1CompaniesCompanyIdContractorPaymentGroupsResponse = { httpMeta: HTTPMetadata; /** * Full contractor payment group object */ contractorPaymentGroup?: ContractorPaymentGroup | undefined; }; /** @internal */ export const PostV1CompaniesCompanyIdContractorPaymentGroupsHeaderXGustoAPIVersion$outboundSchema: z.ZodNativeEnum< typeof PostV1CompaniesCompanyIdContractorPaymentGroupsHeaderXGustoAPIVersion > = z.nativeEnum( PostV1CompaniesCompanyIdContractorPaymentGroupsHeaderXGustoAPIVersion, ); /** @internal */ export type Options$Outbound = { type?: string | undefined; message?: string | undefined; }; /** @internal */ export const Options$outboundSchema: z.ZodType< Options$Outbound, z.ZodTypeDef, Options > = z.object({ type: z.string().optional(), message: z.string().optional(), }); export function optionsToJSON(options: Options): string { return JSON.stringify(Options$outboundSchema.parse(options)); } /** @internal */ export type SubmissionBlockers$Outbound = { blocker_type?: string | undefined; selected_option?: string | null | undefined; message?: string | undefined; options?: Array | undefined; }; /** @internal */ export const SubmissionBlockers$outboundSchema: z.ZodType< SubmissionBlockers$Outbound, z.ZodTypeDef, SubmissionBlockers > = z.object({ blockerType: z.string().optional(), selectedOption: z.nullable(z.string()).optional(), message: z.string().optional(), options: z.array(z.lazy(() => Options$outboundSchema)).optional(), }).transform((v) => { return remap$(v, { blockerType: "blocker_type", selectedOption: "selected_option", }); }); export function submissionBlockersToJSON( submissionBlockers: SubmissionBlockers, ): string { return JSON.stringify( SubmissionBlockers$outboundSchema.parse(submissionBlockers), ); } /** @internal */ export const PaymentMethod$outboundSchema: z.ZodNativeEnum< typeof PaymentMethod > = z.nativeEnum(PaymentMethod); /** @internal */ export type ContractorPayments$Outbound = { contractor_uuid?: string | undefined; payment_method: string; wage?: string | undefined; hours?: string | undefined; bonus?: string | undefined; reimbursement?: string | undefined; }; /** @internal */ export const ContractorPayments$outboundSchema: z.ZodType< ContractorPayments$Outbound, z.ZodTypeDef, ContractorPayments > = z.object({ contractorUuid: z.string().optional(), paymentMethod: PaymentMethod$outboundSchema.default("Direct Deposit"), wage: z.string().optional(), hours: z.string().optional(), bonus: z.string().optional(), reimbursement: z.string().optional(), }).transform((v) => { return remap$(v, { contractorUuid: "contractor_uuid", paymentMethod: "payment_method", }); }); export function contractorPaymentsToJSON( contractorPayments: ContractorPayments, ): string { return JSON.stringify( ContractorPayments$outboundSchema.parse(contractorPayments), ); } /** @internal */ export type PostV1CompaniesCompanyIdContractorPaymentGroupsRequestBody$Outbound = { check_date: string; creation_token: string; submission_blockers?: Array | undefined; contractor_payments: Array; }; /** @internal */ export const PostV1CompaniesCompanyIdContractorPaymentGroupsRequestBody$outboundSchema: z.ZodType< PostV1CompaniesCompanyIdContractorPaymentGroupsRequestBody$Outbound, z.ZodTypeDef, PostV1CompaniesCompanyIdContractorPaymentGroupsRequestBody > = z.object({ checkDate: z.instanceof(RFCDate).transform(v => v.toString()), creationToken: z.string(), submissionBlockers: z.array(z.lazy(() => SubmissionBlockers$outboundSchema)) .optional(), contractorPayments: z.array( z.lazy(() => ContractorPayments$outboundSchema), ), }).transform((v) => { return remap$(v, { checkDate: "check_date", creationToken: "creation_token", submissionBlockers: "submission_blockers", contractorPayments: "contractor_payments", }); }); export function postV1CompaniesCompanyIdContractorPaymentGroupsRequestBodyToJSON( postV1CompaniesCompanyIdContractorPaymentGroupsRequestBody: PostV1CompaniesCompanyIdContractorPaymentGroupsRequestBody, ): string { return JSON.stringify( PostV1CompaniesCompanyIdContractorPaymentGroupsRequestBody$outboundSchema .parse(postV1CompaniesCompanyIdContractorPaymentGroupsRequestBody), ); } /** @internal */ export type PostV1CompaniesCompanyIdContractorPaymentGroupsRequest$Outbound = { "X-Gusto-API-Version": string; company_id: string; RequestBody: PostV1CompaniesCompanyIdContractorPaymentGroupsRequestBody$Outbound; }; /** @internal */ export const PostV1CompaniesCompanyIdContractorPaymentGroupsRequest$outboundSchema: z.ZodType< PostV1CompaniesCompanyIdContractorPaymentGroupsRequest$Outbound, z.ZodTypeDef, PostV1CompaniesCompanyIdContractorPaymentGroupsRequest > = z.object({ xGustoAPIVersion: PostV1CompaniesCompanyIdContractorPaymentGroupsHeaderXGustoAPIVersion$outboundSchema .default("2025-06-15"), companyId: z.string(), requestBody: z.lazy(() => PostV1CompaniesCompanyIdContractorPaymentGroupsRequestBody$outboundSchema ), }).transform((v) => { return remap$(v, { xGustoAPIVersion: "X-Gusto-API-Version", companyId: "company_id", requestBody: "RequestBody", }); }); export function postV1CompaniesCompanyIdContractorPaymentGroupsRequestToJSON( postV1CompaniesCompanyIdContractorPaymentGroupsRequest: PostV1CompaniesCompanyIdContractorPaymentGroupsRequest, ): string { return JSON.stringify( PostV1CompaniesCompanyIdContractorPaymentGroupsRequest$outboundSchema.parse( postV1CompaniesCompanyIdContractorPaymentGroupsRequest, ), ); } /** @internal */ export const PostV1CompaniesCompanyIdContractorPaymentGroupsResponse$inboundSchema: z.ZodType< PostV1CompaniesCompanyIdContractorPaymentGroupsResponse, z.ZodTypeDef, unknown > = z.object({ HttpMeta: HTTPMetadata$inboundSchema, "Contractor-Payment-Group": ContractorPaymentGroup$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "HttpMeta": "httpMeta", "Contractor-Payment-Group": "contractorPaymentGroup", }); }); export function postV1CompaniesCompanyIdContractorPaymentGroupsResponseFromJSON( jsonString: string, ): SafeParseResult< PostV1CompaniesCompanyIdContractorPaymentGroupsResponse, SDKValidationError > { return safeParse( jsonString, (x) => PostV1CompaniesCompanyIdContractorPaymentGroupsResponse$inboundSchema .parse(JSON.parse(x)), `Failed to parse 'PostV1CompaniesCompanyIdContractorPaymentGroupsResponse' from JSON`, ); }