/*
 * 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 CustomerDeletedMetadata = {
  customerId: string;
  customerEmail: string | null;
  customerName: string | null;
  customerExternalId: string | null;
};

/** @internal */
export const CustomerDeletedMetadata$inboundSchema: z.ZodMiniType<
  CustomerDeletedMetadata,
  unknown
> = z.pipe(
  z.object({
    customer_id: z.string(),
    customer_email: z.nullable(z.string()),
    customer_name: z.nullable(z.string()),
    customer_external_id: z.nullable(z.string()),
  }),
  z.transform((v) => {
    return remap$(v, {
      "customer_id": "customerId",
      "customer_email": "customerEmail",
      "customer_name": "customerName",
      "customer_external_id": "customerExternalId",
    });
  }),
);

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