Files
monitor-im-flur/src/api/flatastic.ts
2025-08-27 18:15:55 +02:00

52 lines
1.4 KiB
TypeScript

class Flatastic {
private apikey: string;
constructor(apikey: string) {
this.apikey = apikey;
}
async request(url: string) {
const headers = {
accept: "application/json, text/plain, */*",
"accept-language":
"de-CH,de;q=0.9,en-US;q=0.8,en-CH;q=0.7,en;q=0.6,ar-JO;q=0.5,ar;q=0.4,de-DE;q=0.3",
// "cache-control": "no-cache",
// "pragma": "no-cache",
// "sec-fetch-dest": "empty",
// "sec-fetch-mode": "cors",
// "sec-fetch-site": "same-site",
"x-api-key": this.apikey,
"x-api-version": "2.0.0",
"x-client-version": "2.3.20",
};
const response = await fetch(url, {
headers: {
...headers,
},
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return await response.json();
}
getShoppingList() {
return this.request(
"https://api.flatastic-app.com/index.php/api/shoppinglist",
);
}
getTaskList() {
return this.request(
"https://api.flatastic-app.com/index.php/api/chores",
);
}
getInformation() {
return this.request("https://api.flatastic-app.com/index.php/api/wg");
}
}
export { Flatastic };
export default Flatastic;