/* * 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"; export type Address = { /** * The city for the address. */ city?: string | null | undefined; /** * The country for the address in ISO 3166 format. */ country?: string | null | undefined; /** * The postal code or zip code for the address. */ postalCode?: string | null | undefined; /** * The state, county, or province for the address. */ state?: string | null | undefined; /** * The code of state, county, or province for the address in ISO 3166-2 format. */ stateCode?: string | null | undefined; /** * The house number or name for the address. Not all payment services use this field but some do. */ houseNumberOrName?: string | null | undefined; /** * The first line of the address. */ line1?: string | null | undefined; /** * The second line of the address. */ line2?: string | null | undefined; /** * The optional name of the company or organisation to add to the address. */ organization?: string | null | undefined; }; /** @internal */ export const Address$inboundSchema: z.ZodType
= z.object({ city: z.nullable(z.string()).optional(), country: z.nullable(z.string()).optional(), postal_code: z.nullable(z.string()).optional(), state: z.nullable(z.string()).optional(), state_code: z.nullable(z.string()).optional(), house_number_or_name: z.nullable(z.string()).optional(), line1: z.nullable(z.string()).optional(), line2: z.nullable(z.string()).optional(), organization: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { "postal_code": "postalCode", "state_code": "stateCode", "house_number_or_name": "houseNumberOrName", }); }); /** @internal */ export type Address$Outbound = { city?: string | null | undefined; country?: string | null | undefined; postal_code?: string | null | undefined; state?: string | null | undefined; state_code?: string | null | undefined; house_number_or_name?: string | null | undefined; line1?: string | null | undefined; line2?: string | null | undefined; organization?: string | null | undefined; }; /** @internal */ export const Address$outboundSchema: z.ZodType< Address$Outbound, z.ZodTypeDef, Address > = z.object({ city: z.nullable(z.string()).optional(), country: z.nullable(z.string()).optional(), postalCode: z.nullable(z.string()).optional(), state: z.nullable(z.string()).optional(), stateCode: z.nullable(z.string()).optional(), houseNumberOrName: z.nullable(z.string()).optional(), line1: z.nullable(z.string()).optional(), line2: z.nullable(z.string()).optional(), organization: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { postalCode: "postal_code", stateCode: "state_code", houseNumberOrName: "house_number_or_name", }); }); export function addressToJSON(address: Address): string { return JSON.stringify(Address$outboundSchema.parse(address)); } export function addressFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Address$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Address' from JSON`, ); }