import api from './client'; import type { AssignmentsSummary, MessageResponse, PaginatedResponse, WeiboAccountItem, WeiboAccountCkResult, WeiboBatchTagResult, WeiboBindQrResult, WeiboExchangeRecordsResult, WeiboExchangeResult, WeiboForceAssignResult, WeiboMallListResult, WeiboPaymentStatusResult, WeiboPointHistoryResult, WeiboRechargeOrderResult, WeiboImportResult, WeiboWorkbenchMutationResult, WeiboWorkbenchBatchImportResult, WeiboWorkbenchTransferToCollabResult, } from './types'; export const weiboApi = { listAccounts: (params: { search?: string; tag?: string; bind_status?: string; enabled?: boolean; assign_status?: string; assigned_user_id?: number; page: number; page_size: number; }) => api.get, PaginatedResponse>( '/weibo/accounts', { params }, ), listAccountIds: (params: { search?: string; tag?: string; bind_status?: string; enabled?: boolean; assign_status?: string; assigned_user_id?: number; }) => api.get<{ account_ids: number[]; total: number }, { account_ids: number[]; total: number }>( '/weibo/accounts/ids', { params }, ), getAccount: (accountId: number) => api.get(`/weibo/accounts/${accountId}`), importCookies: ( text: string, tag = '', updateExisting = false, forceUpdate = false, ) => api.post('/weibo/accounts/import-cookies', { text, tag, update_existing: updateExisting, force_update: forceUpdate, }), 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: 600000 }, ), 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 }, ), batchAssign: (accountIds: number[], assignedTo: number | null) => api.post('/weibo/accounts/batch-assign', { account_ids: accountIds, assigned_to: assignedTo, }), forceAssign: ( assignedTo: number, expectedCount: number, scope: { accountIds: number[] } | { tag: string }, ) => api.post( '/weibo/assignments/force', { assigned_to: assignedTo, expected_count: expectedCount, ...('accountIds' in scope ? { account_ids: scope.accountIds } : { tag: scope.tag }), }, ), assignmentsSummary: () => api.get('/weibo/assignments/summary'), accountTags: () => api.get<{ tags: string[] }, { tags: string[] }>('/weibo/accounts/tags'), workbenchTags: () => api.get<{ tags: string[] }, { tags: string[] }>('/weibo/workbench/tags'), listWorkbenchAccounts: (params: { search?: string; tag?: string; bind_status?: string; enabled?: boolean; page: number; page_size: number; }) => api.get, PaginatedResponse>( '/weibo/workbench/accounts', { params }, ), listWorkbenchPool: (params: { search?: string; tag?: string; page: number; page_size: number; }) => api.get, PaginatedResponse>( '/weibo/workbench/pool', { params }, ), addWorkbenchAccounts: (accountIds: number[]) => api.post( '/weibo/workbench/accounts', { account_ids: accountIds }, ), batchImportWorkbenchAccounts: (text: string, forceAddOccupied = false) => api.post( '/weibo/workbench/accounts/batch-import', { text, force_add_occupied: forceAddOccupied }, ), transferWorkbenchToCollab: (accountId: number) => api.post< WeiboWorkbenchTransferToCollabResult, WeiboWorkbenchTransferToCollabResult >('/weibo/workbench/accounts/transfer-to-collab', { account_id: accountId, }), 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: 45000 }, ), deleteAccount: (accountId: number) => api.delete(`/weibo/accounts/${accountId}`), };