// brevoContactService.ts

import { brevoContactClient as brevo } from '@/lib/brevoClient';

interface CreateContactOptions {
  email: string;
  firstName?: string;
  lastName?: string;
  sms?: string;
  whatsapp?: string;
  attributes?: Record<string, unknown>;
  listIds?: number[];
  updateExisting?: boolean;
}

export async function createBrevoContact({
  email,
  firstName,
  lastName,
  sms,
  whatsapp,
  attributes = {},
  listIds = [],
  updateExisting = true,
}: CreateContactOptions) {
  try {
    const contactData = {
      email,
      sms,
      whatsapp,
      attributes: {
        ...(firstName && { FIRSTNAME: firstName }),
        ...(lastName && { LASTNAME: lastName }),
        ...(sms && { SMS: sms }),
        ...(whatsapp && { WHATSAPP: whatsapp }),
        ...attributes,
      },
      listIds,
      updateEnabled: updateExisting,
    };

    // Brevo contact creation disabled
    // const { body } = await brevo.createContact(contactData);

    // return body;
    return;
  } catch (error) {
    console.error(
      '❌ Failed to create Brevo contact:',
      error?.body || error.message,
    );
    // throw error;
  }
}
