// Acuity Scheduling TypeScript types

export interface AcuityConfig {
  userId: string;
  apiKey: string;
  baseUrl?: string;
}

export interface AcuityError {
  error: string;
  message: string;
  status_code: number;
}

// Appointment Types
export interface Appointment {
  id: number;
  firstName: string;
  lastName: string;
  phone: string;
  email: string;
  date: string;
  time: string;
  endTime: string;
  dateCreated: string;
  datetimeCreated: string;
  datetime: string;
  price: string;
  priceSold: string;
  paid: string;
  amountPaid: string;
  type: string;
  appointmentTypeID: number;
  classID: number | null;
  addonIDs: number[];
  category: string;
  duration: string;
  calendar: string;
  calendarID: number;
  canClientCancel: boolean;
  canClientReschedule: boolean;
  labels: Label[] | null;
  forms: Form[];
  formsText: string;
  notes: string;
  timezone: string;
  calendarTimezone: string;
  canceled: boolean;
  confirmationPage: string;
  location: string;
  certificate: string | null;
  confirmationPageUrl?: string;
}

export interface CreateAppointmentParams {
  appointmentTypeID: number;
  datetime: string;
  firstName: string;
  lastName: string;
  email: string;
  phone?: string;
  calendarID?: number;
  timezone?: string;
  notes?: string;
  fields?: { id: number; value: string }[];
  certificate?: string;
}

export interface UpdateAppointmentParams {
  datetime?: string;
  firstName?: string;
  lastName?: string;
  email?: string;
  phone?: string;
  notes?: string;
  calendarID?: number;
}

// Calendar Types
export interface Calendar {
  id: number;
  name: string;
  email: string;
  description: string;
  location: string;
  timezone: string;
  image: string;
  thumbnail: string;
  replyTo: string;
}

// Appointment Type
export interface AppointmentType {
  id: number;
  active: boolean;
  name: string;
  description: string;
  duration: number;
  price: string;
  category: string;
  color: string;
  private: boolean;
  type: string;
  calendarIDs: number[];
  classSize: number | null;
  paddingBefore: number;
  paddingAfter: number;
  schedulingUrl: string;
}

export interface CreateAppointmentTypeParams {
  name: string;
  duration: number;
  calendarIDs: number[];
  price?: string;
  description?: string;
  category?: string;
  color?: string;
  private?: boolean;
  paddingBefore?: number;
  paddingAfter?: number;
}

// Client Types
export interface Client {
  id: number;
  firstName: string;
  lastName: string;
  phone: string;
  email: string;
  notes: string;
}

export interface CreateClientParams {
  firstName: string;
  lastName: string;
  email: string;
  phone?: string;
  notes?: string;
}

// Availability Types
export interface Availability {
  date: string;
  time: string;
  slotsAvailable: number;
}

export interface AvailabilityParams {
  appointmentTypeID: number;
  calendarID?: number;
  month: string; // YYYY-MM
  timezone?: string;
}

export interface Block {
  id: number;
  calendarID: number;
  start: string;
  end: string;
  notes: string;
}

export interface CreateBlockParams {
  calendarID: number;
  start: string;
  end: string;
  notes?: string;
}

// Product Types
export interface Product {
  id: number;
  name: string;
  description: string;
  price: string;
  active: boolean;
}

export interface CreateProductParams {
  name: string;
  price: string;
  description?: string;
  active?: boolean;
}

// Certificate Types
export interface Certificate {
  certificate: string;
  name: string;
  value: string;
  validUses: number;
  usesRemaining: number;
  expirationDate: string | null;
}

export interface CreateCertificateParams {
  certificate: string;
  name: string;
  value: string;
  validUses?: number;
  expirationDate?: string;
}

// Coupon Types
export interface Coupon {
  id: number;
  code: string;
  discount: string;
  discountAmount: string;
  expirationDate: string | null;
  appointmentTypeIDs: number[];
}

export interface CreateCouponParams {
  code: string;
  discount: string;
  appointmentTypeIDs?: number[];
  expirationDate?: string;
}

// Form Types
export interface Form {
  id: number;
  name: string;
  description: string;
  fields: FormField[];
}

export interface FormField {
  id: number;
  name: string;
  type: string;
  required: boolean;
  options?: string[];
}

export interface CreateFormParams {
  name: string;
  description?: string;
}

// Label Types
export interface Label {
  id: number;
  name: string;
  color: string;
}

export interface CreateLabelParams {
  name: string;
  color?: string;
}

// Package Types
export interface Package {
  id: number;
  name: string;
  price: string;
  numberOfSessions: number;
  appointmentTypeIDs: number[];
}

export interface CreatePackageParams {
  name: string;
  price: string;
  numberOfSessions: number;
  appointmentTypeIDs: number[];
}

// Subscription Types
export interface Subscription {
  id: number;
  name: string;
  price: string;
  frequency: string;
  appointmentTypeIDs: number[];
}

export interface CreateSubscriptionParams {
  name: string;
  price: string;
  frequency: string;
  appointmentTypeIDs: number[];
}

// Pagination
export interface PaginationParams {
  max?: number;
  offset?: number;
  minDate?: string;
  maxDate?: string;
}

// API Response wrapper
export interface ApiResponse<T> {
  data: T;
  status: number;
}

export interface PaginatedResponse<T> {
  data: T[];
  count: number;
  hasMore: boolean;
}
