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

export const clientTools = [
  {
    name: 'acuity_list_clients',
    description: 'List all clients with optional pagination',
    inputSchema: {
      type: 'object',
      properties: {
        max: {
          type: 'number',
          description: 'Maximum number of clients to return',
        },
        offset: {
          type: 'number',
          description: 'Offset for pagination',
        },
      },
    },
    handler: async (args: any, client: AcuityClient) => {
      const clients = await client.getClients(args);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(clients, null, 2),
          },
        ],
      };
    },
  },
  {
    name: 'acuity_get_client',
    description: 'Get a specific client by ID',
    inputSchema: {
      type: 'object',
      properties: {
        id: {
          type: 'number',
          description: 'Client ID',
        },
      },
      required: ['id'],
    },
    handler: async (args: any, client: AcuityClient) => {
      const clientData = await client.getClient(args.id);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(clientData, null, 2),
          },
        ],
      };
    },
  },
  {
    name: 'acuity_create_client',
    description: 'Create a new client',
    inputSchema: {
      type: 'object',
      properties: {
        firstName: {
          type: 'string',
          description: 'Client first name',
        },
        lastName: {
          type: 'string',
          description: 'Client last name',
        },
        email: {
          type: 'string',
          description: 'Client email address',
        },
        phone: {
          type: 'string',
          description: 'Client phone number',
        },
        notes: {
          type: 'string',
          description: 'Notes about the client',
        },
      },
      required: ['firstName', 'lastName', 'email'],
    },
    handler: async (args: any, client: AcuityClient) => {
      const clientData = await client.createClient(args);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(clientData, null, 2),
          },
        ],
      };
    },
  },
  {
    name: 'acuity_update_client',
    description: 'Update an existing client',
    inputSchema: {
      type: 'object',
      properties: {
        id: {
          type: 'number',
          description: 'Client ID',
        },
        firstName: {
          type: 'string',
          description: 'Updated first name',
        },
        lastName: {
          type: 'string',
          description: 'Updated last name',
        },
        email: {
          type: 'string',
          description: 'Updated email',
        },
        phone: {
          type: 'string',
          description: 'Updated phone',
        },
        notes: {
          type: 'string',
          description: 'Updated notes',
        },
      },
      required: ['id'],
    },
    handler: async (args: any, client: AcuityClient) => {
      const { id, ...updateParams } = args;
      const clientData = await client.updateClient(id, updateParams);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(clientData, null, 2),
          },
        ],
      };
    },
  },
  {
    name: 'acuity_delete_client',
    description: 'Delete a client',
    inputSchema: {
      type: 'object',
      properties: {
        id: {
          type: 'number',
          description: 'Client ID to delete',
        },
      },
      required: ['id'],
    },
    handler: async (args: any, client: AcuityClient) => {
      await client.deleteClient(args.id);
      return {
        content: [
          {
            type: 'text',
            text: `Client ${args.id} deleted successfully`,
          },
        ],
      };
    },
  },
];
