/* * 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 { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import * as shared from "../shared/index.js"; export type CreateSourceAccountRequestBody = | shared.SourceAccountV2Prototype | shared.SourceAccountPrototype; export type CreateSourceAccountRequest = { /** * Unique identifier for a company. */ companyId: string; /** * Unique identifier for a connection. */ connectionId: string; requestBody?: | shared.SourceAccountV2Prototype | shared.SourceAccountPrototype | undefined; }; /** * Success */ export type CreateSourceAccountResponseBody = | shared.SourceAccountV2 | shared.SourceAccount; /** @internal */ export type CreateSourceAccountRequestBody$Outbound = | shared.SourceAccountV2Prototype$Outbound | shared.SourceAccountPrototype$Outbound; /** @internal */ export const CreateSourceAccountRequestBody$outboundSchema: z.ZodType< CreateSourceAccountRequestBody$Outbound, z.ZodTypeDef, CreateSourceAccountRequestBody > = z.union([ shared.SourceAccountV2Prototype$outboundSchema, shared.SourceAccountPrototype$outboundSchema, ]); export function createSourceAccountRequestBodyToJSON( createSourceAccountRequestBody: CreateSourceAccountRequestBody, ): string { return JSON.stringify( CreateSourceAccountRequestBody$outboundSchema.parse( createSourceAccountRequestBody, ), ); } /** @internal */ export type CreateSourceAccountRequest$Outbound = { companyId: string; connectionId: string; RequestBody?: | shared.SourceAccountV2Prototype$Outbound | shared.SourceAccountPrototype$Outbound | undefined; }; /** @internal */ export const CreateSourceAccountRequest$outboundSchema: z.ZodType< CreateSourceAccountRequest$Outbound, z.ZodTypeDef, CreateSourceAccountRequest > = z.object({ companyId: z.string(), connectionId: z.string(), requestBody: z.union([ shared.SourceAccountV2Prototype$outboundSchema, shared.SourceAccountPrototype$outboundSchema, ]).optional(), }).transform((v) => { return remap$(v, { requestBody: "RequestBody", }); }); export function createSourceAccountRequestToJSON( createSourceAccountRequest: CreateSourceAccountRequest, ): string { return JSON.stringify( CreateSourceAccountRequest$outboundSchema.parse(createSourceAccountRequest), ); } /** @internal */ export const CreateSourceAccountResponseBody$inboundSchema: z.ZodType< CreateSourceAccountResponseBody, z.ZodTypeDef, unknown > = z.union([ shared.SourceAccountV2$inboundSchema, shared.SourceAccount$inboundSchema, ]); export function createSourceAccountResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateSourceAccountResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateSourceAccountResponseBody' from JSON`, ); }