export function call(endpoint, data, auth) { const headers = { "Content-Type": "application/json", }; if (auth) headers.Authorization = `Bearer ${auth}`; return fetch("https://managerapi.mosyle.com/v2" + endpoint, { method: "POST", headers, body: JSON.stringify(data), }); } export async function authenticate(email, password, token) { const response = await call("/login", { email, password, accessToken: token, }); if (!response.ok) throw new Error("Authentication failed"); return response.headers.get("Authorization").replace(/^Bearer\s/, ""); } export function bulk(data, auth) { return call("/bulkops", data, auth); }