import request from '@/utils/http'
import type {
  BulkPurchaseCreateApiResponse,
  BulkPurchaseItemsApiResponse,
  BulkPurchaseTaskApiResponse
} from '@/types/api'

export class BulkPurchaseService {
  static createTask(data: FormData): Promise<BulkPurchaseCreateApiResponse> {
    return request.post<BulkPurchaseCreateApiResponse>({
      url: '/api/admin/bulk-purchases',
      data
    })
  }

  static getTask(taskId: number): Promise<BulkPurchaseTaskApiResponse> {
    return request.get<BulkPurchaseTaskApiResponse>({
      url: `/api/admin/bulk-purchases/${taskId}`
    })
  }

  static getItems(
    taskId: number,
    params?: { page?: number; size?: number; status?: string | number }
  ): Promise<BulkPurchaseItemsApiResponse> {
    return request.get<BulkPurchaseItemsApiResponse>({
      url: `/api/admin/bulk-purchases/${taskId}/items`,
      params
    })
  }
}
