import { Appointment, Vote } from "le-coffre-resources/dist/SuperAdmin"; import BaseSuperAdmin from "../BaseSuperAdmin"; // TODO Type get query params -> Where + inclue + orderby export interface IGetLiveVotessparams { where?: {}; include?: {}; select?: {}; } export type IPostLiveVotesParams = { appointment: Appointment; }; export type LiveVote = { uid: string; appointment: Appointment; }; export type IDeleteVotesParams = { uid: Vote["uid"]; }; export default class LiveVotes extends BaseSuperAdmin { private static instance: LiveVotes; private readonly baseURl = this.namespaceUrl.concat("/live-votes"); private constructor() { super(); } public static getInstance() { if (!this.instance) { return new this(); } else { return this.instance; } } /** * @description : Create a LiveVotes */ public async post(body: IPostLiveVotesParams): Promise { const url = new URL(this.baseURl); try { return await this.postRequest(url, body); } catch (err) { this.onError(err); return Promise.reject(err); } } /** * @description : Delete a vote */ public async delete(body: IDeleteVotesParams): Promise { const url = new URL(`${this.baseURl}/${body.uid}`); try { return await this.deleteRequest(url, body); } catch (err) { this.onError(err); return Promise.reject(err); } } }