This commit is contained in:
2026-08-04 21:01:39 +08:00
parent 88bd939170
commit 5cb1ca307d
77 changed files with 9914 additions and 131 deletions
+35
View File
@@ -0,0 +1,35 @@
import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
import type { AdjustPublishedInboundFeeRequest, InboundFeeSnapshot } from './types'
function feeBasePath(inboundId: string) {
return `/platform/v1/inbounds/${encodeURIComponent(inboundId)}/fees`
}
export async function getLatestInboundFee(tenantId: string, inboundId: string) {
const response = await http.get<unknown, ApiEnvelope<InboundFeeSnapshot>>(
`${feeBasePath(inboundId)}/latest`,
{ params: { tenantId } },
)
return unwrapApiResponse(response)
}
export async function adjustPublishedInboundFee(
tenantId: string,
inboundId: string,
payload: AdjustPublishedInboundFeeRequest,
idempotencyKey: string,
) {
const response = await http.put<unknown, ApiEnvelope<InboundFeeSnapshot>>(
`${feeBasePath(inboundId)}/published`,
payload,
{ params: { tenantId }, headers: { 'Idempotency-Key': idempotencyKey } },
)
return unwrapApiResponse(response)
}
export function createFeeAdjustmentIdempotencyKey() {
const uuid = globalThis.crypto?.randomUUID?.()
if (uuid) return `fee-adjust-${uuid}`
return `fee-adjust-${Date.now()}-${Math.random().toString(36).slice(2, 12)}`
}