This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
import { apiRequest } from "@/lib/api/api-service";
|
||||
import { ApiResponse } from "@/types/api-response";
|
||||
import {
|
||||
CreateCouponDto,
|
||||
SuggestCouponDto,
|
||||
AnalyzeMatchDto,
|
||||
CouponResponseDto,
|
||||
CouponHistoryDto,
|
||||
UserBettingStatsDto,
|
||||
MatchAnalysisResultDto,
|
||||
DailyBankoResponseDto,
|
||||
SmartCouponResultDto,
|
||||
} from "./types";
|
||||
|
||||
/**
|
||||
* Coupons Service
|
||||
* Backend: /api/coupon/*
|
||||
*/
|
||||
|
||||
const analyzeMatch = (dto: AnalyzeMatchDto) => {
|
||||
return apiRequest<ApiResponse<MatchAnalysisResultDto>>({
|
||||
url: "/coupon/analyze",
|
||||
client: "core",
|
||||
method: "post",
|
||||
data: dto,
|
||||
});
|
||||
};
|
||||
|
||||
const createCoupon = (dto: CreateCouponDto) => {
|
||||
return apiRequest<ApiResponse<CouponResponseDto>>({
|
||||
url: "/coupon",
|
||||
client: "core",
|
||||
method: "post",
|
||||
data: dto,
|
||||
});
|
||||
};
|
||||
|
||||
const getDailyBanko = (matchIds: string[]) => {
|
||||
return apiRequest<ApiResponse<DailyBankoResponseDto>>({
|
||||
url: "/coupon/daily-banko",
|
||||
client: "core",
|
||||
method: "post",
|
||||
data: { matchIds },
|
||||
});
|
||||
};
|
||||
|
||||
const getHistory = (limit: number) => {
|
||||
return apiRequest<ApiResponse<CouponHistoryDto>>({
|
||||
url: "/coupon/history",
|
||||
client: "core",
|
||||
method: "get",
|
||||
params: { limit },
|
||||
});
|
||||
};
|
||||
|
||||
const getUserStats = () => {
|
||||
return apiRequest<ApiResponse<UserBettingStatsDto>>({
|
||||
url: "/coupon/my-stats",
|
||||
client: "core",
|
||||
method: "get",
|
||||
});
|
||||
};
|
||||
|
||||
const suggestCoupon = (dto: SuggestCouponDto) => {
|
||||
return apiRequest<ApiResponse<SmartCouponResultDto>>({
|
||||
url: "/coupon/suggest",
|
||||
client: "core",
|
||||
method: "post",
|
||||
data: dto,
|
||||
});
|
||||
};
|
||||
|
||||
export const couponsService = {
|
||||
analyzeMatch,
|
||||
createCoupon,
|
||||
getDailyBanko,
|
||||
getHistory,
|
||||
getUserStats,
|
||||
suggestCoupon,
|
||||
};
|
||||
Reference in New Issue
Block a user