This commit is contained in:
2026-08-19 09:14:35 +08:00
parent c188482c24
commit 80cfca5056
36 changed files with 854 additions and 1044 deletions
+28 -2
View File
@@ -15,6 +15,28 @@ export async function getLatestInboundFee(tenantId: string, inboundId: string) {
return unwrapApiResponse(response)
}
async function transitionInboundFee(
tenantId: string,
inboundId: string,
action: 'confirm' | 'send',
idempotencyKey: string,
) {
const response = await http.post<unknown, ApiEnvelope<InboundFeeSnapshot>>(
`${feeBasePath(inboundId)}/${action}`,
undefined,
{ params: { tenantId }, headers: { 'Idempotency-Key': idempotencyKey } },
)
return unwrapApiResponse(response)
}
export function confirmInboundFee(tenantId: string, inboundId: string, idempotencyKey: string) {
return transitionInboundFee(tenantId, inboundId, 'confirm', idempotencyKey)
}
export function sendInboundFee(tenantId: string, inboundId: string, idempotencyKey: string) {
return transitionInboundFee(tenantId, inboundId, 'send', idempotencyKey)
}
export async function adjustPublishedInboundFee(
tenantId: string,
inboundId: string,
@@ -30,7 +52,11 @@ export async function adjustPublishedInboundFee(
}
export function createFeeAdjustmentIdempotencyKey() {
return createFeeActionIdempotencyKey('adjust')
}
export function createFeeActionIdempotencyKey(action: 'adjust' | 'confirm' | 'send') {
const uuid = globalThis.crypto?.randomUUID?.()
if (uuid) return `fee-adjust-${uuid}`
return `fee-adjust-${Date.now()}-${Math.random().toString(36).slice(2, 12)}`
if (uuid) return `fee-${action}-${uuid}`
return `fee-${action}-${Date.now()}-${Math.random().toString(36).slice(2, 12)}`
}