mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-11-04 08:43:20 +00:00
8 files changed
+361
-39
No files matched your search
@@ -23,6 +23,7 @@ import type {
|
||||
CheckMixedChannelResponse,
|
||||
UpstreamBillingProbeResult,
|
||||
UpstreamBillingProbeSettings,
|
||||
UpstreamBillingRatesResponse,
|
||||
OllamaCloudUsageSettings,
|
||||
OllamaCloudUsageState
|
||||
} from '@/types'
|
||||
@@ -70,6 +71,45 @@ export interface AccountListWithEtagResult {
|
||||
data: PaginatedResponse<Account> | null
|
||||
}
|
||||
|
||||
export interface AccountUpstreamBillingRatesWithEtagResult {
|
||||
notModified: boolean
|
||||
etag: string | null
|
||||
data: UpstreamBillingRatesResponse | null
|
||||
}
|
||||
|
||||
export async function getUpstreamBillingRatesWithEtag(
|
||||
page: number = 1,
|
||||
pageSize: number = 20,
|
||||
filters?: {
|
||||
platform?: string
|
||||
type?: string
|
||||
status?: string
|
||||
group?: string
|
||||
search?: string
|
||||
privacy_mode?: string
|
||||
sort_by?: string
|
||||
sort_order?: 'asc' | 'desc'
|
||||
},
|
||||
options?: {
|
||||
signal?: AbortSignal
|
||||
etag?: string | null
|
||||
}
|
||||
): Promise<AccountUpstreamBillingRatesWithEtagResult> {
|
||||
const headers: Record<string, string> = {}
|
||||
if (options?.etag) headers['If-None-Match'] = options.etag
|
||||
|
||||
const response = await apiClient.get<UpstreamBillingRatesResponse>('/admin/accounts/upstream-billing-rates', {
|
||||
params: { page, page_size: pageSize, ...filters },
|
||||
headers,
|
||||
signal: options?.signal,
|
||||
validateStatus: (status) => (status >= 200 && status < 300) || status === 304
|
||||
})
|
||||
|
||||
const etagHeader = typeof response.headers?.etag === 'string' ? response.headers.etag : null
|
||||
if (response.status === 304) return { notModified: true, etag: etagHeader, data: null }
|
||||
return { notModified: false, etag: etagHeader, data: response.data }
|
||||
}
|
||||
|
||||
export async function listWithEtag(
|
||||
page: number = 1,
|
||||
pageSize: number = 20,
|
||||
@@ -1008,6 +1048,7 @@ export async function refreshOllamaCloudUsage(id: number): Promise<OllamaCloudUs
|
||||
export const accountsAPI = {
|
||||
list,
|
||||
listWithEtag,
|
||||
getUpstreamBillingRatesWithEtag,
|
||||
getById,
|
||||
create,
|
||||
duplicate,
|
||||
|
||||
Reference in new issue
Block a user