Add bulk wipe
This commit is contained in:
parent
4721569c5d
commit
b24a5bb612
6 changed files with 119 additions and 2 deletions
25
mosyle.js
Normal file
25
mosyle.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue