summaryrefslogtreecommitdiff
path: root/lib/vendor-document-list/sync-client.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/vendor-document-list/sync-client.ts')
-rw-r--r--lib/vendor-document-list/sync-client.ts28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/vendor-document-list/sync-client.ts b/lib/vendor-document-list/sync-client.ts
new file mode 100644
index 00000000..11439dcb
--- /dev/null
+++ b/lib/vendor-document-list/sync-client.ts
@@ -0,0 +1,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()
+ }
+ } \ No newline at end of file