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