/*
 * 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";

/**
 * Schema for creating a customer session using an external customer ID.
 */
export type CustomerSessionCustomerExternalIDCreate = {
  /**
   * ID of the member to create a session for. When not provided and the organization has `member_model_enabled`, the owner member of the customer will be used for individual customers.
   */
  memberId?: string | null | undefined;
  /**
   * External ID of the member to create a session for. Alternative to `member_id`.
   */
  externalMemberId?: string | null | undefined;
  /**
   * When set, a back button will be shown in the customer portal to return to this URL.
   */
  returnUrl?: string | null | undefined;
  /**
   * External ID of the customer to create a session for.
   */
  externalCustomerId: string;
};

/** @internal */
export type CustomerSessionCustomerExternalIDCreate$Outbound = {
  member_id?: string | null | undefined;
  external_member_id?: string | null | undefined;
  return_url?: string | null | undefined;
  external_customer_id: string;
};

/** @internal */
export const CustomerSessionCustomerExternalIDCreate$outboundSchema:
  z.ZodMiniType<
    CustomerSessionCustomerExternalIDCreate$Outbound,
    CustomerSessionCustomerExternalIDCreate
  > = z.pipe(
    z.object({
      memberId: z.optional(z.nullable(z.string())),
      externalMemberId: z.optional(z.nullable(z.string())),
      returnUrl: z.optional(z.nullable(z.string())),
      externalCustomerId: z.string(),
    }),
    z.transform((v) => {
      return remap$(v, {
        memberId: "member_id",
        externalMemberId: "external_member_id",
        returnUrl: "return_url",
        externalCustomerId: "external_customer_id",
      });
    }),
  );

export function customerSessionCustomerExternalIDCreateToJSON(
  customerSessionCustomerExternalIDCreate:
    CustomerSessionCustomerExternalIDCreate,
): string {
  return JSON.stringify(
    CustomerSessionCustomerExternalIDCreate$outboundSchema.parse(
      customerSessionCustomerExternalIDCreate,
    ),
  );
}
