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

export const certificateTools = [
  {
    name: 'acuity_list_certificates',
    description: 'List all gift certificates',
    inputSchema: {
      type: 'object',
      properties: {},
    },
    handler: async (args: any, client: AcuityClient) => {
      const certificates = await client.getCertificates();
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(certificates, null, 2),
          },
        ],
      };
    },
  },
  {
    name: 'acuity_get_certificate',
    description: 'Get a specific certificate by code',
    inputSchema: {
      type: 'object',
      properties: {
        code: {
          type: 'string',
          description: 'Certificate code',
        },
      },
      required: ['code'],
    },
    handler: async (args: any, client: AcuityClient) => {
      const certificate = await client.getCertificate(args.code);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(certificate, null, 2),
          },
        ],
      };
    },
  },
  {
    name: 'acuity_create_certificate',
    description: 'Create a new gift certificate',
    inputSchema: {
      type: 'object',
      properties: {
        certificate: {
          type: 'string',
          description: 'Certificate code/identifier',
        },
        name: {
          type: 'string',
          description: 'Certificate holder name',
        },
        value: {
          type: 'string',
          description: 'Certificate value (e.g., "100.00")',
        },
        validUses: {
          type: 'number',
          description: 'Number of valid uses',
        },
        expirationDate: {
          type: 'string',
          description: 'Expiration date (YYYY-MM-DD)',
        },
      },
      required: ['certificate', 'name', 'value'],
    },
    handler: async (args: any, client: AcuityClient) => {
      const certificate = await client.createCertificate(args);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(certificate, null, 2),
          },
        ],
      };
    },
  },
  {
    name: 'acuity_delete_certificate',
    description: 'Delete a gift certificate',
    inputSchema: {
      type: 'object',
      properties: {
        code: {
          type: 'string',
          description: 'Certificate code to delete',
        },
      },
      required: ['code'],
    },
    handler: async (args: any, client: AcuityClient) => {
      await client.deleteCertificate(args.code);
      return {
        content: [
          {
            type: 'text',
            text: `Certificate ${args.code} deleted successfully`,
          },
        ],
      };
    },
  },
];
