优化
This commit is contained in:
@@ -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)}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user