36 lines
981 B
TypeScript
36 lines
981 B
TypeScript
import settings from '../settings'
|
|
import { Client } from '../types'
|
|
import axios from 'axios'
|
|
|
|
const { apiUrl } = settings
|
|
|
|
export const createClient = async (body: Client) => {
|
|
await axios.post(`${apiUrl}/clients`, body)
|
|
}
|
|
|
|
export const getClients = async (): Promise<Client[]> => {
|
|
const res = await axios.post<Client[]>(`${apiUrl}/clients`)
|
|
return res.data as Client[]
|
|
}
|
|
|
|
export const beginCapture = async (clientId: string) => {
|
|
const res = await axios.post(`${apiUrl}/clients/${clientId}/session`)
|
|
return res.data as string // capture id
|
|
}
|
|
|
|
export const getCapture = async (
|
|
clientId: string,
|
|
): Promise<null | string[]> => {
|
|
const res = await axios.get(`${apiUrl}/clients/${clientId}/session`)
|
|
return res.data as null | string[]
|
|
}
|
|
|
|
export const retryCapture = async (clientId: string) => {
|
|
await axios.delete(`${apiUrl}/clients/${clientId}/session`)
|
|
await axios.post(`${apiUrl}/clients/${clientId}/session`)
|
|
}
|
|
|
|
export const cleanup = () => {
|
|
// send
|
|
}
|