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

import * as z from "zod/v4-mini";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  CustomerSeat,
  CustomerSeat$inboundSchema,
  CustomerSeat$Outbound,
  CustomerSeat$outboundSchema,
} from "./customerseat.js";

/**
 * Sent when a customer seat is claimed.
 *
 * @remarks
 *
 * This event is triggered when a customer accepts the seat invitation and claims their access.
 */
export type WebhookCustomerSeatClaimedPayload = {
  type: "customer_seat.claimed";
  timestamp: Date;
  data: CustomerSeat;
};

/** @internal */
export const WebhookCustomerSeatClaimedPayload$inboundSchema: z.ZodMiniType<
  WebhookCustomerSeatClaimedPayload,
  unknown
> = z.object({
  type: z.literal("customer_seat.claimed"),
  timestamp: z.pipe(
    z.iso.datetime({ offset: true }),
    z.transform(v => new Date(v)),
  ),
  data: CustomerSeat$inboundSchema,
});
/** @internal */
export type WebhookCustomerSeatClaimedPayload$Outbound = {
  type: "customer_seat.claimed";
  timestamp: string;
  data: CustomerSeat$Outbound;
};

/** @internal */
export const WebhookCustomerSeatClaimedPayload$outboundSchema: z.ZodMiniType<
  WebhookCustomerSeatClaimedPayload$Outbound,
  WebhookCustomerSeatClaimedPayload
> = z.object({
  type: z.literal("customer_seat.claimed"),
  timestamp: z.pipe(z.date(), z.transform(v => v.toISOString())),
  data: CustomerSeat$outboundSchema,
});

export function webhookCustomerSeatClaimedPayloadToJSON(
  webhookCustomerSeatClaimedPayload: WebhookCustomerSeatClaimedPayload,
): string {
  return JSON.stringify(
    WebhookCustomerSeatClaimedPayload$outboundSchema.parse(
      webhookCustomerSeatClaimedPayload,
    ),
  );
}
export function webhookCustomerSeatClaimedPayloadFromJSON(
  jsonString: string,
): SafeParseResult<WebhookCustomerSeatClaimedPayload, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => WebhookCustomerSeatClaimedPayload$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'WebhookCustomerSeatClaimedPayload' from JSON`,
  );
}
