mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-31 00:24:38 +00:00
Merge pull request #4385 from yardbirds0/feat/upstream-billing-probe
feat: 增加上游 Sub2API 计费倍率探测与账号展示
This commit is contained in:
@@ -20,7 +20,9 @@ import type {
|
||||
CodexSessionImportResult,
|
||||
OpenAICodexPATCreateRequest,
|
||||
CheckMixedChannelRequest,
|
||||
CheckMixedChannelResponse
|
||||
CheckMixedChannelResponse,
|
||||
UpstreamBillingProbeResult,
|
||||
UpstreamBillingProbeSettings
|
||||
} from '@/types'
|
||||
|
||||
/**
|
||||
@@ -848,6 +850,38 @@ export async function createSparkShadow(parentId: number, payload: SparkShadowCr
|
||||
return data
|
||||
}
|
||||
|
||||
export async function getUpstreamBillingProbeSettings(): Promise<UpstreamBillingProbeSettings> {
|
||||
const { data } = await apiClient.get<UpstreamBillingProbeSettings>('/admin/accounts/upstream-billing-probe/settings')
|
||||
return data
|
||||
}
|
||||
|
||||
export async function updateUpstreamBillingProbeSettings(
|
||||
settings: UpstreamBillingProbeSettings
|
||||
): Promise<UpstreamBillingProbeSettings> {
|
||||
const { data } = await apiClient.put<UpstreamBillingProbeSettings>(
|
||||
'/admin/accounts/upstream-billing-probe/settings',
|
||||
settings
|
||||
)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function setUpstreamBillingProbeEnabled(id: number, enabled: boolean): Promise<void> {
|
||||
await apiClient.put(`/admin/accounts/${id}/upstream-billing-probe`, { enabled })
|
||||
}
|
||||
|
||||
export async function probeUpstreamBilling(id: number): Promise<UpstreamBillingProbeResult> {
|
||||
const { data } = await apiClient.post<UpstreamBillingProbeResult>(`/admin/accounts/${id}/upstream-billing-probe`)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function probeUpstreamBillingBatch(accountIds: number[]): Promise<UpstreamBillingProbeResult[]> {
|
||||
const { data } = await apiClient.post<{ results: UpstreamBillingProbeResult[] }>(
|
||||
'/admin/accounts/upstream-billing-probe/batch',
|
||||
{ account_ids: accountIds }
|
||||
)
|
||||
return data.results
|
||||
}
|
||||
|
||||
export const accountsAPI = {
|
||||
list,
|
||||
listWithEtag,
|
||||
@@ -894,7 +928,12 @@ export const accountsAPI = {
|
||||
revertProxyFallback,
|
||||
queryOpenAIQuota,
|
||||
resetOpenAIQuota,
|
||||
createSparkShadow
|
||||
createSparkShadow,
|
||||
getUpstreamBillingProbeSettings,
|
||||
updateUpstreamBillingProbeSettings,
|
||||
setUpstreamBillingProbeEnabled,
|
||||
probeUpstreamBilling,
|
||||
probeUpstreamBillingBatch
|
||||
}
|
||||
|
||||
export default accountsAPI
|
||||
|
||||
Reference in New Issue
Block a user