import BaseApiService from "@Front/Api/BaseApiService"; import { UserNotification } from "le-coffre-resources/dist/Notary"; // TODO Type get query params -> Where + inclue + orderby export interface IGetNotificationsParams { where?: {}; include?: {}; select?: {}; } export type IPutNotificationsParams = { read?: boolean; }; export default class Notifications extends BaseApiService { private static instance: Notifications; private baseUrl = this.getBaseUrl().concat("/notifications"); private constructor() { super(); } public static getInstance() { if (!this.instance) { return new this(); } else { return this.instance; } } public async get(q?: IGetNotificationsParams): Promise { const url = new URL(this.baseUrl); if (q) { const query = { q }; Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value))); } try { return await this.getRequest(url); } catch (err) { this.onError(err); return Promise.reject(err); } } public async put(uid: string, body: IPutNotificationsParams): Promise { const url = new URL(this.baseUrl.concat(`/${uid}`)); try { return await this.putRequest(url, body); } catch (err) { this.onError(err); return Promise.reject(err); } } }