import { AcuityClient } from '../clients/acuity.js';

export const appointmentTypeTools = [
  {
    name: 'acuity_list_appointment_types',
    description: 'List all appointment types',
    inputSchema: {
      type: 'object',
      properties: {},
    },
    handler: async (args: any, client: AcuityClient) => {
      const types = await client.getAppointmentTypes();
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(types, null, 2),
          },
        ],
      };
    },
  },
  {
    name: 'acuity_get_appointment_type',
    description: 'Get a specific appointment type by ID',
    inputSchema: {
      type: 'object',
      properties: {
        id: {
          type: 'number',
          description: 'Appointment Type ID',
        },
      },
      required: ['id'],
    },
    handler: async (args: any, client: AcuityClient) => {
      const type = await client.getAppointmentType(args.id);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(type, null, 2),
          },
        ],
      };
    },
  },
  {
    name: 'acuity_create_appointment_type',
    description: 'Create a new appointment type',
    inputSchema: {
      type: 'object',
      properties: {
        name: {
          type: 'string',
          description: 'Appointment type name',
        },
        duration: {
          type: 'number',
          description: 'Duration in minutes',
        },
        calendarIDs: {
          type: 'array',
          items: { type: 'number' },
          description: 'Array of calendar IDs',
        },
        price: {
          type: 'string',
          description: 'Price (e.g., "50.00")',
        },
        description: {
          type: 'string',
          description: 'Description',
        },
        category: {
          type: 'string',
          description: 'Category name',
        },
        color: {
          type: 'string',
          description: 'Color hex code',
        },
        private: {
          type: 'boolean',
          description: 'Whether type is private',
        },
        paddingBefore: {
          type: 'number',
          description: 'Padding before in minutes',
        },
        paddingAfter: {
          type: 'number',
          description: 'Padding after in minutes',
        },
      },
      required: ['name', 'duration', 'calendarIDs'],
    },
    handler: async (args: any, client: AcuityClient) => {
      const type = await client.createAppointmentType(args);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(type, null, 2),
          },
        ],
      };
    },
  },
  {
    name: 'acuity_update_appointment_type',
    description: 'Update an existing appointment type',
    inputSchema: {
      type: 'object',
      properties: {
        id: {
          type: 'number',
          description: 'Appointment Type ID',
        },
        name: {
          type: 'string',
          description: 'Updated name',
        },
        duration: {
          type: 'number',
          description: 'Updated duration in minutes',
        },
        price: {
          type: 'string',
          description: 'Updated price',
        },
        description: {
          type: 'string',
          description: 'Updated description',
        },
        category: {
          type: 'string',
          description: 'Updated category',
        },
      },
      required: ['id'],
    },
    handler: async (args: any, client: AcuityClient) => {
      const { id, ...updateParams } = args;
      const type = await client.updateAppointmentType(id, updateParams);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(type, null, 2),
          },
        ],
      };
    },
  },
  {
    name: 'acuity_delete_appointment_type',
    description: 'Delete an appointment type',
    inputSchema: {
      type: 'object',
      properties: {
        id: {
          type: 'number',
          description: 'Appointment Type ID to delete',
        },
      },
      required: ['id'],
    },
    handler: async (args: any, client: AcuityClient) => {
      await client.deleteAppointmentType(args.id);
      return {
        content: [
          {
            type: 'text',
            text: `Appointment type ${args.id} deleted successfully`,
          },
        ],
      };
    },
  },
];
