import request from './request'
import type { SyncLog } from '@/types'

export const syncApi = {
  syncProducts: () => {
    return request.post<any, { message: string }>('/sync/products')
  },

  syncCategories: () => {
    return request.post<any, { message: string }>('/sync/categories')
  },

  syncProductDetails: () => {
    return request.post<any, { message: string }>('/sync/product-details')
  },

  syncOneProductDetail: (goodId: string) => {
    return request.post<any, { goodId: string; variants: number; detailSyncedAt: string }>(
      `/sync/products/${goodId}/detail`,
    )
  },

  getSyncStatus: (limit?: number) => {
    return request.get<any, SyncLog[]>('/sync/status', {
      params: limit ? { limit } : undefined,
    })
  },
}
