src/controllers/requestController.js
/**
   * @description This helps requester to create trip request
   * @param  {object} req - The request object
   * @param  {object} res - The response object
   * @returns {object} The response object
   */
@description This helps requester to create trip request
@param  {object} req - The request object
@param  {object} res - The response object
@returns {object} The response object
@description This helps requester to create trip request @param { object } req - The request object @param { object } res - The response object @returns { object } The response object
static async create(req, res, next) {
    try {
      const { userData } = req;
      const {
        origin,
        destination,
        travelDates,
        returnDate,
        reason,
        accommodation_id,
        dob,
        passportName,
        passportNumber,
        gender
      } = req.value;
      const info = {
        user_id: userData.id,
        origin,
        accommodation_id,
        destination: Array.isArray(destination) ? destination : [destination],
        travel_date: Array.isArray(travelDates) ? travelDates : [travelDates],
        return_date: returnDate,
        reason,
        dob,
        passportName,
        passportNumber,
        gender
      };
      const { dataValues } = await Request.create(info);
      if (dataValues) {
        const notification = {
          eventType: 'created_request',
          requestId: dataValues.id
        };
        eventEmitter.emit('notification', notification);
        onSuccess(res, 201, 'Your request has sent successfully, wait for approval', dataValues);
      }
      return next();
    } catch (ex) {
      onError(res, 500, 'Internal Server Error');
    }
  }
static async create ( req , res , next ) { try { const { userData } = req ; const { origin , destination , travelDates , returnDate , reason , accommodation_id , dob , passportName , passportNumber , gender } = req . value ; const info = { user_id : userData . id , origin , accommodation_id , destination : Array . isArray ( destination ) ? destination : [ destination ] , travel_date : Array . isArray ( travelDates ) ? travelDates : [ travelDates ] , return_date : returnDate , reason , dob , passportName , passportNumber , gender } ; const { dataValues } = await Request . create ( info ) ; if ( dataValues ) { const notification = { eventType : 'created_request' , requestId : dataValues . id } ; eventEmitter . emit ( 'notification' , notification ) ; onSuccess ( res , 201 , 'Your request has sent successfully, wait for approval' , dataValues ) ; } return next ( ) ; } catch ( ex ) { onError ( res , 500 , 'Internal Server Error' ) ; } }
@description This helps requester to create trip request
 @param  {object} req - The request object
 @param  {object} res - The response object
 @returns {object} The response object
@description This helps requester to create trip request @param { object } req - The request object @param { object } res - The response object @returns { object } The response object
// eslint-disable-next-line camelcase