import api from './client'; import type { MessageResponse, PaginatedResponse, WeiboAccountItem, WeiboAccountCkResult, WeiboBatchTagResult, WeiboBindQrResult, WeiboExchangeRecordsResult, WeiboExchangeResult, WeiboMallListResult, WeiboPaymentStatusResult, WeiboPointHistoryResult, WeiboRechargeOrderResult, WeiboImportResult, WeiboWorkbenchMutationResult, } from './types'; export const weiboApi = { listAccounts: (params: { search?: string; bind_status?: string; enabled?: boolean; page: number; page_size: number; }) => api.get, PaginatedResponse>( '/weibo/accounts', { params }, ), getAccount: (accountId: number) => api.get(`/weibo/accounts/${accountId}`), importCookies: (text: string, tag = '') => api.post('/weibo/accounts/import-cookies', { text, tag, }), updateAccount: ( accountId: number, data: { tag?: string; remark?: string }, ) => api.put( `/weibo/accounts/${accountId}`, data, ), disableAccount: (accountId: number, reason = '') => api.post( `/weibo/accounts/${accountId}/disable`, { reason }, ), enableAccount: (accountId: number) => api.post( `/weibo/accounts/${accountId}/enable`, undefined, { timeout: 120000 }, ), refreshAccount: (accountId: number) => api.post( `/weibo/accounts/${accountId}/refresh`, ), copyAccountCk: (accountId: number) => api.post( `/weibo/accounts/${accountId}/ck/copy`, ), batchTagAccounts: (ids: number[], tag: string) => api.post( '/weibo/accounts/batch-tag', { ids, tag }, ), listWorkbenchAccounts: (params: { search?: string; bind_status?: string; enabled?: boolean; page: number; page_size: number; }) => api.get, PaginatedResponse>( '/weibo/workbench/accounts', { params }, ), listWorkbenchPool: (params: { search?: string; page: number; page_size: number; }) => api.get, PaginatedResponse>( '/weibo/workbench/pool', { params }, ), addWorkbenchAccounts: (accountIds: number[]) => api.post( '/weibo/workbench/accounts', { account_ids: accountIds }, ), removeWorkbenchAccounts: (accountIds: number[]) => api.post( '/weibo/workbench/accounts/remove', { account_ids: accountIds }, ), bindQrcodes: (accountId: number, channel: 'wx' | 'qq') => api.post( `/weibo/accounts/${accountId}/bind-qrcodes`, undefined, { params: { channel }, timeout: 60000 }, ), mallList: (accountId: number) => api.post( `/weibo/accounts/${accountId}/mall-list`, undefined, { timeout: 60000 }, ), exchangeGoods: (accountId: number, goodsId: number, expectedPrice: number) => api.post( `/weibo/accounts/${accountId}/exchange`, { goods_id: goodsId, expected_price: expectedPrice, confirm: true, }, { timeout: 120000 }, ), exchangeRecords: (accountId: number, page = 1, pageSize = 20) => api.post( `/weibo/accounts/${accountId}/exchange-records`, undefined, { params: { page, page_size: pageSize }, timeout: 60000 }, ), pointHistory: (accountId: number, page = 1, pageSize = 20) => api.post( `/weibo/accounts/${accountId}/point-history`, undefined, { params: { page, page_size: pageSize }, timeout: 60000 }, ), createRechargeOrder: (accountId: number, amountYuan: number) => api.post( `/weibo/accounts/${accountId}/recharge/orders`, { amount_yuan: amountYuan }, { timeout: 120000 }, ), rechargeStatus: (accountId: number, payId: string) => api.post( `/weibo/accounts/${accountId}/recharge/status`, { pay_id: payId }, { timeout: 30000 }, ), deleteAccount: (accountId: number) => api.delete(`/weibo/accounts/${accountId}`), };