2021-12-29 10:22:26 +01:00
|
|
|
import { Result } from 'db'
|
2022-02-17 16:08:01 +01:00
|
|
|
import { VariableWithValue } from 'models'
|
2021-12-29 10:22:26 +01:00
|
|
|
import { sendRequest } from 'utils'
|
|
|
|
|
2022-02-17 16:08:01 +01:00
|
|
|
export const createResult = async (
|
|
|
|
typebotId: string,
|
|
|
|
prefilledVariables: VariableWithValue[]
|
|
|
|
) => {
|
2021-12-29 10:22:26 +01:00
|
|
|
return sendRequest<Result>({
|
|
|
|
url: `/api/results`,
|
|
|
|
method: 'POST',
|
2022-02-17 16:08:01 +01:00
|
|
|
body: { typebotId, prefilledVariables },
|
2021-12-29 10:22:26 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export const updateResult = async (
|
|
|
|
resultId: string,
|
|
|
|
result: Partial<Result>
|
|
|
|
) => {
|
|
|
|
return sendRequest<Result>({
|
|
|
|
url: `/api/results/${resultId}`,
|
|
|
|
method: 'PATCH',
|
|
|
|
body: result,
|
|
|
|
})
|
|
|
|
}
|