add id360 callback pages
This commit is contained in:
parent
7f6cd05ebf
commit
0750c86215
@ -13,6 +13,7 @@ const nextConfig = {
|
||||
NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT: process.env.NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT,
|
||||
NEXT_PUBLIC_IDNOT_CLIENT_ID: process.env.NEXT_PUBLIC_IDNOT_CLIENT_ID,
|
||||
NEXT_PUBLIC_IDNOT_BASE_URL: process.env.NEXT_PUBLIC_IDNOT_BASE_URL,
|
||||
NEXT_PUBLIC_DOCAPOSTE_API_URL: process.env.NEXT_PUBLIC_DOCAPOSTE_API_URL,
|
||||
},
|
||||
// webpack: config => {
|
||||
// config.node = {
|
||||
|
5
src/common/Api/LeCoffreApi/Admin/BaseAdmin.ts
Normal file
5
src/common/Api/LeCoffreApi/Admin/BaseAdmin.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import BaseApiService from "@Front/Api/BaseApiService";
|
||||
|
||||
export default abstract class BaseAdmin extends BaseApiService {
|
||||
protected readonly namespaceUrl = this.getBaseUrl().concat("/admin");
|
||||
}
|
94
src/common/Api/LeCoffreApi/Admin/DeedTypes/DeedTypes.ts
Normal file
94
src/common/Api/LeCoffreApi/Admin/DeedTypes/DeedTypes.ts
Normal file
@ -0,0 +1,94 @@
|
||||
import { DeedType } from "le-coffre-resources/dist/Admin";
|
||||
|
||||
import BaseAdmin from "../BaseAdmin";
|
||||
|
||||
export type IPutDeedTypesParams = {
|
||||
uid?: DeedType["uid"];
|
||||
name?: DeedType["name"];
|
||||
description?: DeedType["description"];
|
||||
deed?: DeedType["deed"];
|
||||
office?: DeedType["office"];
|
||||
archived_at?: DeedType["archived_at"];
|
||||
document_types?: DeedType["document_types"];
|
||||
};
|
||||
|
||||
export type IPostDeedTypesParams = {
|
||||
name?: DeedType["name"];
|
||||
description?: DeedType["description"];
|
||||
};
|
||||
|
||||
export type IGetDeedTypesParams = {
|
||||
where?: {};
|
||||
include?: {};
|
||||
select?: {};
|
||||
};
|
||||
|
||||
export default class DeedTypes extends BaseAdmin {
|
||||
private static instance: DeedTypes;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/deed-types");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new DeedTypes();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
public async get(q: IGetDeedTypesParams): Promise<DeedType[]> {
|
||||
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<DeedType[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async getByUid(uid: string, q?: any): Promise<DeedType> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<DeedType>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async put(uid: string, body: IPutDeedTypesParams) {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.putRequest<DeedType>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async post(body: IPostDeedTypesParams) {
|
||||
const url = new URL(this.baseURl);
|
||||
try {
|
||||
return await this.postRequest<DeedType>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async delete(uid: string) {
|
||||
const url = new URL(this.baseURl);
|
||||
try {
|
||||
return await this.deleteRequest<DeedType>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
49
src/common/Api/LeCoffreApi/Admin/Deeds/Deeds.ts
Normal file
49
src/common/Api/LeCoffreApi/Admin/Deeds/Deeds.ts
Normal file
@ -0,0 +1,49 @@
|
||||
import { Deed } from "le-coffre-resources/dist/Admin";
|
||||
|
||||
import BaseAdmin from "../BaseAdmin";
|
||||
|
||||
export type IGetDeedsParams = {
|
||||
where?: {};
|
||||
include?: {};
|
||||
select?: {};
|
||||
};
|
||||
|
||||
export default class Deeds extends BaseAdmin {
|
||||
private static instance: Deeds;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/deeds");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new Deeds();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
public async get(q: IGetDeedsParams): Promise<Deed[]> {
|
||||
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<Deed[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async getByUid(uid: string, q?: any): Promise<Deed> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<Deed>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
import { DocumentType } from "le-coffre-resources/dist/Admin";
|
||||
|
||||
import BaseAdmin from "../BaseAdmin";
|
||||
|
||||
// TODO Type get query params -> Where + inclue + orderby
|
||||
export interface IGetDocumentTypesparams {
|
||||
where?: {};
|
||||
include?: {};
|
||||
}
|
||||
|
||||
// TODO Type getbyuid query params
|
||||
|
||||
export type IPutDocumentTypesParams = {};
|
||||
|
||||
export interface IPostDocumentTypesParams {
|
||||
name: string;
|
||||
public_description: string;
|
||||
private_description: string;
|
||||
office: {
|
||||
uid: string;
|
||||
};
|
||||
}
|
||||
|
||||
export default class DocumentTypes extends BaseAdmin {
|
||||
private static instance: DocumentTypes;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/document-types");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new this();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
public async get(q: IGetDocumentTypesparams): Promise<DocumentType[]> {
|
||||
const url = new URL(this.baseURl);
|
||||
const query = { q };
|
||||
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<DocumentType[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Create a Document
|
||||
*/
|
||||
public async post(body: DocumentType): Promise<DocumentType> {
|
||||
const url = new URL(this.baseURl);
|
||||
try {
|
||||
return await this.postRequest<DocumentType>(url, body as any);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async getByUid(uid: string, q?: any): Promise<DocumentType> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
const query = { q };
|
||||
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<DocumentType>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async put(uid: string, body: IPutDocumentTypesParams): Promise<DocumentType> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.putRequest<DocumentType>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
93
src/common/Api/LeCoffreApi/Admin/Documents/Documents.ts
Normal file
93
src/common/Api/LeCoffreApi/Admin/Documents/Documents.ts
Normal file
@ -0,0 +1,93 @@
|
||||
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
|
||||
import { Document } from "le-coffre-resources/dist/SuperAdmin";
|
||||
|
||||
import BaseAdmin from "../BaseAdmin";
|
||||
|
||||
// TODO Type get query params -> Where + inclue + orderby
|
||||
export interface IGetDocumentsparams {
|
||||
where?: {};
|
||||
include?: {};
|
||||
}
|
||||
|
||||
// TODO Type getbyuid query params
|
||||
|
||||
export type IPutDocumentsParams = {
|
||||
document_status?: EDocumentStatus;
|
||||
refused_reason?: string;
|
||||
};
|
||||
|
||||
export interface IPostDocumentsParams {}
|
||||
|
||||
export default class Documents extends BaseAdmin {
|
||||
private static instance: Documents;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/documents");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new this();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
public async get(q: IGetDocumentsparams): Promise<Document[]> {
|
||||
const url = new URL(this.baseURl);
|
||||
const query = { q };
|
||||
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<Document[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Create a Document
|
||||
*/
|
||||
public async post(body: any): Promise<Document> {
|
||||
const url = new URL(this.baseURl);
|
||||
try {
|
||||
return await this.postRequest<Document>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async getByUid(uid: string, q?: any): Promise<Document> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
const query = { q };
|
||||
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<Document>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async put(uid: string, body: IPutDocumentsParams): Promise<Document> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.putRequest<Document>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async delete(uid: string): Promise<Document> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.deleteRequest<Document>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
81
src/common/Api/LeCoffreApi/Admin/OfficeRoles/OfficeRoles.ts
Normal file
81
src/common/Api/LeCoffreApi/Admin/OfficeRoles/OfficeRoles.ts
Normal file
@ -0,0 +1,81 @@
|
||||
import { OfficeRole } from "le-coffre-resources/dist/Admin";
|
||||
|
||||
import BaseAdmin from "../BaseAdmin";
|
||||
|
||||
export type IGetRolesParams = {
|
||||
where?: {};
|
||||
include?: {};
|
||||
select?: {};
|
||||
};
|
||||
|
||||
export type IPutRoleParams = {
|
||||
uid: OfficeRole["uid"];
|
||||
rules: OfficeRole["rules"];
|
||||
};
|
||||
|
||||
export type IPostRoleParams = {
|
||||
name: OfficeRole["name"];
|
||||
office: OfficeRole["office"];
|
||||
};
|
||||
|
||||
export default class OfficeRoles extends BaseAdmin {
|
||||
private static instance: OfficeRoles;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/office-roles");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new OfficeRoles();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
public async get(q?: IGetRolesParams): Promise<OfficeRole[]> {
|
||||
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<OfficeRole[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async getByUid(uid: string, q?: any): Promise<OfficeRole> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<OfficeRole>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async put(uid: string, body: IPutRoleParams): Promise<OfficeRole> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.putRequest<OfficeRole>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async post(body: IPostRoleParams) {
|
||||
const url = new URL(this.baseURl);
|
||||
try {
|
||||
return await this.postRequest<OfficeRole>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
96
src/common/Api/LeCoffreApi/Admin/Roles/Roles.ts
Normal file
96
src/common/Api/LeCoffreApi/Admin/Roles/Roles.ts
Normal file
@ -0,0 +1,96 @@
|
||||
import { Role } from "le-coffre-resources/dist/Admin";
|
||||
|
||||
import BaseAdmin from "../BaseAdmin";
|
||||
|
||||
export type IGetRolesParams = {
|
||||
where?: {};
|
||||
include?: {};
|
||||
select?: {};
|
||||
};
|
||||
|
||||
export type IPutRoleParams = {
|
||||
uid: Role["uid"];
|
||||
rules: Role["rules"];
|
||||
};
|
||||
|
||||
export type IPostRoleParams = {
|
||||
name: Role["name"];
|
||||
};
|
||||
export default class Roles extends BaseAdmin {
|
||||
private static instance: Roles;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/roles");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new Roles();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
public async get(q?: IGetRolesParams): Promise<Role[]> {
|
||||
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<Role[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async post(body: IPostRoleParams) {
|
||||
const url = new URL(this.baseURl);
|
||||
try {
|
||||
return await this.postRequest<Role>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async getOne(q?: IGetRolesParams): Promise<Role | null> {
|
||||
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 {
|
||||
const res = await this.getRequest<Role[]>(url);
|
||||
if (!res) return null;
|
||||
if (res.length > 1) throw new Error("More than one role found");
|
||||
return res[0] ? res[0] : null;
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async getByUid(uid: string, q?: any): Promise<Role> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<Role>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async put(uid: string, body: IPutRoleParams): Promise<Role> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.putRequest<Role>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
49
src/common/Api/LeCoffreApi/Admin/Rules/Rules.ts
Normal file
49
src/common/Api/LeCoffreApi/Admin/Rules/Rules.ts
Normal file
@ -0,0 +1,49 @@
|
||||
import { Rule } from "le-coffre-resources/dist/Admin";
|
||||
|
||||
import BaseAdmin from "../BaseAdmin";
|
||||
|
||||
export type IGetRulesParams = {
|
||||
where?: {};
|
||||
include?: {};
|
||||
select?: {};
|
||||
};
|
||||
|
||||
export default class Rules extends BaseAdmin {
|
||||
private static instance: Rules;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/rules");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new Rules();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
public async get(q: IGetRulesParams): Promise<Rule[]> {
|
||||
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<Rule[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async getByUid(uid: string, q?: any): Promise<Rule> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<Rule>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
91
src/common/Api/LeCoffreApi/Admin/Users/Users.ts
Normal file
91
src/common/Api/LeCoffreApi/Admin/Users/Users.ts
Normal file
@ -0,0 +1,91 @@
|
||||
import User from "le-coffre-resources/dist/SuperAdmin";
|
||||
import BaseAdmin from "../BaseAdmin";
|
||||
|
||||
// TODO Type get query params -> Where + inclue + orderby
|
||||
export interface IGetUsersparams {
|
||||
where?: {};
|
||||
include?: {};
|
||||
select?: {};
|
||||
}
|
||||
|
||||
// TODO Type getbyuid query params
|
||||
|
||||
export type IPutUsersParams = {
|
||||
uid?: User["uid"];
|
||||
idNot?: User["idNot"];
|
||||
contact?: User["contact"];
|
||||
office_membership?: User["office_membership"];
|
||||
documents?: User["documents"];
|
||||
};
|
||||
|
||||
export default class Users extends BaseAdmin {
|
||||
private static instance: Users;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/users");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new this();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get all Users
|
||||
*/
|
||||
public async get(q: IGetUsersparams): Promise<User[]> {
|
||||
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<User[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get a folder by uid
|
||||
*/
|
||||
public async getByUid(uid: string, q?: any): Promise<User> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<User>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Create a User
|
||||
*/
|
||||
// public async post(body: IPostDeedsParams): Promise<OfficeFolder> {
|
||||
// const url = new URL(this.baseURl);
|
||||
// try {
|
||||
// return await this.postRequest<OfficeFolder>(url, body);
|
||||
// } catch (err) {
|
||||
// this.onError(err);
|
||||
// return Promise.reject(err);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* @description : Update the folder description
|
||||
*/
|
||||
public async put(uid: string, body: IPutUsersParams): Promise<User> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.putRequest<User>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
5
src/common/Api/LeCoffreApi/Customer/BaseCustomer.ts
Normal file
5
src/common/Api/LeCoffreApi/Customer/BaseCustomer.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import BaseApiService from "@Front/Api/BaseApiService";
|
||||
|
||||
export default abstract class BaseNotary extends BaseApiService {
|
||||
protected readonly namespaceUrl = this.getBaseUrl().concat("/customer");
|
||||
}
|
67
src/common/Api/LeCoffreApi/Customer/Customers/Customers.ts
Normal file
67
src/common/Api/LeCoffreApi/Customer/Customers/Customers.ts
Normal file
@ -0,0 +1,67 @@
|
||||
import Customer, { Contact } from "le-coffre-resources/dist/Customer";
|
||||
|
||||
import BaseCustomer from "../BaseCustomer";
|
||||
import { ECivility } from "le-coffre-resources/dist/Customer/Contact";
|
||||
|
||||
// TODO Type get query params -> Where + inclue + orderby
|
||||
export interface IGetCustomersparams {
|
||||
where?: {};
|
||||
include?: {};
|
||||
}
|
||||
|
||||
// TODO Type getbyuid query params
|
||||
|
||||
export type IPutCustomersParams = {
|
||||
uid?: Customer["uid"];
|
||||
contact?: Customer["contact"];
|
||||
};
|
||||
|
||||
export interface IPostCustomersParams {
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
email: string;
|
||||
cell_phone_number: string;
|
||||
civility: ECivility;
|
||||
address?: Contact["address"];
|
||||
}
|
||||
|
||||
export default class Customers extends BaseCustomer {
|
||||
private static instance: Customers;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/customers");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new this();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
public async get(q: IGetCustomersparams): Promise<Customer[]> {
|
||||
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<Customer[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async getByUid(uid: string, q?: any): Promise<Customer> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
const query = { q };
|
||||
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<Customer>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
93
src/common/Api/LeCoffreApi/Customer/Documents/Documents.ts
Normal file
93
src/common/Api/LeCoffreApi/Customer/Documents/Documents.ts
Normal file
@ -0,0 +1,93 @@
|
||||
import { Document } from "le-coffre-resources/dist/Customer";
|
||||
|
||||
import BaseCustomer from "../BaseCustomer";
|
||||
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
|
||||
|
||||
// TODO Type get query params -> Where + inclue + orderby
|
||||
export interface IGetDocumentsparams {
|
||||
where?: {};
|
||||
include?: {};
|
||||
}
|
||||
|
||||
// TODO Type getbyuid query params
|
||||
|
||||
export type IPutDocumentsParams = {
|
||||
document_status?: EDocumentStatus;
|
||||
refused_reason?: string;
|
||||
};
|
||||
|
||||
export interface IPostDocumentsParams {}
|
||||
|
||||
export default class Documents extends BaseCustomer {
|
||||
private static instance: Documents;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/documents");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new this();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
public async get(q: IGetDocumentsparams): Promise<Document[]> {
|
||||
const url = new URL(this.baseURl);
|
||||
const query = { q };
|
||||
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<Document[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Create a Document
|
||||
*/
|
||||
public async post(body: any): Promise<Document> {
|
||||
const url = new URL(this.baseURl);
|
||||
try {
|
||||
return await this.postRequest<Document>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async getByUid(uid: string, q?: any): Promise<Document> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
const query = { q };
|
||||
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<Document>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async put(uid: string, body: IPutDocumentsParams): Promise<Document> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.putRequest<Document>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async delete(uid: string): Promise<Document> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.deleteRequest<Document>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
93
src/common/Api/LeCoffreApi/Customer/Files/Files.ts
Normal file
93
src/common/Api/LeCoffreApi/Customer/Files/Files.ts
Normal file
@ -0,0 +1,93 @@
|
||||
import { File } from "le-coffre-resources/dist/Customer";
|
||||
import BaseCustomer from "../BaseCustomer";
|
||||
|
||||
// TODO Type get query params -> Where + inclue + orderby
|
||||
export interface IGetFilesparams {
|
||||
where?: {};
|
||||
include?: {};
|
||||
}
|
||||
|
||||
// TODO Type getbyuid query params
|
||||
|
||||
export type IPutFilesParams = {};
|
||||
|
||||
export interface IPostFilesParams {}
|
||||
|
||||
export default class Files extends BaseCustomer {
|
||||
private static instance: Files;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/files");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
return (this.instance ??= new this());
|
||||
}
|
||||
|
||||
public async get(q: IGetFilesparams): Promise<File[]> {
|
||||
const url = new URL(this.baseURl);
|
||||
const query = { q };
|
||||
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
const files = await this.getRequest<File[]>(url);
|
||||
return files;
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Create a File
|
||||
*/
|
||||
public async post(body: any): Promise<File> {
|
||||
const url = new URL(this.baseURl);
|
||||
try {
|
||||
return await this.postRequestFormData<File>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public getUploadLink(uid: string): string {
|
||||
return this.baseURl.concat(`/download/${uid}`);
|
||||
}
|
||||
|
||||
public async getByUid(uid: string, q?: any): Promise<File> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
const query = { q };
|
||||
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
const file = await this.getRequest<File>(url);
|
||||
return file;
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async put(uid: string, body: IPutFilesParams): Promise<File> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.putRequest<File>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Delete a folder only if the folder don't contains customers
|
||||
*/
|
||||
public async delete(uid: string): Promise<File> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.deleteRequest<File>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
57
src/common/Api/LeCoffreApi/Customer/Folders/Folders.ts
Normal file
57
src/common/Api/LeCoffreApi/Customer/Folders/Folders.ts
Normal file
@ -0,0 +1,57 @@
|
||||
import { type OfficeFolder } from "le-coffre-resources/dist/Customer";
|
||||
|
||||
import BaseCustomer from "../BaseCustomer";
|
||||
|
||||
// TODO Type get query params -> Where + inclue + orderby
|
||||
export interface IGetFoldersParams {
|
||||
q?: {
|
||||
select?: {};
|
||||
where?: {};
|
||||
include?: {};
|
||||
};
|
||||
}
|
||||
|
||||
export default class Folders extends BaseCustomer {
|
||||
private static instance: Folders;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/folders");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new this();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get all folders
|
||||
*/
|
||||
public async get(q: IGetFoldersParams): Promise<OfficeFolder[]> {
|
||||
const url = new URL(this.baseURl);
|
||||
Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<OfficeFolder[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get a folder by uid
|
||||
*/
|
||||
public async getByUid(uid: string, q?: any): Promise<OfficeFolder> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<OfficeFolder>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
49
src/common/Api/LeCoffreApi/Customer/Users/Users.ts
Normal file
49
src/common/Api/LeCoffreApi/Customer/Users/Users.ts
Normal file
@ -0,0 +1,49 @@
|
||||
import BaseNotary from "../BaseCustomer";
|
||||
import User from "le-coffre-resources/dist/Notary";
|
||||
|
||||
export default class Users extends BaseNotary {
|
||||
private static instance: Users;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/Users");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new Users();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
public async get(): Promise<User[]> {
|
||||
const url = new URL(this.baseURl);
|
||||
try {
|
||||
return await this.getRequest<User[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async getOne(uid: string): Promise<User> {
|
||||
const url = new URL(this.baseURl.concat("/").concat(uid));
|
||||
try {
|
||||
return await this.getRequest<User>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
// public async post(params: User): Promise<User> {
|
||||
// const url = new URL(this.baseURl);
|
||||
// try {
|
||||
// return await this.postRequest<User>(url, params);
|
||||
// } catch (err) {
|
||||
// this.onError(err);
|
||||
// return Promise.reject(err);
|
||||
// }
|
||||
// }
|
||||
}
|
5
src/common/Api/LeCoffreApi/Notary/BaseNotary.ts
Normal file
5
src/common/Api/LeCoffreApi/Notary/BaseNotary.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import BaseApiService from "@Front/Api/BaseApiService";
|
||||
|
||||
export default abstract class BaseNotary extends BaseApiService {
|
||||
protected readonly namespaceUrl = this.getBaseUrl().concat("/notary");
|
||||
}
|
90
src/common/Api/LeCoffreApi/Notary/Customers/Customers.ts
Normal file
90
src/common/Api/LeCoffreApi/Notary/Customers/Customers.ts
Normal file
@ -0,0 +1,90 @@
|
||||
import { Contact, Customer } from "le-coffre-resources/dist/Notary";
|
||||
|
||||
import BaseNotary from "../BaseNotary";
|
||||
import { ECivility } from "le-coffre-resources/dist/Customer/Contact";
|
||||
|
||||
// TODO Type get query params -> Where + inclue + orderby
|
||||
export interface IGetCustomersparams {
|
||||
where?: {};
|
||||
include?: {};
|
||||
}
|
||||
|
||||
// TODO Type getbyuid query params
|
||||
|
||||
export type IPutCustomersParams = {
|
||||
uid?: Customer["uid"];
|
||||
contact?: Customer["contact"];
|
||||
};
|
||||
|
||||
export interface IPostCustomersParams {
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
email: string;
|
||||
cell_phone_number: string;
|
||||
civility: ECivility;
|
||||
address?: Contact["address"];
|
||||
}
|
||||
|
||||
export default class Customers extends BaseNotary {
|
||||
private static instance: Customers;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/customers");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new this();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
public async get(q: IGetCustomersparams): Promise<Customer[]> {
|
||||
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<Customer[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Create a Customer
|
||||
*/
|
||||
public async post(body: any): Promise<Customer> {
|
||||
const url = new URL(this.baseURl);
|
||||
try {
|
||||
return await this.postRequest<Customer>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async getByUid(uid: string, q?: any): Promise<Customer> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
const query = { q };
|
||||
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<Customer>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async put(uid: string, body: IPutCustomersParams): Promise<Customer> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.putRequest<Customer>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
84
src/common/Api/LeCoffreApi/Notary/DeedTypes/DeedTypes.ts
Normal file
84
src/common/Api/LeCoffreApi/Notary/DeedTypes/DeedTypes.ts
Normal file
@ -0,0 +1,84 @@
|
||||
import { DeedType } from "le-coffre-resources/dist/Notary";
|
||||
|
||||
import BaseNotary from "../BaseNotary";
|
||||
|
||||
export type IPutDeedTypesParams = {
|
||||
uid?: DeedType["uid"];
|
||||
name?: DeedType["name"];
|
||||
description?: DeedType["description"];
|
||||
deed?: DeedType["deed"];
|
||||
office?: DeedType["office"];
|
||||
archived_at?: DeedType["archived_at"];
|
||||
document_types?: DeedType["document_types"];
|
||||
};
|
||||
|
||||
export type IPostDeedTypesParams = {
|
||||
name?: DeedType["name"];
|
||||
description?: DeedType["description"];
|
||||
};
|
||||
|
||||
export type IGetDeedTypesParams = {
|
||||
where?: {};
|
||||
include?: {};
|
||||
select?: {};
|
||||
};
|
||||
|
||||
export default class DeedTypes extends BaseNotary {
|
||||
private static instance: DeedTypes;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/deed-types");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new DeedTypes();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
public async get(q?: IGetDeedTypesParams): Promise<DeedType[]> {
|
||||
const url = new URL(this.baseURl);
|
||||
const query = { q };
|
||||
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<DeedType[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async getByUid(uid: string, q?: any): Promise<DeedType> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<DeedType>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async put(uid: string, body: IPutDeedTypesParams) {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.putRequest<DeedType>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async post(body: IPostDeedTypesParams) {
|
||||
const url = new URL(this.baseURl);
|
||||
try {
|
||||
return await this.postRequest<DeedType>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
72
src/common/Api/LeCoffreApi/Notary/Deeds/Deeds.ts
Normal file
72
src/common/Api/LeCoffreApi/Notary/Deeds/Deeds.ts
Normal file
@ -0,0 +1,72 @@
|
||||
import { Deed, OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||
|
||||
import BaseAdmin from "../BaseNotary";
|
||||
|
||||
export type IGetDeedsParams = {
|
||||
where?: {};
|
||||
include?: {};
|
||||
select?: {};
|
||||
};
|
||||
|
||||
export type IPutDeedsParams = {
|
||||
uid?: OfficeFolder["uid"];
|
||||
folder_number?: OfficeFolder["folder_number"];
|
||||
name?: OfficeFolder["name"];
|
||||
description?: OfficeFolder["description"];
|
||||
archived_description?: OfficeFolder["archived_description"];
|
||||
status?: OfficeFolder["status"];
|
||||
document_types?: Deed["document_types"];
|
||||
};
|
||||
|
||||
export default class Deeds extends BaseAdmin {
|
||||
private static instance: Deeds;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/deeds");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new Deeds();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
public async get(q: IGetDeedsParams): Promise<Deed[]> {
|
||||
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<Deed[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async getByUid(uid: string, q?: any): Promise<Deed> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<Deed>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Update the folder description
|
||||
*/
|
||||
public async put(uid: string, body: IPutDeedsParams): Promise<Deed> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.putRequest<Deed>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
import { DocumentType } from "le-coffre-resources/dist/Notary";
|
||||
|
||||
import BaseNotary from "../BaseNotary";
|
||||
|
||||
// TODO Type get query params -> Where + inclue + orderby
|
||||
export interface IGetDocumentTypesparams {
|
||||
where?: {};
|
||||
include?: {};
|
||||
}
|
||||
|
||||
// TODO Type getbyuid query params
|
||||
|
||||
export type IPutDocumentTypesParams = {};
|
||||
|
||||
export interface IPostDocumentTypesParams {
|
||||
name: string;
|
||||
public_description: string;
|
||||
private_description: string | null;
|
||||
office?: {
|
||||
uid?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export default class DocumentTypes extends BaseNotary {
|
||||
private static instance: DocumentTypes;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/document-types");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new this();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
public async get(q: IGetDocumentTypesparams): Promise<DocumentType[]> {
|
||||
const url = new URL(this.baseURl);
|
||||
const query = { q };
|
||||
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<DocumentType[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Create a Document
|
||||
*/
|
||||
public async post(body: IPostDocumentTypesParams): Promise<DocumentType> {
|
||||
const url = new URL(this.baseURl);
|
||||
try {
|
||||
return await this.postRequest<DocumentType>(url, body as any);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async getByUid(uid: string, q?: any): Promise<DocumentType> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
const query = { q };
|
||||
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<DocumentType>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async put(uid: string, body: IPutDocumentTypesParams): Promise<DocumentType> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.putRequest<DocumentType>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
93
src/common/Api/LeCoffreApi/Notary/Documents/Documents.ts
Normal file
93
src/common/Api/LeCoffreApi/Notary/Documents/Documents.ts
Normal file
@ -0,0 +1,93 @@
|
||||
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
|
||||
import { Document } from "le-coffre-resources/dist/Notary";
|
||||
|
||||
import BaseNotary from "../BaseNotary";
|
||||
|
||||
// TODO Type get query params -> Where + inclue + orderby
|
||||
export interface IGetDocumentsparams {
|
||||
where?: {};
|
||||
include?: {};
|
||||
}
|
||||
|
||||
// TODO Type getbyuid query params
|
||||
|
||||
export type IPutDocumentsParams = {
|
||||
document_status?: EDocumentStatus;
|
||||
refused_reason?: string;
|
||||
};
|
||||
|
||||
export interface IPostDocumentsParams {}
|
||||
|
||||
export default class Documents extends BaseNotary {
|
||||
private static instance: Documents;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/documents");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new this();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
public async get(q: IGetDocumentsparams): Promise<Document[]> {
|
||||
const url = new URL(this.baseURl);
|
||||
const query = { q };
|
||||
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<Document[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Create a Document
|
||||
*/
|
||||
public async post(body: any): Promise<Document> {
|
||||
const url = new URL(this.baseURl);
|
||||
try {
|
||||
return await this.postRequest<Document>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async getByUid(uid: string, q?: any): Promise<Document> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
const query = { q };
|
||||
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<Document>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async put(uid: string, body: IPutDocumentsParams): Promise<Document> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.putRequest<Document>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async delete(uid: string): Promise<Document> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.deleteRequest<Document>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
119
src/common/Api/LeCoffreApi/Notary/Folders/Folders.ts
Normal file
119
src/common/Api/LeCoffreApi/Notary/Folders/Folders.ts
Normal file
@ -0,0 +1,119 @@
|
||||
import { type OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||
|
||||
import BaseNotary from "../BaseNotary";
|
||||
import EFolderStatus from "le-coffre-resources/dist/Customer/EFolderStatus";
|
||||
|
||||
// TODO Type get query params -> Where + inclue + orderby
|
||||
export interface IGetFoldersParams {
|
||||
q?: {
|
||||
select?: {};
|
||||
where?: {};
|
||||
include?: {};
|
||||
};
|
||||
}
|
||||
|
||||
export default class Folders extends BaseNotary {
|
||||
private static instance: Folders;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/folders");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new this();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get all folders
|
||||
*/
|
||||
public async get(q: IGetFoldersParams): Promise<OfficeFolder[]> {
|
||||
const url = new URL(this.baseURl);
|
||||
Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<OfficeFolder[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get a folder by uid
|
||||
*/
|
||||
public async getByUid(uid: string, q?: any): Promise<OfficeFolder> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<OfficeFolder>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Create a folder
|
||||
*/
|
||||
public async post(officeFolder: Partial<OfficeFolder>): Promise<OfficeFolder> {
|
||||
const url = new URL(this.baseURl);
|
||||
try {
|
||||
return await this.postRequest(url, officeFolder);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Update the folder description
|
||||
*/
|
||||
public async put(uid: string, body: Partial<OfficeFolder>): Promise<OfficeFolder> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.putRequest(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Delete a folder only if the folder don't contains customers
|
||||
*/
|
||||
public async delete(uid: string): Promise<OfficeFolder> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
const targetedFolder = await this.getByUid(uid);
|
||||
if (targetedFolder.customers) return Promise.reject(`The folder ${uid} contains customers`);
|
||||
try {
|
||||
return await this.deleteRequest(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async archive(uid: string, body: Partial<OfficeFolder>): Promise<OfficeFolder> {
|
||||
body.status = EFolderStatus.ARCHIVED;
|
||||
try {
|
||||
return await this.put(uid, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async restore(uid: string, body: Partial<OfficeFolder>): Promise<OfficeFolder> {
|
||||
body.status = EFolderStatus.LIVE;
|
||||
try {
|
||||
return await this.put(uid, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
48
src/common/Api/LeCoffreApi/Notary/Users/Users.ts
Normal file
48
src/common/Api/LeCoffreApi/Notary/Users/Users.ts
Normal file
@ -0,0 +1,48 @@
|
||||
import BaseNotary from "../BaseNotary";
|
||||
import User from "le-coffre-resources/dist/Notary";
|
||||
|
||||
export type IGetUsersParams = {
|
||||
where?: {};
|
||||
include?: {};
|
||||
select?: {};
|
||||
};
|
||||
|
||||
export default class Users extends BaseNotary {
|
||||
private static instance: Users;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/users");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new Users();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
public async get(q?: IGetUsersParams): Promise<User[]> {
|
||||
const url = new URL(this.baseURl);
|
||||
const query = { q };
|
||||
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<User[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async getByUid(uid: string, q?: any): Promise<User> {
|
||||
const url = new URL(this.baseURl.concat("/").concat(uid));
|
||||
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<User>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
5
src/common/Api/LeCoffreApi/SuperAdmin/BaseSuperAdmin.ts
Normal file
5
src/common/Api/LeCoffreApi/SuperAdmin/BaseSuperAdmin.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import BaseApiService from "@Front/Api/BaseApiService";
|
||||
|
||||
export default abstract class BaseSuperAdmin extends BaseApiService {
|
||||
protected readonly namespaceUrl = this.getBaseUrl().concat("/super-admin");
|
||||
}
|
90
src/common/Api/LeCoffreApi/SuperAdmin/Customers/Customers.ts
Normal file
90
src/common/Api/LeCoffreApi/SuperAdmin/Customers/Customers.ts
Normal file
@ -0,0 +1,90 @@
|
||||
import { Contact, Customer } from "le-coffre-resources/dist/SuperAdmin";
|
||||
|
||||
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||
import { ECivility } from "le-coffre-resources/dist/Customer/Contact";
|
||||
|
||||
// TODO Type get query params -> Where + inclue + orderby
|
||||
export interface IGetCustomersparams {
|
||||
where?: {};
|
||||
include?: {};
|
||||
}
|
||||
|
||||
// TODO Type getbyuid query params
|
||||
|
||||
export type IPutCustomersParams = {
|
||||
uid?: Customer["uid"];
|
||||
contact?: Customer["contact"];
|
||||
};
|
||||
|
||||
export interface IPostCustomersParams {
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
email: string;
|
||||
cell_phone_number: string;
|
||||
civility: ECivility;
|
||||
address?: Contact["address"];
|
||||
}
|
||||
|
||||
export default class Customers extends BaseSuperAdmin {
|
||||
private static instance: Customers;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/customers");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new this();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
public async get(q: IGetCustomersparams): Promise<Customer[]> {
|
||||
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<Customer[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Create a Customer
|
||||
*/
|
||||
public async post(body: any): Promise<Customer> {
|
||||
const url = new URL(this.baseURl);
|
||||
try {
|
||||
return await this.postRequest<Customer>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async getByUid(uid: string, q?: any): Promise<Customer> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
const query = { q };
|
||||
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<Customer>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async put(uid: string, body: IPutCustomersParams): Promise<Customer> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.putRequest<Customer>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
92
src/common/Api/LeCoffreApi/SuperAdmin/DeedTypes/DeedTypes.ts
Normal file
92
src/common/Api/LeCoffreApi/SuperAdmin/DeedTypes/DeedTypes.ts
Normal file
@ -0,0 +1,92 @@
|
||||
import { DeedType } from "le-coffre-resources/dist/Notary";
|
||||
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||
|
||||
// TODO Type get query params -> Where + inclue + orderby
|
||||
export interface IGetDeedTypesParams {
|
||||
q?: {};
|
||||
}
|
||||
|
||||
// TODO Type getbyuid query params
|
||||
|
||||
export type IPutDeedTypesParams = {
|
||||
uid?: DeedType["uid"];
|
||||
name?: DeedType["name"];
|
||||
description?: DeedType["description"];
|
||||
deed?: DeedType["deed"];
|
||||
office?: DeedType["office"];
|
||||
archived_at?: DeedType["archived_at"];
|
||||
document_types?: DeedType["document_types"];
|
||||
};
|
||||
|
||||
export default class DeedTypes extends BaseSuperAdmin {
|
||||
private static instance: DeedTypes;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/deed-types");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new this();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get all DeedTypes
|
||||
*/
|
||||
public async get(q?: IGetDeedTypesParams): Promise<DeedType[]> {
|
||||
const url = new URL(this.baseURl);
|
||||
if(q){
|
||||
Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
}
|
||||
try {
|
||||
return await this.getRequest<DeedType[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get a folder by uid
|
||||
*/
|
||||
public async getByUid(uid: string, q?: any): Promise<DeedType> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<DeedType>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Create a deed
|
||||
*/
|
||||
// public async post(body: IPostDeedTypesParams): Promise<OfficeFolder> {
|
||||
// const url = new URL(this.baseURl);
|
||||
// try {
|
||||
// return await this.postRequest<OfficeFolder>(url, body);
|
||||
// } catch (err) {
|
||||
// this.onError(err);
|
||||
// return Promise.reject(err);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* @description : Update the folder description
|
||||
*/
|
||||
public async put(uid: string, body: IPutDeedTypesParams): Promise<DeedType> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.putRequest<DeedType>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
90
src/common/Api/LeCoffreApi/SuperAdmin/Deeds/Deeds.ts
Normal file
90
src/common/Api/LeCoffreApi/SuperAdmin/Deeds/Deeds.ts
Normal file
@ -0,0 +1,90 @@
|
||||
import { Deed, OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||
|
||||
// TODO Type get query params -> Where + inclue + orderby
|
||||
export interface IGetDeedsParams {
|
||||
q?: {};
|
||||
}
|
||||
|
||||
// TODO Type getbyuid query params
|
||||
|
||||
export type IPutDeedsParams = {
|
||||
uid?: OfficeFolder["uid"];
|
||||
folder_number?: OfficeFolder["folder_number"];
|
||||
name?: OfficeFolder["name"];
|
||||
description?: OfficeFolder["description"];
|
||||
archived_description?: OfficeFolder["archived_description"];
|
||||
status?: OfficeFolder["status"];
|
||||
document_types?: Deed["document_types"];
|
||||
};
|
||||
|
||||
export default class Deeds extends BaseSuperAdmin {
|
||||
private static instance: Deeds;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/deeds");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new this();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get all deeds
|
||||
*/
|
||||
public async get(q: IGetDeedsParams): Promise<Deed[]> {
|
||||
const url = new URL(this.baseURl);
|
||||
Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<Deed[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get a folder by uid
|
||||
*/
|
||||
public async getByUid(uid: string, q?: any): Promise<Deed> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<Deed>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Create a deed
|
||||
*/
|
||||
// public async post(body: IPostDeedsParams): Promise<OfficeFolder> {
|
||||
// const url = new URL(this.baseURl);
|
||||
// try {
|
||||
// return await this.postRequest<OfficeFolder>(url, body);
|
||||
// } catch (err) {
|
||||
// this.onError(err);
|
||||
// return Promise.reject(err);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* @description : Update the folder description
|
||||
*/
|
||||
public async put(uid: string, body: IPutDeedsParams): Promise<Deed> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.putRequest<Deed>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
import { DocumentType } from "le-coffre-resources/dist/SuperAdmin";
|
||||
|
||||
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||
|
||||
// TODO Type get query params -> Where + inclue + orderby
|
||||
export interface IGetDocumentTypesparams {
|
||||
where?: {};
|
||||
include?: {};
|
||||
}
|
||||
|
||||
// TODO Type getbyuid query params
|
||||
|
||||
export type IPutDocumentTypesParams = {};
|
||||
|
||||
export interface IPostDocumentTypesParams {
|
||||
name: string;
|
||||
public_description: string;
|
||||
private_description: string;
|
||||
office: {
|
||||
uid: string;
|
||||
};
|
||||
}
|
||||
|
||||
export default class DocumentTypes extends BaseSuperAdmin {
|
||||
private static instance: DocumentTypes;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/document-types");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new this();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
public async get(q?: IGetDocumentTypesparams): Promise<DocumentType[]> {
|
||||
const url = new URL(this.baseURl);
|
||||
if (q) {
|
||||
const query = { q };
|
||||
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
}
|
||||
try {
|
||||
return await this.getRequest<DocumentType[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Create a Document
|
||||
*/
|
||||
public async post(body: IPostDocumentTypesParams): Promise<DocumentType> {
|
||||
const url = new URL(this.baseURl);
|
||||
try {
|
||||
return await this.postRequest<DocumentType>(url, body as any);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async getByUid(uid: string, q?: any): Promise<DocumentType> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
const query = { q };
|
||||
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<DocumentType>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async put(uid: string, body: IPutDocumentTypesParams): Promise<DocumentType> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.putRequest<DocumentType>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
93
src/common/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts
Normal file
93
src/common/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts
Normal file
@ -0,0 +1,93 @@
|
||||
import { Document } from "le-coffre-resources/dist/SuperAdmin";
|
||||
|
||||
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
|
||||
|
||||
// TODO Type get query params -> Where + inclue + orderby
|
||||
export interface IGetDocumentsparams {
|
||||
where?: {};
|
||||
include?: {};
|
||||
}
|
||||
|
||||
// TODO Type getbyuid query params
|
||||
|
||||
export type IPutDocumentsParams = {
|
||||
document_status?: EDocumentStatus;
|
||||
refused_reason?: string;
|
||||
};
|
||||
|
||||
export interface IPostDocumentsParams {}
|
||||
|
||||
export default class Documents extends BaseSuperAdmin {
|
||||
private static instance: Documents;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/documents");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new this();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
public async get(q: IGetDocumentsparams): Promise<Document[]> {
|
||||
const url = new URL(this.baseURl);
|
||||
const query = { q };
|
||||
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<Document[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Create a Document
|
||||
*/
|
||||
public async post(body: any): Promise<Document> {
|
||||
const url = new URL(this.baseURl);
|
||||
try {
|
||||
return await this.postRequest<Document>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async getByUid(uid: string, q?: any): Promise<Document> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
const query = { q };
|
||||
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<Document>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async put(uid: string, body: IPutDocumentsParams): Promise<Document> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.putRequest<Document>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async delete(uid: string): Promise<Document> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.deleteRequest<Document>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
93
src/common/Api/LeCoffreApi/SuperAdmin/Files/Files.ts
Normal file
93
src/common/Api/LeCoffreApi/SuperAdmin/Files/Files.ts
Normal file
@ -0,0 +1,93 @@
|
||||
import { File } from "le-coffre-resources/dist/SuperAdmin";
|
||||
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||
|
||||
// TODO Type get query params -> Where + inclue + orderby
|
||||
export interface IGetFilesparams {
|
||||
where?: {};
|
||||
include?: {};
|
||||
}
|
||||
|
||||
// TODO Type getbyuid query params
|
||||
|
||||
export type IPutFilesParams = {};
|
||||
|
||||
export interface IPostFilesParams {}
|
||||
|
||||
export default class Files extends BaseSuperAdmin {
|
||||
private static instance: Files;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/files");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
return (this.instance ??= new this());
|
||||
}
|
||||
|
||||
public async get(q: IGetFilesparams): Promise<File[]> {
|
||||
const url = new URL(this.baseURl);
|
||||
const query = { q };
|
||||
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
const files = await this.getRequest<File[]>(url);
|
||||
return files;
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Create a File
|
||||
*/
|
||||
public async post(body: any): Promise<File> {
|
||||
const url = new URL(this.baseURl);
|
||||
try {
|
||||
return await this.postRequestFormData<File>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public getUploadLink(uid: string): string {
|
||||
return this.baseURl.concat(`/download/${uid}`);
|
||||
}
|
||||
|
||||
public async getByUid(uid: string, q?: any): Promise<File> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
const query = { q };
|
||||
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
const file = await this.getRequest<File>(url);
|
||||
return file;
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async put(uid: string, body: IPutFilesParams): Promise<File> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.putRequest<File>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Delete a folder only if the folder don't contains customers
|
||||
*/
|
||||
public async delete(uid: string): Promise<File> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.deleteRequest<File>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
119
src/common/Api/LeCoffreApi/SuperAdmin/Folders/Folders.ts
Normal file
119
src/common/Api/LeCoffreApi/SuperAdmin/Folders/Folders.ts
Normal file
@ -0,0 +1,119 @@
|
||||
import { type OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||
|
||||
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||
import EFolderStatus from "le-coffre-resources/dist/Customer/EFolderStatus";
|
||||
|
||||
// TODO Type get query params -> Where + inclue + orderby
|
||||
export interface IGetFoldersParams {
|
||||
q?: {
|
||||
select?: {};
|
||||
where?: {};
|
||||
include?: {};
|
||||
};
|
||||
}
|
||||
|
||||
export default class Folders extends BaseSuperAdmin {
|
||||
private static instance: Folders;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/folders");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new this();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get all folders
|
||||
*/
|
||||
public async get(q: IGetFoldersParams): Promise<OfficeFolder[]> {
|
||||
const url = new URL(this.baseURl);
|
||||
Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<OfficeFolder[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get a folder by uid
|
||||
*/
|
||||
public async getByUid(uid: string, q?: any): Promise<OfficeFolder> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<OfficeFolder>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Create a folder
|
||||
*/
|
||||
public async post(officeFolder: Partial<OfficeFolder>): Promise<OfficeFolder> {
|
||||
const url = new URL(this.baseURl);
|
||||
try {
|
||||
return await this.postRequest(url, officeFolder);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Update the folder description
|
||||
*/
|
||||
public async put(uid: string, body: Partial<OfficeFolder>): Promise<OfficeFolder> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.putRequest(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Delete a folder only if the folder don't contains customers
|
||||
*/
|
||||
public async delete(uid: string): Promise<OfficeFolder> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
const targetedFolder = await this.getByUid(uid);
|
||||
if (targetedFolder.customers) return Promise.reject(`The folder ${uid} contains customers`);
|
||||
try {
|
||||
return await this.deleteRequest(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async archive(uid: string, body: Partial<OfficeFolder>): Promise<OfficeFolder> {
|
||||
body.status = EFolderStatus.ARCHIVED;
|
||||
try {
|
||||
return await this.put(uid, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async restore(uid: string, body: Partial<OfficeFolder>): Promise<OfficeFolder> {
|
||||
body.status = EFolderStatus.LIVE;
|
||||
try {
|
||||
return await this.put(uid, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
49
src/common/Api/LeCoffreApi/SuperAdmin/LiveVotes/LiveVotes.ts
Normal file
49
src/common/Api/LeCoffreApi/SuperAdmin/LiveVotes/LiveVotes.ts
Normal file
@ -0,0 +1,49 @@
|
||||
import { Appointment } 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 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<LiveVote> {
|
||||
const url = new URL(this.baseURl);
|
||||
try {
|
||||
return await this.postRequest<LiveVote>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
53
src/common/Api/LeCoffreApi/SuperAdmin/Offices/Offices.ts
Normal file
53
src/common/Api/LeCoffreApi/SuperAdmin/Offices/Offices.ts
Normal file
@ -0,0 +1,53 @@
|
||||
import { Office } from "le-coffre-resources/dist/SuperAdmin";
|
||||
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||
|
||||
export interface IGetOfficesparams {
|
||||
where?: {};
|
||||
include?: {};
|
||||
select?: {};
|
||||
}
|
||||
|
||||
export default class Offices extends BaseSuperAdmin {
|
||||
private static instance: Offices;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/offices");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new this();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
public async get(q?: IGetOfficesparams): Promise<Office[]> {
|
||||
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<Office[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get a folder by uid
|
||||
*/
|
||||
public async getByUid(uid: string, q?: any): Promise<Office> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<Office>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
91
src/common/Api/LeCoffreApi/SuperAdmin/Users/Users.ts
Normal file
91
src/common/Api/LeCoffreApi/SuperAdmin/Users/Users.ts
Normal file
@ -0,0 +1,91 @@
|
||||
import User from "le-coffre-resources/dist/SuperAdmin";
|
||||
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||
|
||||
// TODO Type get query params -> Where + inclue + orderby
|
||||
export interface IGetUsersparams {
|
||||
where?:{},
|
||||
include?:{},
|
||||
select?:{},
|
||||
}
|
||||
|
||||
// TODO Type getbyuid query params
|
||||
|
||||
export type IPutUsersParams = {
|
||||
uid?: User["uid"];
|
||||
idNot?: User["idNot"];
|
||||
contact?: User["contact"];
|
||||
office_membership?: User["office_membership"];
|
||||
documents?: User["documents"];
|
||||
};
|
||||
|
||||
export default class Users extends BaseSuperAdmin {
|
||||
private static instance: Users;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/users");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new this();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get all Users
|
||||
*/
|
||||
public async get(q: IGetUsersparams): Promise<User[]> {
|
||||
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<User[]>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get a folder by uid
|
||||
*/
|
||||
public async getByUid(uid: string, q?: any): Promise<User> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||
try {
|
||||
return await this.getRequest<User>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Create a User
|
||||
*/
|
||||
// public async post(body: IPostDeedsParams): Promise<OfficeFolder> {
|
||||
// const url = new URL(this.baseURl);
|
||||
// try {
|
||||
// return await this.postRequest<OfficeFolder>(url, body);
|
||||
// } catch (err) {
|
||||
// this.onError(err);
|
||||
// return Promise.reject(err);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* @description : Update the folder description
|
||||
*/
|
||||
public async put(uid: string, body: IPutUsersParams): Promise<User> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
try {
|
||||
return await this.putRequest<User>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
44
src/common/Api/LeCoffreApi/SuperAdmin/Votes/Votes.ts
Normal file
44
src/common/Api/LeCoffreApi/SuperAdmin/Votes/Votes.ts
Normal file
@ -0,0 +1,44 @@
|
||||
import { Vote } from "le-coffre-resources/dist/SuperAdmin";
|
||||
|
||||
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||
|
||||
// TODO Type get query params -> Where + inclue + orderby
|
||||
export interface IGetVotessparams {
|
||||
where?: {};
|
||||
include?: {};
|
||||
select?: {};
|
||||
}
|
||||
|
||||
export type IDeleteVotesParams = {
|
||||
uid: Vote["uid"];
|
||||
};
|
||||
|
||||
export default class Votes extends BaseSuperAdmin {
|
||||
private static instance: Votes;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/votes");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new this();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Create a Votes
|
||||
*/
|
||||
public async delete(body: IDeleteVotesParams): Promise<Vote> {
|
||||
const url = new URL(this.baseURl + "/" + body.uid);
|
||||
try {
|
||||
return await this.deleteRequest<Vote>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
5
src/front/Api/LeCoffreApi/Id360/BaseId360.ts
Normal file
5
src/front/Api/LeCoffreApi/Id360/BaseId360.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import BaseApiService from "@Front/Api/BaseApiService";
|
||||
|
||||
export default abstract class BaseNotary extends BaseApiService {
|
||||
protected readonly namespaceUrl = this.getBaseUrl().concat("/id360");
|
||||
}
|
45
src/front/Api/LeCoffreApi/Id360/Customers/Customers.ts
Normal file
45
src/front/Api/LeCoffreApi/Id360/Customers/Customers.ts
Normal file
@ -0,0 +1,45 @@
|
||||
import BaseId360 from "../BaseId360";
|
||||
|
||||
export interface IConnectionUrlResponse {
|
||||
enrollment: {
|
||||
franceConnectUrl: string;
|
||||
processId: string;
|
||||
}
|
||||
}
|
||||
|
||||
export default class Customers extends BaseId360 {
|
||||
private static instance: Customers;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/customers");
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
return new this();
|
||||
} else {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
public async login(): Promise<IConnectionUrlResponse> {
|
||||
const url = new URL(this.baseURl.concat(`/login`));
|
||||
try {
|
||||
return await this.postRequest<IConnectionUrlResponse>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async loginCallback(callbackToken: string | string[]): Promise<any> {
|
||||
const url = new URL(this.baseURl.concat(`/login-callback/${callbackToken}`));
|
||||
try {
|
||||
return await this.postRequest<any>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
@ -51,8 +51,14 @@ export default class Files extends BaseSuperAdmin {
|
||||
}
|
||||
}
|
||||
|
||||
public getUploadLink(uid: string): string {
|
||||
return this.baseURl.concat(`/download/${uid}`);
|
||||
public async getUploadLink(uid: string) {
|
||||
const url = new URL(this.baseURl.concat(`/download/${uid}`));
|
||||
try {
|
||||
return await this.getRequest<File>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async getByUid(uid: string, q?: any): Promise<File> {
|
||||
|
@ -4,8 +4,6 @@ import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
||||
import Typography, { ITypo } from "@Front/Components/DesignSystem/Typography";
|
||||
import DefaultDoubleSidePage from "@Front/Components/LayoutTemplates/DefaultDoubleSidePage";
|
||||
import Module from "@Front/Config/Module";
|
||||
import JwtService from "@Front/Services/JwtService/JwtService";
|
||||
import UserStore from "@Front/Stores/UserStore";
|
||||
import Image from "next/image";
|
||||
import { useRouter } from "next/router";
|
||||
import { useCallback } from "react";
|
||||
@ -13,6 +11,7 @@ import { useCallback } from "react";
|
||||
import classes from "./classes.module.scss";
|
||||
import LandingImage from "./landing-connect.jpeg";
|
||||
import { FrontendVariables } from "@Front/Config/VariablesFront";
|
||||
import Customers from "@Front/Api/LeCoffreApi/Id360/Customers/Customers";
|
||||
|
||||
export default function Login() {
|
||||
const router = useRouter();
|
||||
@ -29,14 +28,12 @@ export default function Login() {
|
||||
const redirectCustomerOnConnection = useCallback(() => {
|
||||
async function getCustomer() {
|
||||
try {
|
||||
await UserStore.instance.connectCustomer("antoine.bernard@outlook.com");
|
||||
await JwtService.getInstance().checkJwt();
|
||||
router.push(Module.getInstance().get().modules.pages.Folder.pages.Select.props.path);
|
||||
const loginRes = await Customers.getInstance().login();
|
||||
router.push(loginRes.enrollment.franceConnectUrl);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
getCustomer();
|
||||
}, [router]);
|
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
@import "@Themes/constants.scss";
|
||||
|
||||
.root {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
max-width: 530px;
|
||||
margin: auto;
|
||||
|
||||
.title {
|
||||
margin: 32px 0;
|
||||
text-align: center;
|
||||
@media (max-width: $screen-s) {
|
||||
font-family: 48px;
|
||||
}
|
||||
}
|
||||
|
||||
.loader {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.forget-password {
|
||||
margin-top: 32px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
}
|
55
src/front/Components/Layouts/LoginCallbackCustomer/index.tsx
Normal file
55
src/front/Components/Layouts/LoginCallbackCustomer/index.tsx
Normal file
@ -0,0 +1,55 @@
|
||||
import LandingImage from "../Login/landing-connect.jpeg";
|
||||
import Image from "next/image";
|
||||
import CoffreIcon from "@Assets/Icons/coffre.svg";
|
||||
import { useRouter } from "next/router";
|
||||
import React, { useEffect } from "react";
|
||||
import classes from "./classes.module.scss";
|
||||
//import Module from "@Front/Config/Module";
|
||||
//import Auth from "@Front/Api/Auth/IdNot";
|
||||
import DefaultDoubleSidePage from "@Front/Components/LayoutTemplates/DefaultDoubleSidePage";
|
||||
import Typography, { ITypo } from "@Front/Components/DesignSystem/Typography";
|
||||
import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
||||
import Loader from "@Front/Components/DesignSystem/Loader";
|
||||
// import { FrontendVariables } from "@Front/Config/VariablesFront";
|
||||
// import CustomerStore from "@Front/Stores/CustomerStore";
|
||||
import Customers from "@Front/Api/LeCoffreApi/Id360/Customers/Customers";
|
||||
import CustomerStore from "@Front/Stores/CustomerStore";
|
||||
import Module from "@Front/Config/Module";
|
||||
|
||||
|
||||
export default function LoginCallBack() {
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
const getReport = async() => {
|
||||
const tokenid360 = router.query["token"];
|
||||
if (!tokenid360) return;
|
||||
// const variables = FrontendVariables.getInstance();
|
||||
// console.log(`${variables.DOCAPOST_API_URL}/enrollment/status/${tokenid360}/`)
|
||||
// const reportRes = await fetch(`${variables.DOCAPOST_API_URL}/enrollment/status/${tokenid360}`, { method: "GET"});
|
||||
// const report = await reportRes.json() as id360ProcessResponse;
|
||||
const token = await Customers.getInstance().loginCallback(tokenid360);
|
||||
CustomerStore.instance.connect(token.accessToken, token.refreshToken);
|
||||
router.push(Module.getInstance().get().modules.pages.Folder.pages.Select.props.path);
|
||||
}
|
||||
getReport();
|
||||
}),[router];
|
||||
|
||||
return (
|
||||
<DefaultDoubleSidePage title={"Login"} image={LandingImage}>
|
||||
<div className={classes["root"]}>
|
||||
<Image alt="coffre" src={CoffreIcon} />
|
||||
<Typography typo={ITypo.H1}>
|
||||
<div className={classes["title"]}>Connexion espace client</div>
|
||||
</Typography>
|
||||
<div className={classes["loader"]}>
|
||||
<Loader />
|
||||
</div>
|
||||
<Typography typo={ITypo.P_18}>
|
||||
<div className={classes["forget-password"]}>Vous n'arrivez pas à vous connecter ?</div>
|
||||
</Typography>
|
||||
<Button variant={EButtonVariant.LINE}>Contacter l'administrateur</Button>
|
||||
</div>
|
||||
</DefaultDoubleSidePage>
|
||||
);
|
||||
}
|
@ -17,6 +17,8 @@ export class FrontendVariables {
|
||||
|
||||
public IDNOT_CLIENT_ID!: string;
|
||||
|
||||
public DOCAPOST_API_URL!: string;
|
||||
|
||||
public KEY_DATA!: string;
|
||||
|
||||
public FC_AUTHORIZE_ENDPOINT!: string;
|
||||
|
77
src/front/Stores/CustomerStore.ts
Normal file
77
src/front/Stores/CustomerStore.ts
Normal file
@ -0,0 +1,77 @@
|
||||
"use client";
|
||||
|
||||
import Customer from "@Front/Api/Auth/franceConnect/Customer";
|
||||
import CookieService from "@Front/Services/CookieService/CookieService";
|
||||
import EventEmitter from "@Front/Services/EventEmitter";
|
||||
import JwtService from "@Front/Services/JwtService/JwtService";
|
||||
|
||||
export default class UserStore {
|
||||
public static readonly instance = new this();
|
||||
protected readonly event = new EventEmitter();
|
||||
public accessToken: string | null = null;
|
||||
public refreshToken: string | null = null;
|
||||
|
||||
private constructor() {}
|
||||
|
||||
public isConnected(): boolean {
|
||||
return !!this.accessToken;
|
||||
}
|
||||
|
||||
public getRole(): string | undefined {
|
||||
const decodedPayload = JwtService.getInstance().decodeJwt();
|
||||
return decodedPayload?.role;
|
||||
}
|
||||
|
||||
public async connect(accessToken: string, refreshToken: string) {
|
||||
try {
|
||||
//Save tokens in cookies
|
||||
CookieService.getInstance().setCookie("leCoffreAccessToken", accessToken);
|
||||
CookieService.getInstance().setCookie("leCoffreRefreshToken", refreshToken);
|
||||
|
||||
this.event.emit("connection", this.accessToken);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public async connectCustomer(email: string) {
|
||||
try {
|
||||
//call connection function
|
||||
const customer: any = await Customer.getInstance().login(email);
|
||||
|
||||
//Save tokens in cookies
|
||||
CookieService.getInstance().setCookie("leCoffreAccessToken", customer.accessToken);
|
||||
CookieService.getInstance().setCookie("leCoffreRefreshToken", customer.refreshToken);
|
||||
|
||||
this.event.emit("connection", this.accessToken);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public async disconnect() {
|
||||
try {
|
||||
//Remove tokens from cookies
|
||||
CookieService.getInstance().deleteCookie("leCoffreAccessToken");
|
||||
CookieService.getInstance().deleteCookie("leCoffreRefreshToken");
|
||||
|
||||
this.event.emit("disconnection", this.accessToken);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
public onDisconnect(callback: (userAddress: string) => void): () => void {
|
||||
this.event.on("disconnection", callback);
|
||||
return () => this.event.off("disconnection", callback);
|
||||
}
|
||||
|
||||
public onConnect(callback: (userAddress: string) => void): () => void {
|
||||
this.event.on("connection", callback);
|
||||
return () => this.event.off("connection", callback);
|
||||
}
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
import Notifications from "@Front/Api/LeCoffreApi/Notifications/Notifications";
|
||||
import { ICustomerJwtPayload, IUserJwtPayload } from "@Front/Services/JwtService/JwtService";
|
||||
import jwt_decode from "jwt-decode";
|
||||
import { NextResponse } from "next/server";
|
||||
@ -21,8 +20,8 @@ export async function middleware(request: NextRequest) {
|
||||
const currentDate = new Date();
|
||||
const time = currentDate.getTime();
|
||||
const now = Math.floor(time / 1000);
|
||||
|
||||
if (token.exp < now) {
|
||||
console.log("token expired");
|
||||
return NextResponse.redirect(new URL("/login", request.url));
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ type AppPropsWithLayout = AppProps & {
|
||||
idNotClientId: string;
|
||||
fcAuthorizeEndpoint: string;
|
||||
fcClientId: string;
|
||||
docaposteApiUrl: string;
|
||||
};
|
||||
|
||||
const MyApp = (({
|
||||
@ -36,7 +37,8 @@ const MyApp = (({
|
||||
idNotAuthorizeEndpoint,
|
||||
idNotClientId,
|
||||
fcAuthorizeEndpoint,
|
||||
fcClientId
|
||||
fcClientId,
|
||||
docaposteApiUrl
|
||||
}: AppPropsWithLayout) => {
|
||||
const getLayout = Component.getLayout ?? ((page) => <DefaultLayout children={page}></DefaultLayout>);
|
||||
|
||||
@ -51,6 +53,7 @@ const MyApp = (({
|
||||
instance.IDNOT_CLIENT_ID = idNotClientId ?? "4501646203F3EF67";
|
||||
instance.FC_AUTHORIZE_ENDPOINT= fcAuthorizeEndpoint ?? "https://fcp.integ01.dev-franceconnect.fr/api/v1/authorize";
|
||||
instance.FC_CLIENT_ID = fcClientId ?? "211286433e39cce01db448d80181bdfd005554b19cd51b3fe7943f6b3b86ab6e";
|
||||
instance.DOCAPOST_API_URL = docaposteApiUrl;
|
||||
|
||||
return getLayout(<Component {...pageProps} />);
|
||||
}) as AppType;
|
||||
@ -67,7 +70,8 @@ MyApp.getInitialProps = async () => {
|
||||
idNotAuthorizeEndpoint: process.env["NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT"],
|
||||
idNotClientId: process.env["NEXT_PUBLIC_IDNOT_CLIENT_ID"],
|
||||
fcAuthorizeEndpoint: process.env["NEXT_PUBLIC_FC_AUTHORIZE_ENDPOINT"],
|
||||
fcClientId: process.env["NEXT_PUBLIC_FC_CLIENT_ID"]
|
||||
fcClientId: process.env["NEXT_PUBLIC_FC_CLIENT_ID"],
|
||||
docaposteApiUrl: process.env["NEXT_PUBLIC_DOCAPOST_API_URL"],
|
||||
};
|
||||
};
|
||||
|
||||
|
5
src/pages/id360/customer-callback.tsx
Normal file
5
src/pages/id360/customer-callback.tsx
Normal file
@ -0,0 +1,5 @@
|
||||
import LoginCallBackCustomer from "@Front/Components/Layouts/LoginCallbackCustomer";
|
||||
|
||||
export default function Route() {
|
||||
return <LoginCallBackCustomer />;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user