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

import * as z from "zod/v4-mini";
import { smartUnion } from "../../types/smartUnion.js";
import {
  EventCreateCustomer,
  EventCreateCustomer$Outbound,
  EventCreateCustomer$outboundSchema,
} from "./eventcreatecustomer.js";
import {
  EventCreateExternalCustomer,
  EventCreateExternalCustomer$Outbound,
  EventCreateExternalCustomer$outboundSchema,
} from "./eventcreateexternalcustomer.js";

export type Events = EventCreateCustomer | EventCreateExternalCustomer;

export type EventsIngest = {
  /**
   * List of events to ingest.
   */
  events: Array<EventCreateCustomer | EventCreateExternalCustomer>;
};

/** @internal */
export type Events$Outbound =
  | EventCreateCustomer$Outbound
  | EventCreateExternalCustomer$Outbound;

/** @internal */
export const Events$outboundSchema: z.ZodMiniType<Events$Outbound, Events> =
  smartUnion([
    EventCreateCustomer$outboundSchema,
    EventCreateExternalCustomer$outboundSchema,
  ]);

export function eventsToJSON(events: Events): string {
  return JSON.stringify(Events$outboundSchema.parse(events));
}

/** @internal */
export type EventsIngest$Outbound = {
  events: Array<
    EventCreateCustomer$Outbound | EventCreateExternalCustomer$Outbound
  >;
};

/** @internal */
export const EventsIngest$outboundSchema: z.ZodMiniType<
  EventsIngest$Outbound,
  EventsIngest
> = z.object({
  events: z.array(
    smartUnion([
      EventCreateCustomer$outboundSchema,
      EventCreateExternalCustomer$outboundSchema,
    ]),
  ),
});

export function eventsIngestToJSON(eventsIngest: EventsIngest): string {
  return JSON.stringify(EventsIngest$outboundSchema.parse(eventsIngest));
}
