/**
 * Types for the Zoom REST client (ZoomApiService): the request payloads it
 * builds and the loosely-structured response it returns. Provider-specific —
 * these never cross the provider-neutral online-session boundary.
 */

/**
 * Recurrence rule for a recurring webinar (Zoom `recurrence`). camelCase here;
 * mapped to Zoom's snake_case in {@link ZoomApiService.createWebinar}. `type`
 * uses ZOOM_RECURRENCE_TYPE (1 daily / 2 weekly / 3 monthly). For a weekly
 * Mon/Tue/Wed program: `{ type: 2, repeatInterval: 1, weeklyDays: '2,3,4',
 * endTimes: 12 }` (Zoom weekdays: 1=Sun … 7=Sat).
 */
export interface ZoomRecurrence {
  type: number;
  repeatInterval?: number;
  /** Comma-separated Zoom weekday numbers, e.g. '2,3,4' for Mon/Tue/Wed. */
  weeklyDays?: string;
  /** Total number of occurrences (mutually exclusive with endDateTime). */
  endTimes?: number;
  /** ISO end date-time (mutually exclusive with endTimes). */
  endDateTime?: string;
}

/** Create-webinar payload mapped to the Zoom REST body. */
export interface ZoomWebinarCreatePayload {
  title: string;
  startAt: string | Date;
  duration: number;
  password?: string | null;
  /**
   * When present, creates a RECURRING_FIXED_WEBINAR (type 9) so one webinar spans
   * many occurrences and every registrant gets a single link valid for all of
   * them. Omit for the default one-off SCHEDULED_WEBINAR (type 5).
   */
  recurrence?: ZoomRecurrence;
}

/** One occurrence of a recurring webinar, as returned in the create response. */
export interface ZoomOccurrence {
  occurrence_id?: string;
  start_time?: string;
  duration?: number;
  status?: string;
  [key: string]: unknown;
}

/** Patch-webinar payload; only provided fields are sent. */
export interface ZoomWebinarUpdatePayload {
  title?: string;
  startAt?: string | Date;
  duration?: number;
  password?: string | null;
}

/** Create-meeting payload — extends the webinar shape with meeting-only options. */
export interface ZoomMeetingCreatePayload extends ZoomWebinarCreatePayload {
  /** Enable Zoom registration (per-user join links) vs a shared join link. */
  requireRegistration?: boolean;
}

/** Patch-meeting payload; only provided fields are sent. */
export type ZoomMeetingUpdatePayload = ZoomWebinarUpdatePayload;

/**
 * Permissive shape of a Zoom REST response. Zoom returns loosely-structured
 * JSON that varies by endpoint; the commonly-read fields are declared and the
 * index signature keeps the rest accessible without `any`.
 */
export interface ZoomApiResponse {
  id?: string | number;
  join_url?: string;
  password?: string;
  registration_url?: string;
  start_url?: string;
  registrant_id?: string;
  email?: string;
  next_page_token?: string;
  /** Present on recurring-webinar create/get responses. */
  occurrences?: ZoomOccurrence[];
  [key: string]: unknown;
}
