/* * 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 { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { PaymentMethodBankAccount, PaymentMethodBankAccount$inboundSchema, } from "./paymentmethodbankaccount.js"; export const ContractorPaymentMethodType = { DirectDeposit: "Direct Deposit", Check: "Check", } as const; export type ContractorPaymentMethodType = ClosedEnum< typeof ContractorPaymentMethodType >; export const ContractorPaymentMethodSplitBy = { Amount: "Amount", Percentage: "Percentage", } as const; export type ContractorPaymentMethodSplitBy = ClosedEnum< typeof ContractorPaymentMethodSplitBy >; export type ContractorPaymentMethod = { /** * The current version of the object. See the [versioning guide](https://docs.gusto.com/embedded-payroll/docs/idempotency) for information on how to use this field. */ version?: string | undefined; /** * The payment method type. If type is Check, then `split_by` and `splits` do not need to be populated. If type is Direct Deposit, `split_by` and `splits` are required. */ type?: ContractorPaymentMethodType | null | undefined; /** * Describes how the payment will be split. If `split_by` is Percentage, then the `split` amounts must add up to exactly 100. If `split_by` is Amount, then values are in cents and the last split amount must be `null` to capture the remainder. */ splitBy?: ContractorPaymentMethodSplitBy | null | undefined; splits?: Array | null | undefined; }; /** @internal */ export const ContractorPaymentMethodType$inboundSchema: z.ZodNativeEnum< typeof ContractorPaymentMethodType > = z.nativeEnum(ContractorPaymentMethodType); /** @internal */ export const ContractorPaymentMethodSplitBy$inboundSchema: z.ZodNativeEnum< typeof ContractorPaymentMethodSplitBy > = z.nativeEnum(ContractorPaymentMethodSplitBy); /** @internal */ export const ContractorPaymentMethod$inboundSchema: z.ZodType< ContractorPaymentMethod, z.ZodTypeDef, unknown > = z.object({ version: z.string().optional(), type: z.nullable(ContractorPaymentMethodType$inboundSchema).optional(), split_by: z.nullable(ContractorPaymentMethodSplitBy$inboundSchema).optional(), splits: z.nullable(z.array(PaymentMethodBankAccount$inboundSchema)) .optional(), }).transform((v) => { return remap$(v, { "split_by": "splitBy", }); }); export function contractorPaymentMethodFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ContractorPaymentMethod$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContractorPaymentMethod' from JSON`, ); }