/**
 * License API Service
 * 
 * License activation, deactivation, and feature checking
 */

import { api } from './api';
import type {
  LicenseInfo,
  LicenseActivationResponse,
  LicenseDeactivationResponse,
  FeatureCheckResponse,
} from '../types/license';

/**
 * Get license information
 */
export async function getLicenseInfo(): Promise<{ success: boolean; data: LicenseInfo }> {
  const response = await api.get('/license/info');
  return response.data;
}

/**
 * Activate license key
 */
export async function activateLicense(
  licenseKey: string
): Promise<LicenseActivationResponse> {
  const response = await api.post('/license/activate', {
    license_key: licenseKey,
  });
  return response.data;
}

/**
 * Deactivate license key
 */
export async function deactivateLicense(): Promise<LicenseDeactivationResponse> {
  const response = await api.post('/license/deactivate');
  return response.data;
}

/**
 * Check if a specific feature is available
 */
export async function checkFeature(
  feature: string
): Promise<FeatureCheckResponse> {
  const response = await api.get('/license/check-feature', {
    params: { feature },
  });
  return response.data;
}
