2021-01-25 12:55:29 +01:00
|
|
|
import { notificationStore } from "../store/notification"
|
2021-01-08 18:25:06 +01:00
|
|
|
import API from "./api"
|
|
|
|
/**
|
|
|
|
* Executes an automation. Must have "App Action" trigger.
|
|
|
|
*/
|
|
|
|
export const triggerAutomation = async (automationId, fields) => {
|
2021-01-25 12:55:29 +01:00
|
|
|
const res = await API.post({
|
2021-01-08 18:25:06 +01:00
|
|
|
url: `/api/automations/${automationId}/trigger`,
|
|
|
|
body: { fields },
|
|
|
|
})
|
2021-01-25 12:55:29 +01:00
|
|
|
res.error
|
2021-01-25 13:36:35 +01:00
|
|
|
? notificationStore.danger("An error has occurred")
|
2021-01-25 12:57:04 +01:00
|
|
|
: notificationStore.success("Automation triggered")
|
2021-01-25 12:55:29 +01:00
|
|
|
return res
|
2021-01-08 18:25:06 +01:00
|
|
|
}
|