blob: 11439dcb4952d87e70bfc8c4684f3a56e63e43b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
export class SyncClient {
static async getSyncStatus(contractId: number, targetSystem: string = 'SHI') {
const response = await fetch(`/api/sync/status?contractId=${contractId}&targetSystem=${targetSystem}`)
if (!response.ok) throw new Error('Failed to fetch sync status')
return response.json()
}
static async triggerSync(contractId: number, targetSystem: string = 'SHI') {
const response = await fetch('/api/sync/trigger', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ contractId, targetSystem })
})
if (!response.ok) {
const error = await response.json()
throw new Error(error.message || 'Sync failed')
}
return response.json()
}
static async getSyncBatches(contractId: number, targetSystem: string = 'SHI', limit: number = 10) {
const response = await fetch(`/api/sync/batches?contractId=${contractId}&targetSystem=${targetSystem}&limit=${limit}`)
if (!response.ok) throw new Error('Failed to fetch sync batches')
return response.json()
}
}
|