/**
 * 店铺套餐分配 API 服务
 */

import { BaseService } from '../BaseService'
import type {
  BaseResponse,
  CreateShopPackageAllocationRequest,
  ShopPackageAllocationResponse,
  UpdateShopPackageAllocationExpiryBaseRequest
} from '@/types/api'

export class ShopPackageAllocationService extends BaseService {
  /**
   * 创建店铺套餐分配
   * POST /api/admin/shop-package-allocations
   */
  static createShopPackageAllocation(
    data: CreateShopPackageAllocationRequest
  ): Promise<BaseResponse<ShopPackageAllocationResponse>> {
    return this.post<BaseResponse<ShopPackageAllocationResponse>>(
      '/api/admin/shop-package-allocations',
      data
    )
  }

  /**
   * 更新店铺套餐分配生效条件
   * PATCH /api/admin/shop-package-allocations/{id}/expiry-base
   */
  static updateShopPackageAllocationExpiryBase(
    id: number,
    data: UpdateShopPackageAllocationExpiryBaseRequest
  ): Promise<BaseResponse<ShopPackageAllocationResponse>> {
    return this.patch<BaseResponse<ShopPackageAllocationResponse>>(
      `/api/admin/shop-package-allocations/${id}/expiry-base`,
      data
    )
  }
}
