/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v4-mini";
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 AddressDict = {
  line1?: string | undefined;
  line2?: string | undefined;
  postalCode?: string | undefined;
  city?: string | undefined;
  state?: string | undefined;
  country: string;
};

/** @internal */
export const AddressDict$inboundSchema: z.ZodMiniType<AddressDict, unknown> = z
  .pipe(
    z.object({
      line1: z.optional(z.string()),
      line2: z.optional(z.string()),
      postal_code: z.optional(z.string()),
      city: z.optional(z.string()),
      state: z.optional(z.string()),
      country: z.string(),
    }),
    z.transform((v) => {
      return remap$(v, {
        "postal_code": "postalCode",
      });
    }),
  );

export function addressDictFromJSON(
  jsonString: string,
): SafeParseResult<AddressDict, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => AddressDict$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'AddressDict' from JSON`,
  );
}
