/* eslint-disable */
import request from "@workspace/ui/lib/request";

/** Create promo rule POST /v1/admin/promo/rule */
export async function createPromoRule(
  body: API.CreatePromoRuleRequest,
  options?: Record<string, unknown>
) {
  return request<API.Response & { data?: API.PromoRule }>(
    `${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/promo/rule`,
    {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
      },
      data: body,
      ...(options || {}),
    }
  );
}

/** Get promo rule list GET /v1/admin/promo/rule/list */
export async function getPromoRuleList(
  params: API.GetPromoRuleListParams,
  options?: Record<string, unknown>
) {
  return request<API.Response & { data?: API.GetPromoRuleListResponse }>(
    `${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/promo/rule/list`,
    {
      method: "GET",
      params: {
        ...params,
      },
      ...(options || {}),
    }
  );
}

/** Get promo rule detail GET /v1/admin/promo/rule/:id */
export async function getPromoRuleDetail(
  params: API.GetPromoRuleDetailParams,
  options?: Record<string, unknown>
) {
  return request<API.Response & { data?: API.PromoRule }>(
    `${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/promo/rule/${params.id}`,
    {
      method: "GET",
      ...(options || {}),
    }
  );
}

/** Update promo rule PUT /v1/admin/promo/rule/:id */
export async function updatePromoRule(
  params: API.UpdatePromoRuleParams,
  body: API.UpdatePromoRuleRequest,
  options?: Record<string, unknown>
) {
  return request<API.Response & { data?: API.PromoRule }>(
    `${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/promo/rule/${params.id}`,
    {
      method: "PUT",
      headers: {
        "Content-Type": "application/json",
      },
      data: body,
      ...(options || {}),
    }
  );
}

/** Delete promo rule DELETE /v1/admin/promo/rule/:id */
export async function deletePromoRule(
  params: API.DeletePromoRuleParams,
  options?: Record<string, unknown>
) {
  return request<API.Response & { data?: unknown }>(
    `${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/promo/rule/${params.id}`,
    {
      method: "DELETE",
      ...(options || {}),
    }
  );
}

/** Create promo price POST /v1/admin/promo/price */
export async function createPromoPrice(
  body: API.CreatePromoPriceRequest,
  options?: Record<string, unknown>
) {
  return request<API.Response & { data?: API.PromoPrice }>(
    `${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/promo/price`,
    {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
      },
      data: body,
      ...(options || {}),
    }
  );
}

/** Get promo price list GET /v1/admin/promo/price/list */
export async function getPromoPriceList(
  params: API.GetPromoPriceListParams,
  options?: Record<string, unknown>
) {
  return request<API.Response & { data?: API.GetPromoPriceListResponse }>(
    `${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/promo/price/list`,
    {
      method: "GET",
      params: {
        ...params,
      },
      ...(options || {}),
    }
  );
}

/** Delete promo price DELETE /v1/admin/promo/price/:id */
export async function deletePromoPrice(
  params: API.DeletePromoPriceParams,
  options?: Record<string, unknown>
) {
  return request<API.Response & { data?: unknown }>(
    `${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/promo/price/${params.id}`,
    {
      method: "DELETE",
      ...(options || {}),
    }
  );
}

/** Get promo usage list GET /v1/admin/promo/usage/list */
export async function getPromoUsageList(
  params: API.GetPromoUsageListParams,
  options?: Record<string, unknown>
) {
  return request<API.Response & { data?: API.GetPromoUsageListResponse }>(
    `${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/promo/usage/list`,
    {
      method: "GET",
      params: {
        ...params,
      },
      ...(options || {}),
    }
  );
}
