Merge branch 'dev' into staging
This commit is contained in:
commit
a21b35f9a5
34
src/app/api/idnot/OfficeController.ts
Normal file
34
src/app/api/idnot/OfficeController.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { Response, Request } from "express";
|
||||||
|
import { Controller, Get } from "@ControllerPattern/index";
|
||||||
|
import ApiController from "@Common/system/controller-pattern/ApiController";
|
||||||
|
import { Service } from "typedi";
|
||||||
|
import IdNotService from "@Services/common/IdNotService/IdNotService";
|
||||||
|
|
||||||
|
@Controller()
|
||||||
|
@Service()
|
||||||
|
export default class UserController extends ApiController {
|
||||||
|
constructor (private idNotService: IdNotService) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get("/api/v1/idnot/office/:uid/office-memberships")
|
||||||
|
protected async getOfficeMemberships(req: Request, response: Response) {
|
||||||
|
try {
|
||||||
|
const uid = req.params["uid"];
|
||||||
|
if (!uid) {
|
||||||
|
this.httpBadRequest(response, "uid is required");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const officeMemberships = await this.idNotService.getOfficeMemberships(uid);
|
||||||
|
this.httpSuccess(response, officeMemberships);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
this.httpInternalError(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -48,7 +48,7 @@ import UserNotificationController from "./api/notary/UserNotificationController"
|
|||||||
import AuthController from "./api/customer/AuthController";
|
import AuthController from "./api/customer/AuthController";
|
||||||
import NotaryOfficeRibController from "./api/notary/OfficeRibController";
|
import NotaryOfficeRibController from "./api/notary/OfficeRibController";
|
||||||
import CustomerOfficeRibController from "./api/customer/OfficeRibController";
|
import CustomerOfficeRibController from "./api/customer/OfficeRibController";
|
||||||
|
import IdNotOfficeController from "./api/idnot/OfficeController";
|
||||||
/**
|
/**
|
||||||
* @description This allow to declare all controllers used in the application
|
* @description This allow to declare all controllers used in the application
|
||||||
*/
|
*/
|
||||||
@ -104,5 +104,6 @@ export default {
|
|||||||
Container.get(AuthController);
|
Container.get(AuthController);
|
||||||
Container.get(NotaryOfficeRibController);
|
Container.get(NotaryOfficeRibController);
|
||||||
Container.get(CustomerOfficeRibController);
|
Container.get(CustomerOfficeRibController);
|
||||||
|
Container.get(IdNotOfficeController)
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -121,12 +121,20 @@ export default class IdNotService extends BaseService {
|
|||||||
code: code,
|
code: code,
|
||||||
grant_type: "authorization_code",
|
grant_type: "authorization_code",
|
||||||
});
|
});
|
||||||
|
console.log(this.variables.IDNOT_BASE_URL + this.variables.IDNOT_CONNEXION_URL + "?" + query.toString());
|
||||||
|
|
||||||
|
|
||||||
const token = await fetch(this.variables.IDNOT_BASE_URL + this.variables.IDNOT_CONNEXION_URL + "?" + query, { method: "POST" });
|
const token = await fetch(this.variables.IDNOT_BASE_URL + this.variables.IDNOT_CONNEXION_URL + "?" + query, { method: "POST" });
|
||||||
|
console.log(token.status);
|
||||||
|
|
||||||
if(token.status !== 200) console.error(await token.text());
|
if(token.status !== 200) console.error(await token.text());
|
||||||
|
|
||||||
const decodedToken = (await token.json()) as IIdNotToken;
|
const decodedToken = (await token.json()) as IIdNotToken;
|
||||||
|
console.log(decodedToken);
|
||||||
|
|
||||||
const decodedIdToken = jwt.decode(decodedToken.id_token) as IdNotJwtPayload;
|
const decodedIdToken = jwt.decode(decodedToken.id_token) as IdNotJwtPayload;
|
||||||
|
console.log(decodedIdToken);
|
||||||
|
|
||||||
|
|
||||||
return decodedIdToken;
|
return decodedIdToken;
|
||||||
}
|
}
|
||||||
@ -173,6 +181,19 @@ export default class IdNotService extends BaseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getOfficeMemberships(officeId: string) {
|
||||||
|
const officeInfos = await this.officeService.getByUid(officeId);
|
||||||
|
const office = Office.hydrate<Office>(officeInfos!);
|
||||||
|
const searchParams = new URLSearchParams({
|
||||||
|
key: this.variables.IDNOT_API_KEY,
|
||||||
|
});
|
||||||
|
return (await (
|
||||||
|
await fetch(`${this.variables.IDNOT_API_BASE_URL}/api/pp/v2/entites/${office.idNot}/personnes?` + searchParams, {
|
||||||
|
method: "GET",
|
||||||
|
})
|
||||||
|
).json()) as any;
|
||||||
|
}
|
||||||
|
|
||||||
public getOfficeStatus(statusName: string) {
|
public getOfficeStatus(statusName: string) {
|
||||||
switch (statusName) {
|
switch (statusName) {
|
||||||
case "Pourvu":
|
case "Pourvu":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user