51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
|
|
import { requestJson } from "@/shared/api/request-json"
|
||
|
|
|
||
|
|
import {
|
||
|
|
defaultMarketIntegrityQuery,
|
||
|
|
type IntegrityCheckAccepted,
|
||
|
|
type MarketIntegrityCheck,
|
||
|
|
type MarketIntegrityQuery,
|
||
|
|
} from "./sync.types"
|
||
|
|
|
||
|
|
const integrityChecksPath = "/api/v1/market-data/integrity-checks"
|
||
|
|
|
||
|
|
export function triggerIntegrityCheck(signal?: AbortSignal) {
|
||
|
|
return requestJson<IntegrityCheckAccepted>(integrityChecksPath, {
|
||
|
|
method: "POST",
|
||
|
|
signal,
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
|
export function getLatestIntegrityCheck(
|
||
|
|
query: MarketIntegrityQuery = defaultMarketIntegrityQuery,
|
||
|
|
signal?: AbortSignal,
|
||
|
|
) {
|
||
|
|
return requestJson<MarketIntegrityCheck>(
|
||
|
|
`${integrityChecksPath}/latest?${buildQuery(query)}`,
|
||
|
|
{ signal },
|
||
|
|
)
|
||
|
|
}
|
||
|
|
|
||
|
|
export function getIntegrityCheck(
|
||
|
|
checkId: string,
|
||
|
|
query: MarketIntegrityQuery = defaultMarketIntegrityQuery,
|
||
|
|
signal?: AbortSignal,
|
||
|
|
) {
|
||
|
|
return requestJson<MarketIntegrityCheck>(
|
||
|
|
`${integrityChecksPath}/${encodeURIComponent(checkId)}?${buildQuery(query)}`,
|
||
|
|
{ signal },
|
||
|
|
)
|
||
|
|
}
|
||
|
|
|
||
|
|
function buildQuery(query: MarketIntegrityQuery) {
|
||
|
|
const params = new URLSearchParams({
|
||
|
|
page: String(query.page),
|
||
|
|
page_size: String(query.pageSize),
|
||
|
|
})
|
||
|
|
return params.toString()
|
||
|
|
}
|
||
|
|
|
||
|
|
export const getMarketIntegrityCheck = getIntegrityCheck
|
||
|
|
export const getLatestMarketIntegrityCheck = getLatestIntegrityCheck
|
||
|
|
export const triggerMarketIntegrityCheck = triggerIntegrityCheck
|