25 lines
804 B
JavaScript
25 lines
804 B
JavaScript
export const api = {
|
|
async conversations({ q = "", status = "", state = "" } = {}) {
|
|
const u = new URL("/conversations", location.origin);
|
|
if (q) u.searchParams.set("q", q);
|
|
if (status) u.searchParams.set("status", status);
|
|
if (state) u.searchParams.set("state", state);
|
|
return fetch(u).then(r => r.json());
|
|
},
|
|
|
|
async runs({ chat_id, limit = 1 } = {}) {
|
|
const u = new URL("/runs", location.origin);
|
|
if (chat_id) u.searchParams.set("chat_id", chat_id);
|
|
u.searchParams.set("limit", String(limit));
|
|
return fetch(u).then(r => r.json());
|
|
},
|
|
|
|
async simEvolution(payload) {
|
|
return fetch("/webhook/evolution", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify(payload),
|
|
}).then(r => r.json());
|
|
},
|
|
};
|