/* * 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"; export const ContractorPaymentDetailsListPaymentMethod = { DirectDeposit: "Direct Deposit", Check: "Check", } as const; export type ContractorPaymentDetailsListPaymentMethod = ClosedEnum< typeof ContractorPaymentDetailsListPaymentMethod >; export const ContractorPaymentDetailsListSplitBy = { Amount: "Amount", Percentage: "Percentage", } as const; export type ContractorPaymentDetailsListSplitBy = ClosedEnum< typeof ContractorPaymentDetailsListSplitBy >; export type ContractorPaymentDetailsListSplits = { bankAccountUuid?: string | undefined; name?: string | undefined; /** * An obfuscated version of the account number which can be used for display purposes. */ hiddenAccountNumber?: string | undefined; /** * Ciphertext containing the full bank account number, which must be decrypted using a key provided by Gusto. Only visible with the `contractor_payment_methods:read:account_number` scope. */ encryptedAccountNumber?: string | null | undefined; routingNumber?: string | undefined; /** * The order of priority for each payment split, with priority 1 being the first bank account paid. Priority must be unique and sequential. */ priority?: number | undefined; /** * If `split_by` is 'Amount', this is in cents (e.g., 500 for $5.00) and exactly one account must have a `split_amount` of `null` to capture the remainder. If `split_by` is 'Percentage', this is the percentage value (e.g., 60 for 60%). */ splitAmount?: number | null | undefined; accountType?: string | undefined; }; export type ContractorPaymentDetailsList = { contractorUuid?: string | undefined; paymentMethod?: ContractorPaymentDetailsListPaymentMethod | undefined; firstName?: string | undefined; lastName?: string | 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 the amount represents cents and the last split amount must be `null` to capture the remainder. */ splitBy?: ContractorPaymentDetailsListSplitBy | null | undefined; splits?: Array | null | undefined; }; /** @internal */ export const ContractorPaymentDetailsListPaymentMethod$inboundSchema: z.ZodNativeEnum = z .nativeEnum(ContractorPaymentDetailsListPaymentMethod); /** @internal */ export const ContractorPaymentDetailsListSplitBy$inboundSchema: z.ZodNativeEnum< typeof ContractorPaymentDetailsListSplitBy > = z.nativeEnum(ContractorPaymentDetailsListSplitBy); /** @internal */ export const ContractorPaymentDetailsListSplits$inboundSchema: z.ZodType< ContractorPaymentDetailsListSplits, z.ZodTypeDef, unknown > = z.object({ bank_account_uuid: z.string().optional(), name: z.string().optional(), hidden_account_number: z.string().optional(), encrypted_account_number: z.nullable(z.string()).optional(), routing_number: z.string().optional(), priority: z.number().int().optional(), split_amount: z.nullable(z.number()).optional(), account_type: z.string().optional(), }).transform((v) => { return remap$(v, { "bank_account_uuid": "bankAccountUuid", "hidden_account_number": "hiddenAccountNumber", "encrypted_account_number": "encryptedAccountNumber", "routing_number": "routingNumber", "split_amount": "splitAmount", "account_type": "accountType", }); }); export function contractorPaymentDetailsListSplitsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ContractorPaymentDetailsListSplits$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContractorPaymentDetailsListSplits' from JSON`, ); } /** @internal */ export const ContractorPaymentDetailsList$inboundSchema: z.ZodType< ContractorPaymentDetailsList, z.ZodTypeDef, unknown > = z.object({ contractor_uuid: z.string().optional(), payment_method: ContractorPaymentDetailsListPaymentMethod$inboundSchema .optional(), first_name: z.string().optional(), last_name: z.string().optional(), split_by: z.nullable(ContractorPaymentDetailsListSplitBy$inboundSchema) .optional(), splits: z.nullable( z.array(z.lazy(() => ContractorPaymentDetailsListSplits$inboundSchema)), ).optional(), }).transform((v) => { return remap$(v, { "contractor_uuid": "contractorUuid", "payment_method": "paymentMethod", "first_name": "firstName", "last_name": "lastName", "split_by": "splitBy", }); }); export function contractorPaymentDetailsListFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ContractorPaymentDetailsList$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContractorPaymentDetailsList' from JSON`, ); }