.
This commit is contained in:
parent
2843dfc4ef
commit
9508ae9936
@ -224,10 +224,43 @@ routes.get(
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* @api {get} /api/v4/web/reservations/code/:encodedCode Recupera la reserva asociada al Código de Invitación (GetReservationFromCode)
|
||||
* @apiName GetReservationFromCode
|
||||
* @apiGroup Eventos
|
||||
* @apiVersion 4.0.0
|
||||
* @apiDescription Este endpoint verifica un código de reserva devolviendo al evento y entidad a la que pertenece. El código de invitación está codificado en Base64.
|
||||
*
|
||||
* @apiParam {String} encodedCode Código de invitación codificado en Base64. Ejemplo, el código "MD22-4939" se codifica como "TUQyMi00OTM5"
|
||||
*
|
||||
* @apiSuccess {Boolean} applicable Indica si el código de invitación es aplicable (true) o no (false).
|
||||
*
|
||||
* @apiSuccessExample {json} Ejemplo de Respuesta Exitosa:
|
||||
* HTTP/1.1 200 OK
|
||||
* true
|
||||
*
|
||||
* @apiSuccessExample {json} Ejemplo de Respuesta Fallida:
|
||||
* HTTP/1.1 200 OK
|
||||
* false
|
||||
*/
|
||||
|
||||
|
||||
routes.get(
|
||||
"/web/reservations/code/:code",
|
||||
// isAPIKeyUser,
|
||||
eventReservationController.getReservationFromCode
|
||||
isAPIKeyUser,
|
||||
FieldMiddleware.middleware({
|
||||
invalidFields: generalInvalidFields,
|
||||
}),
|
||||
(req, res, next) => {
|
||||
res.locals.v4 = {
|
||||
removeFields: [
|
||||
"assistanceType",
|
||||
"assistanceTypeText",
|
||||
"state",
|
||||
],
|
||||
};
|
||||
return eventReservationController.getReservationFromCode(req, res, next);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -111,7 +111,7 @@ const extraControllers = {
|
||||
|
||||
getReservationFromCode: async (req, res, next) => {
|
||||
const params = extractParamsFromRequest(req, res, {});
|
||||
console.log("getReservationFromCode - PARAMS ", params);
|
||||
|
||||
|
||||
const encodedInvitationCode = params.params.code;
|
||||
|
||||
@ -120,6 +120,27 @@ const extraControllers = {
|
||||
try {
|
||||
const result = await eventReservationService._getReservaByOnlyCode(registrationCode);
|
||||
|
||||
//MAPEO SALIDA API4
|
||||
//Tratamos resultado, si hay que remover campos para API4 web
|
||||
if (res.locals.v4){
|
||||
const arrayFieldsremove = res.locals.v4.removeFields;
|
||||
arrayFieldsremove.forEach(campo => {
|
||||
if (campo in result) {
|
||||
delete result[campo];
|
||||
}
|
||||
});
|
||||
};
|
||||
//En lugar de estar quitando campo creamos un DTO nuevo con la información que nos interesa
|
||||
/*const inscriptionResume = {
|
||||
id : inscription.id,
|
||||
stateText : inscription.stateText,
|
||||
code_ticket : inscription.code_ticket,
|
||||
eventName : inscription.event.name,
|
||||
userName : inscription.user.name,
|
||||
userSurname : inscription.user.surname,
|
||||
};
|
||||
inscription = inscriptionResume;
|
||||
*/
|
||||
console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>RESULT>>>>>>>>>>>>>>>>>>>>>>>>>><<', result);
|
||||
|
||||
if (!result)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user