/**
 * Classification Service - Mirror backend classification endpoints
 */
import { apiClient } from '../client';
import {
  ProductClassificationRequest,
  BatchClassificationRequest,
  ProductSuggestionResponse
} from '../types/classification';

export class ClassificationService {
  private readonly baseUrl = '/tenants';

  async classifyProduct(
    tenantId: string,
    classificationData: ProductClassificationRequest
  ): Promise<ProductSuggestionResponse> {
    return apiClient.post<ProductSuggestionResponse>(
      `${this.baseUrl}/${tenantId}/inventory/classify-product`,
      classificationData
    );
  }

  async classifyProductsBatch(
    tenantId: string,
    batchData: BatchClassificationRequest
  ): Promise<ProductSuggestionResponse[]> {
    const response = await apiClient.post<{
      suggestions: ProductSuggestionResponse[];
      business_model_analysis: any;
      total_products: number;
      high_confidence_count: number;
      low_confidence_count: number;
    }>(
      `${this.baseUrl}/${tenantId}/inventory/classify-products-batch`,
      batchData
    );
    // Extract just the suggestions array from the response
    return response.suggestions;
  }

}

export const classificationService = new ClassificationService();