/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { CompanyReference, CompanyReference$inboundSchema, CompanyReference$Outbound, CompanyReference$outboundSchema, } from "./companyreference.js"; import { SourceAccount, SourceAccount$inboundSchema, SourceAccount$Outbound, SourceAccount$outboundSchema, } from "./sourceaccount.js"; import { SourceAccountV2, SourceAccountV2$inboundSchema, SourceAccountV2$Outbound, SourceAccountV2$outboundSchema, } from "./sourceaccountv2.js"; export type SourceAccountWebhookPayloadSourceAccount = | SourceAccountV2 | SourceAccount; export type SourceAccountWebhookPayload = { referenceCompany?: CompanyReference | undefined; /** * Unique identifier for your SMB in Codat. */ companyId?: string | undefined; /** * Unique identifier for a company's data connection. */ connectionId?: string | undefined; sourceAccount?: SourceAccountV2 | SourceAccount | undefined; }; /** @internal */ export const SourceAccountWebhookPayloadSourceAccount$inboundSchema: z.ZodType< SourceAccountWebhookPayloadSourceAccount, z.ZodTypeDef, unknown > = z.union([SourceAccountV2$inboundSchema, SourceAccount$inboundSchema]); /** @internal */ export type SourceAccountWebhookPayloadSourceAccount$Outbound = | SourceAccountV2$Outbound | SourceAccount$Outbound; /** @internal */ export const SourceAccountWebhookPayloadSourceAccount$outboundSchema: z.ZodType< SourceAccountWebhookPayloadSourceAccount$Outbound, z.ZodTypeDef, SourceAccountWebhookPayloadSourceAccount > = z.union([SourceAccountV2$outboundSchema, SourceAccount$outboundSchema]); export function sourceAccountWebhookPayloadSourceAccountToJSON( sourceAccountWebhookPayloadSourceAccount: SourceAccountWebhookPayloadSourceAccount, ): string { return JSON.stringify( SourceAccountWebhookPayloadSourceAccount$outboundSchema.parse( sourceAccountWebhookPayloadSourceAccount, ), ); } export function sourceAccountWebhookPayloadSourceAccountFromJSON( jsonString: string, ): SafeParseResult< SourceAccountWebhookPayloadSourceAccount, SDKValidationError > { return safeParse( jsonString, (x) => SourceAccountWebhookPayloadSourceAccount$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'SourceAccountWebhookPayloadSourceAccount' from JSON`, ); } /** @internal */ export const SourceAccountWebhookPayload$inboundSchema: z.ZodType< SourceAccountWebhookPayload, z.ZodTypeDef, unknown > = z.object({ referenceCompany: CompanyReference$inboundSchema.optional(), companyId: z.string().optional(), connectionId: z.string().optional(), sourceAccount: z.union([ SourceAccountV2$inboundSchema, SourceAccount$inboundSchema, ]).optional(), }); /** @internal */ export type SourceAccountWebhookPayload$Outbound = { referenceCompany?: CompanyReference$Outbound | undefined; companyId?: string | undefined; connectionId?: string | undefined; sourceAccount?: SourceAccountV2$Outbound | SourceAccount$Outbound | undefined; }; /** @internal */ export const SourceAccountWebhookPayload$outboundSchema: z.ZodType< SourceAccountWebhookPayload$Outbound, z.ZodTypeDef, SourceAccountWebhookPayload > = z.object({ referenceCompany: CompanyReference$outboundSchema.optional(), companyId: z.string().optional(), connectionId: z.string().optional(), sourceAccount: z.union([ SourceAccountV2$outboundSchema, SourceAccount$outboundSchema, ]).optional(), }); export function sourceAccountWebhookPayloadToJSON( sourceAccountWebhookPayload: SourceAccountWebhookPayload, ): string { return JSON.stringify( SourceAccountWebhookPayload$outboundSchema.parse( sourceAccountWebhookPayload, ), ); } export function sourceAccountWebhookPayloadFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SourceAccountWebhookPayload$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SourceAccountWebhookPayload' from JSON`, ); }