2024-11-22 09:12:24 +01:00

51 lines
1.3 KiB
TypeScript

import DocumentNotary from "le-coffre-resources/dist/Notary/DocumentNotary";
import BaseCustomer from "../BaseCustomer";
export interface IGetDocumentNotaryparams {
where?: {};
include?: {};
orderBy?: {};
}
export default class DocumentsNotary extends BaseCustomer {
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);
}
}
public async getByUid(uid: string, q?: any): Promise<DocumentNotary> {
const url = new URL(this.baseURl.concat(`/${uid}`));
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);
}
}
}