/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { catchUnrecognizedEnum, OpenEnum, Unrecognized, } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The type of identification document */ export enum IdentificationType { TypeUnspecified = "TYPE_UNSPECIFIED", Ssn = "SSN", Cpf = "CPF", } /** * The type of identification document */ export type IdentificationTypeOpen = OpenEnum; /** * Represents an identification document */ export type Identification = { /** * CLDR format */ regionCode?: string | undefined; /** * The type of identification document */ type?: IdentificationTypeOpen | undefined; /** * The value of the identification document */ value?: string | undefined; }; /** @internal */ export const IdentificationType$inboundSchema: z.ZodType< IdentificationTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(IdentificationType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const IdentificationType$outboundSchema: z.ZodType< IdentificationTypeOpen, z.ZodTypeDef, IdentificationTypeOpen > = z.union([ z.nativeEnum(IdentificationType), z.string().and(z.custom>()), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace IdentificationType$ { /** @deprecated use `IdentificationType$inboundSchema` instead. */ export const inboundSchema = IdentificationType$inboundSchema; /** @deprecated use `IdentificationType$outboundSchema` instead. */ export const outboundSchema = IdentificationType$outboundSchema; } /** @internal */ export const Identification$inboundSchema: z.ZodType< Identification, z.ZodTypeDef, unknown > = z.object({ region_code: z.string().optional(), type: IdentificationType$inboundSchema.optional(), value: z.string().optional(), }).transform((v) => { return remap$(v, { "region_code": "regionCode", }); }); /** @internal */ export type Identification$Outbound = { region_code?: string | undefined; type?: string | undefined; value?: string | undefined; }; /** @internal */ export const Identification$outboundSchema: z.ZodType< Identification$Outbound, z.ZodTypeDef, Identification > = z.object({ regionCode: z.string().optional(), type: IdentificationType$outboundSchema.optional(), value: z.string().optional(), }).transform((v) => { return remap$(v, { regionCode: "region_code", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Identification$ { /** @deprecated use `Identification$inboundSchema` instead. */ export const inboundSchema = Identification$inboundSchema; /** @deprecated use `Identification$outboundSchema` instead. */ export const outboundSchema = Identification$outboundSchema; /** @deprecated use `Identification$Outbound` instead. */ export type Outbound = Identification$Outbound; } export function identificationToJSON(identification: Identification): string { return JSON.stringify(Identification$outboundSchema.parse(identification)); } export function identificationFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Identification$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Identification' from JSON`, ); }