import { apiRequest } from "@/shared/api/request"; import { API_ENDPOINTS, API_OPERATIONS, apiEndpointPath } from "@/shared/api/generated/endpoints"; import type { ApiPage, CoinAdjustmentCreateDto, CoinAdjustmentDto, CoinAdjustmentPayload, CoinLedgerEntryDto, CoinLedgerUserDto, CoinSellerLedgerDto, PageQuery, ReportDto, } from "@/shared/api/types"; export interface GiftDiamondRatioItem { effectiveRegionId: number; giftTypeCode: string; ratioPercent: string; regionId: number; status: string; updatedAtMs?: number; } export interface GiftDiamondRatioResponse { regionId: number; items: GiftDiamondRatioItem[]; } export interface FullServerNoticeFanoutPayload { action_param?: string; action_type?: string; aggregate_id?: string; aggregate_type?: string; batch_size?: number; body?: string; command_id?: string; country?: string; expire_at_ms?: number; icon_url?: string; image_url?: string; message_type: "system" | "activity"; metadata_json?: string; priority?: number; producer_event_type?: string; region_id?: number; sent_at_ms?: number; summary: string; target_scope: "all_active_users" | "single_user" | "user_ids" | "region" | "country"; target_user_id?: number; title: string; user_ids?: number[]; } export interface FullServerNoticeFanoutResponse { command_id: string; created: boolean; job_id: string; message_type: string; status: string; target_scope: string; } export function listCoinLedger(query: PageQuery = {}): Promise> { const endpoint = API_ENDPOINTS.listCoinLedger; return apiRequest>(apiEndpointPath(API_OPERATIONS.listCoinLedger), { method: endpoint.method, query, }); } export function listCoinSellerLedger(query: PageQuery = {}): Promise> { const endpoint = API_ENDPOINTS.listCoinSellerLedger; return apiRequest>(apiEndpointPath(API_OPERATIONS.listCoinSellerLedger), { method: endpoint.method, query, }); } export function exportCoinSellerLedger(query: PageQuery = {}): Promise { return apiRequest("/v1/admin/operations/coin-seller-ledger/export", { method: "GET", query, raw: true, }); } export function listCoinAdjustments(query: PageQuery = {}): Promise> { const endpoint = API_ENDPOINTS.listCoinAdjustments; return apiRequest>(apiEndpointPath(API_OPERATIONS.listCoinAdjustments), { method: endpoint.method, query, }); } export function listReports(query: PageQuery = {}): Promise> { const endpoint = API_ENDPOINTS.listReports; return apiRequest>(apiEndpointPath(API_OPERATIONS.listReports), { method: endpoint.method, query, }); } export function lookupCoinAdjustmentTarget(userId: string): Promise { const endpoint = API_ENDPOINTS.lookupCoinAdjustmentTarget; return apiRequest(apiEndpointPath(API_OPERATIONS.lookupCoinAdjustmentTarget), { method: endpoint.method, query: { user_id: userId }, }); } export function createCoinAdjustment(payload: CoinAdjustmentPayload): Promise { const endpoint = API_ENDPOINTS.createCoinAdjustment; return apiRequest( apiEndpointPath(API_OPERATIONS.createCoinAdjustment), { body: payload, method: endpoint.method, }, ); } export function getGiftDiamondRatios(regionId: string | number): Promise { return apiRequest("/v1/admin/operations/gift-diamond-ratios", { method: "GET", query: { region_id: regionId }, }); } export function updateGiftDiamondRatios(payload: { regionId: number; ratios: Record; }): Promise { return apiRequest("/v1/admin/operations/gift-diamond-ratios", { body: payload, method: "PUT", }); } export function createFullServerNoticeFanout( payload: FullServerNoticeFanoutPayload, ): Promise { const endpoint = API_ENDPOINTS.createFullServerNoticeFanout; return apiRequest( apiEndpointPath(API_OPERATIONS.createFullServerNoticeFanout), { body: payload, method: endpoint.method, }, ); }