/* * 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"; /** * The type of payment event associated with the ACH transaction */ export const PaymentEventType = { Payroll: "Payroll", ContractorPayment: "ContractorPayment", } as const; /** * The type of payment event associated with the ACH transaction */ export type PaymentEventType = ClosedEnum; export const AchTransactionRecipientType = { Employee: "Employee", Contractor: "Contractor", } as const; export type AchTransactionRecipientType = ClosedEnum< typeof AchTransactionRecipientType >; /** * The status of the ACH transaction */ export const PaymentStatus = { Unsubmitted: "unsubmitted", Submitted: "submitted", Successful: "successful", Failed: "failed", } as const; /** * The status of the ACH transaction */ export type PaymentStatus = ClosedEnum; /** * The direction of the payment */ export const PaymentDirection = { Credit: "credit", Debit: "debit", } as const; /** * The direction of the payment */ export type PaymentDirection = ClosedEnum; /** * Representation of an ACH transaction */ export type AchTransaction = { /** * Unique identifier of an ACH transaction */ uuid: string; /** * Unique identifier of the company to which the ACH transaction belongs */ companyUuid?: string | undefined; /** * The type of payment event associated with the ACH transaction */ paymentEventType?: PaymentEventType | undefined; /** * Unique identifier for the payment event associated with the ACH transaction */ paymentEventUuid?: string | undefined; /** * The type of recipient associated with the ACH transaction */ recipientType?: AchTransactionRecipientType | null | undefined; /** * Unique identifier for the recipient associated with the ACH transaction */ recipientUuid?: string | undefined; /** * The error code associated with the ACH transaction, if any. If there is no error on the ACH transaction, this field will be nil. See [this article](https://engineering.gusto.com/how-ach-works-a-developer-perspective-part-2/) for a complete list of ACH return codes. */ errorCode?: string | null | undefined; /** * The type of transaction associated with the ACH transaction */ transactionType?: string | undefined; /** * The status of the ACH transaction */ paymentStatus?: PaymentStatus | undefined; /** * The direction of the payment */ paymentDirection?: PaymentDirection | undefined; /** * The date of the payment event check associated with the ACH transaction */ paymentEventCheckDate?: string | undefined; /** * The date of the payment associated with the ACH transaction */ paymentDate?: string | undefined; /** * The amount of money moved by the ACH transaction. This amount is always non-negative. */ amount?: string | undefined; /** * The description of the ACH transaction. Can be used to identify the ACH transaction on the recipient's bank statement. */ description?: string | undefined; }; /** @internal */ export const PaymentEventType$inboundSchema: z.ZodNativeEnum< typeof PaymentEventType > = z.nativeEnum(PaymentEventType); /** @internal */ export const AchTransactionRecipientType$inboundSchema: z.ZodNativeEnum< typeof AchTransactionRecipientType > = z.nativeEnum(AchTransactionRecipientType); /** @internal */ export const PaymentStatus$inboundSchema: z.ZodNativeEnum< typeof PaymentStatus > = z.nativeEnum(PaymentStatus); /** @internal */ export const PaymentDirection$inboundSchema: z.ZodNativeEnum< typeof PaymentDirection > = z.nativeEnum(PaymentDirection); /** @internal */ export const AchTransaction$inboundSchema: z.ZodType< AchTransaction, z.ZodTypeDef, unknown > = z.object({ uuid: z.string(), company_uuid: z.string().optional(), payment_event_type: PaymentEventType$inboundSchema.optional(), payment_event_uuid: z.string().optional(), recipient_type: z.nullable(AchTransactionRecipientType$inboundSchema) .optional(), recipient_uuid: z.string().optional(), error_code: z.nullable(z.string()).optional(), transaction_type: z.string().optional(), payment_status: PaymentStatus$inboundSchema.optional(), payment_direction: PaymentDirection$inboundSchema.optional(), payment_event_check_date: z.string().optional(), payment_date: z.string().optional(), amount: z.string().optional(), description: z.string().optional(), }).transform((v) => { return remap$(v, { "company_uuid": "companyUuid", "payment_event_type": "paymentEventType", "payment_event_uuid": "paymentEventUuid", "recipient_type": "recipientType", "recipient_uuid": "recipientUuid", "error_code": "errorCode", "transaction_type": "transactionType", "payment_status": "paymentStatus", "payment_direction": "paymentDirection", "payment_event_check_date": "paymentEventCheckDate", "payment_date": "paymentDate", }); }); export function achTransactionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AchTransaction$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AchTransaction' from JSON`, ); }