🥳
This commit is contained in:
@@ -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 = () => {
|
||||
|
Reference in New Issue
Block a user