import client from './client' import type { ShopItem, ShopItemType, InventoryItem, PurchaseResponse, UseConsumableRequest, UseConsumableResponse, CoinsBalance, CoinTransaction, ConsumablesStatus, UserCosmetics, SwapCandidate, } from '@/types' export const shopApi = { // === Каталог товаров === // Получить список товаров getItems: async (itemType?: ShopItemType): Promise => { const params = itemType ? { item_type: itemType } : {} const response = await client.get('/shop/items', { params }) return response.data }, // Получить товар по ID getItem: async (itemId: number): Promise => { const response = await client.get(`/shop/items/${itemId}`) return response.data }, // === Покупки === // Купить товар purchase: async (itemId: number, quantity: number = 1): Promise => { const response = await client.post('/shop/purchase', { item_id: itemId, quantity, }) return response.data }, // === Инвентарь === // Получить инвентарь пользователя getInventory: async (itemType?: ShopItemType): Promise => { const params = itemType ? { item_type: itemType } : {} const response = await client.get('/shop/inventory', { params }) return response.data }, // === Экипировка === // Экипировать предмет equip: async (inventoryId: number): Promise<{ success: boolean; message: string }> => { const response = await client.post<{ success: boolean; message: string }>('/shop/equip', { inventory_id: inventoryId, }) return response.data }, // Снять предмет unequip: async (itemType: ShopItemType): Promise<{ success: boolean; message: string }> => { const response = await client.post<{ success: boolean; message: string }>(`/shop/unequip/${itemType}`) return response.data }, // Получить экипированную косметику getCosmetics: async (): Promise => { const response = await client.get('/shop/cosmetics') return response.data }, // === Расходуемые === // Использовать расходуемый предмет useConsumable: async (data: UseConsumableRequest): Promise => { const response = await client.post('/shop/use', data) return response.data }, // Получить статус расходуемых в марафоне getConsumablesStatus: async (marathonId: number): Promise => { const response = await client.get(`/shop/consumables/${marathonId}`) return response.data }, // Получить кандидатов для Copycat (участники с активными заданиями) getCopycatCandidates: async (marathonId: number): Promise => { const response = await client.get(`/shop/copycat-candidates/${marathonId}`) return response.data }, // === Монеты === // Получить баланс и последние транзакции getBalance: async (): Promise => { const response = await client.get('/shop/balance') return response.data }, // Получить историю транзакций getTransactions: async (limit: number = 50, offset: number = 0): Promise => { const response = await client.get('/shop/transactions', { params: { limit, offset }, }) return response.data }, }