This commit is contained in:
E
2021-03-07 19:17:00 -07:00
parent 11cf67b594
commit d1e5b0310b
16 changed files with 28267 additions and 8961 deletions

View File

@@ -1,33 +1,44 @@
import settings from '../settings'
import { Client } from '../types'
import axios from 'axios'
import { client, clients, session } from '../data'
const { apiUrl } = settings
const apiUrl = '/api'
export const createClient = async (body: Client) => {
await axios.post(`${apiUrl}/clients`, body)
}
export const getClients = async (): Promise<Client[]> => {
return clients
const res = await axios.post<Client[]>(`${apiUrl}/clients`)
return res.data as Client[]
return res.data
}
export const beginCapture = async (clientId: string) => {
export const getClient = async (id: string): Promise<Client> => {
return client
const res = await axios.post<Client>(`${apiUrl}/client/${id}`)
return res.data
}
export const startSession = async (clientId: string) => {
//
const res = await axios.post(`${apiUrl}/clients/${clientId}/session`)
return res.data as string // capture id
return res.data // session data
}
export const getCapture = async (
export const getSession = async (
clientId: string,
): Promise<null | string[]> => {
return session
const res = await axios.get(`${apiUrl}/clients/${clientId}/session`)
return res.data as null | string[]
}
export const retryCapture = async (clientId: string) => {
export const killSession = async (clientId: string) => {
await axios.delete(`${apiUrl}/clients/${clientId}/session`)
await axios.post(`${apiUrl}/clients/${clientId}/session`)
}
export const restartSession = async (clientId: string) => {
await killSession(clientId)
await startSession(clientId)
}
export const cleanup = () => {