import { apiClient } from './apiClient';

export interface ApiKeyInfo {
  apiKey: string;
}

class ApiKeyService {
  /**
   * Get current user's API key (creates one if not exists)
   */
  async getApiKey(): Promise<ApiKeyInfo> {
    const response = await apiClient.get<ApiKeyInfo>('/users/api-key');
    return response.data;
  }

  /**
   * Regenerate API key for current user
   */
  async regenerateApiKey(): Promise<ApiKeyInfo> {
    const response = await apiClient.post<ApiKeyInfo>('/users/api-key/rotate');
    return response.data;
  }
}

export const apiKeyService = new ApiKeyService();
