1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-02 20:15:24 +02:00

events api

This commit is contained in:
hay-kot 2021-08-21 14:04:49 -08:00
parent 6d3a06e1b9
commit 7d40f8d74d
4 changed files with 332 additions and 3 deletions

View file

@ -0,0 +1,42 @@
import { requests } from "../requests";
import { BaseCRUDAPI } from "./_base";
export type EventCategory = "general" | "recipe" | "backup" | "scheduled" | "migration" | "group" | "user";
export type DeclaredTypes = "General" | "Discord" | "Gotify" | "Pushover" | "Home Assistant";
export type GotifyPriority = "low" | "moderate" | "normal" | "high";
export interface EventNotification {
id?: number;
name?: string;
type?: DeclaredTypes & string;
general?: boolean;
recipe?: boolean;
backup?: boolean;
scheduled?: boolean;
migration?: boolean;
group?: boolean;
user?: boolean;
}
export interface CreateEventNotification extends EventNotification {
notificationUrl?: string;
}
const prefix = "/api";
const routes = {
aboutEventsNotifications: `${prefix}/about/events/notifications`,
aboutEventsNotificationsTest: `${prefix}/about/events/notifications/test`,
aboutEventsNotificationsId: (id: number) => `${prefix}/about/events/notifications/${id}`,
};
export class NotificationsAPI extends BaseCRUDAPI<EventNotification, CreateEventNotification> {
baseRoute = routes.aboutEventsNotifications;
itemRoute = routes.aboutEventsNotificationsId;
/** Returns the Group Data for the Current User
*/
async testNotification(id: number) {
return await requests.post(routes.aboutEventsNotificationsTest, { id });
}
}

View file

@ -8,6 +8,7 @@ import { UploadFile } from "./class-interfaces/upload";
import { CategoriesAPI } from "./class-interfaces/categories";
import { TagsAPI } from "./class-interfaces/tags";
import { UtilsAPI } from "./class-interfaces/utils";
import { NotificationsAPI } from "./class-interfaces/event-notifications";
import { ApiRequestInstance } from "~/types/api";
class Api {
@ -21,6 +22,7 @@ class Api {
public categories: CategoriesAPI;
public tags: TagsAPI;
public utils: UtilsAPI;
public notifications: NotificationsAPI;
// Utils
public upload: UploadFile;
@ -43,6 +45,7 @@ class Api {
this.debug = new DebugAPI(requests);
this.events = new EventsAPI(requests);
this.backups = new BackupAPI(requests);
this.notifications = new NotificationsAPI(requests);
// Utils
this.upload = new UploadFile(requests);