fix finance balance delta recharges
This commit is contained in:
@@ -68,6 +68,8 @@ export const authApi = {
|
||||
}
|
||||
|
||||
// ——— Upstreams ———
|
||||
export type FinanceCostMode = 'usage_stats' | 'balance_delta'
|
||||
|
||||
export interface UpstreamData {
|
||||
id: number
|
||||
name: string
|
||||
@@ -89,6 +91,7 @@ export interface UpstreamData {
|
||||
balance_response_path: string
|
||||
balance_divisor: number
|
||||
balance_alert_threshold: number | null
|
||||
finance_cost_mode: FinanceCostMode
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
@@ -108,6 +111,7 @@ export interface UpstreamForm {
|
||||
balance_response_path: string
|
||||
balance_divisor: number
|
||||
balance_alert_threshold: number | null
|
||||
finance_cost_mode: FinanceCostMode
|
||||
}
|
||||
|
||||
export interface GeneratedUpstreamKey {
|
||||
@@ -128,6 +132,16 @@ export interface GeneratedUpstreamKey {
|
||||
has_key_value: boolean
|
||||
}
|
||||
|
||||
export interface UpstreamRecharge {
|
||||
id: number
|
||||
upstream_id: number
|
||||
date: string
|
||||
amount: number
|
||||
note: string
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface GenerateKeysByGroupsForm {
|
||||
group_ids: string[]
|
||||
name_prefix: string
|
||||
@@ -169,6 +183,14 @@ export const upstreamsApi = {
|
||||
test: (id: number) => api.post<{ success: boolean; message: string; detail?: string }>(`/api/upstreams/${id}/test`),
|
||||
checkNow: (id: number) => api.post<{ success: boolean; message: string }>(`/api/upstreams/${id}/check-now`),
|
||||
generatedKeys: (id: number) => api.get<GeneratedUpstreamKey[]>(`/api/upstreams/${id}/generated-keys`),
|
||||
listRecharges: (id: number, date?: string) =>
|
||||
api.get<UpstreamRecharge[]>(`/api/upstreams/${id}/recharges`, { params: date ? { date } : undefined }),
|
||||
createRecharge: (id: number, data: { date: string; amount: number; note?: string }) =>
|
||||
api.post<UpstreamRecharge>(`/api/upstreams/${id}/recharges`, data),
|
||||
updateRecharge: (id: number, rechargeId: number, data: { date?: string; amount?: number; note?: string }) =>
|
||||
api.put<UpstreamRecharge>(`/api/upstreams/${id}/recharges/${rechargeId}`, data),
|
||||
deleteRecharge: (id: number, rechargeId: number) =>
|
||||
api.delete(`/api/upstreams/${id}/recharges/${rechargeId}`),
|
||||
generateKeysByGroups: (id: number, data: GenerateKeysByGroupsForm) =>
|
||||
api.post<{ success: boolean; message: string; items: GeneratedUpstreamKey[] }>(`/api/upstreams/${id}/keys/generate-by-groups`, data),
|
||||
latestSnapshot: (id: number) => api.get(`/api/upstreams/${id}/snapshots/latest`),
|
||||
|
||||
Reference in New Issue
Block a user