2024-09-09 05:45:00 +02:00

54 lines
1.3 KiB
TypeScript

import { DocumentNotary } from "le-coffre-resources/dist/Notary";
import BaseNotary from "../BaseNotary";
// TODO Type get query params -> Where + inclue + orderby
export interface IGetDocumentNotaryparams {
where?: {};
include?: {};
orderBy?: {};
}
// TODO Type getbyuid query params
export default class DocumentsNotary extends BaseNotary {
private static instance: DocumentsNotary;
private readonly baseURl = this.namespaceUrl.concat("/documents_notary");
private constructor() {
super();
}
public static getInstance() {
if (!this.instance) {
return new this();
} else {
return this.instance;
}
}
// public async get(q: IGetDocumentNotaryparams): Promise<DocumentNotary[]> {
// const url = new URL(this.baseURl);
// const query = { q };
// Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
// try {
// return await this.getRequest<DocumentNotary[]>(url);
// } catch (err) {
// this.onError(err);
// return Promise.reject(err);
// }
// }
/**
* @description : Create a Document Notary
*/
public async post(body: any): Promise<DocumentNotary> {
const url = new URL(this.baseURl);
try {
return await this.postRequestFormData<DocumentNotary>(url, body);
} catch (err) {
this.onError(err);
return Promise.reject(err);
}
}
}