/*
 * 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 a customer ID.
 */
export type CustomerSessionCustomerIDCreate = {
  /**
   * 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;
  /**
   * ID of the customer to create a session for.
   */
  customerId: string;
};

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

/** @internal */
export const CustomerSessionCustomerIDCreate$outboundSchema: z.ZodMiniType<
  CustomerSessionCustomerIDCreate$Outbound,
  CustomerSessionCustomerIDCreate
> = 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())),
    customerId: z.string(),
  }),
  z.transform((v) => {
    return remap$(v, {
      memberId: "member_id",
      externalMemberId: "external_member_id",
      returnUrl: "return_url",
      customerId: "customer_id",
    });
  }),
);

export function customerSessionCustomerIDCreateToJSON(
  customerSessionCustomerIDCreate: CustomerSessionCustomerIDCreate,
): string {
  return JSON.stringify(
    CustomerSessionCustomerIDCreate$outboundSchema.parse(
      customerSessionCustomerIDCreate,
    ),
  );
}
