/**
 * API MCP Server - Demo Bookings
 *
 * Provides demo booking API operations.
 * Token savings: 5,000+ per operation
 */

import { callMCPTool } from "../../client.js";

export interface CreateDemoBookingInput {
  customerName: string;
  customerEmail: string;
  customerPhone: string;
  service: string;
  date: string;
  time: string;
  notes?: string;
  language?: "ar" | "en";
}

export interface DemoBookingResponse {
  success: boolean;
  bookingId?: string;
  confirmationEmailSent?: boolean;
  error?: string;
}

/**
 * Test demo booking creation endpoint.
 *
 * @param input - Booking data
 * @returns API response
 *
 * @example
 * ```typescript
 * const result = await testCreateDemoBooking({
 *   customerName: 'أحمد محمد',
 *   customerEmail: 'ahmed@example.com',
 *   customerPhone: '+966501234567',
 *   service: 'Dental Consultation',
 *   date: '2025-11-20',
 *   time: '10:00',
 *   language: 'ar'
 * });
 *
 * if (result.success) {
 *   console.log(`✓ Booking created: ${result.bookingId}`);
 *   console.log(`  Confirmation email sent: ${result.confirmationEmailSent}`);
 * }
 * ```
 */
export async function testCreateDemoBooking(
  input: CreateDemoBookingInput,
): Promise<DemoBookingResponse> {
  return callMCPTool<DemoBookingResponse>(
    "api__test_create_demo_booking",
    input,
  );
}

/**
 * Test demo booking confirmation email.
 *
 * @param bookingId - Booking ID
 * @param language - Email language
 * @returns Email send result
 *
 * @example
 * ```typescript
 * const result = await testSendDemoConfirmation('booking_123', 'ar');
 * console.log(result.success ? '✓ Email sent' : '✗ Failed to send');
 * ```
 */
export async function testSendDemoConfirmation(
  bookingId: string,
  language: "ar" | "en",
): Promise<{ success: boolean }> {
  return callMCPTool("api__test_send_demo_confirmation", {
    bookingId,
    language,
  });
}

export default {
  testCreateDemoBooking,
  testSendDemoConfirmation,
};
