Exemplo n.º 1
0
  /**
   * This API creates a new entry for extend booking
   *
   * @requestBody SpotBookedRequestDTO
   * @return SpotBookedResponseDTO
   * @throws Exception
   */
  @ApiOperation(
      value = "Create Extend Booking",
      notes = "Creates entry for extend booking for a spot",
      httpMethod = "POST")
  @ApiResponses(
      value = {
        @ApiResponse(code = 500, message = "Internal Server error"),
        @ApiResponse(code = 403, message = "Forbidden"),
        @ApiResponse(code = 404, message = "Not Found"),
        @ApiResponse(code = 400, message = "Bad Request"),
        @ApiResponse(code = 201, message = "Created")
      })
  @RequestMapping(
      value = "/createExtendPGW",
      method = RequestMethod.POST,
      consumes = "application/json",
      produces = "application/json")
  @ResponseBody
  public ResponseEntity<SpotBookedResponseDTO> extendReservationPGW(
      @ApiParam @RequestBody SpotBookedRequestDTO spotbookedDTO) throws BookingException {

    logger.debug(
        this.getClass().getSimpleName(),
        "createExtendPGW",
        "Creates a new reservation for extending a spot" + spotbookedDTO.getSpotId());

    assertNotBlank(spotbookedDTO.getSpotId(), ErrorMessages.NULLSPOTID);
    assertNotBlank(spotbookedDTO.getLotId(), ErrorMessages.NULLLOTID);
    assertNotBlank(spotbookedDTO.getDongName(), "dongName cannot be null");
    assertNotBlank(spotbookedDTO.getUserName(), "userName cannot be null");
    assertNotBlank(spotbookedDTO.getVehicleNumber(), "vehicleNumber cannot be null");
    assertNotBlank(spotbookedDTO.getPhoneNumber(), "PhoneNumber cannot be null");
    assertNotBlank(spotbookedDTO.getUserId(), ErrorMessages.NULLUSERID);
    assertNotBlank(spotbookedDTO.getReservationId(), ErrorMessages.NULLRESERVATIONID);

    logger.debug(
        "/createExtend API request body for "
            + spotbookedDTO.getReservationId()
            + " is "
            + "\n"
            + spotbookedDTO.toString());
    SpotBookedResponseDTO response = reservationService.createExtendBookingPGW(spotbookedDTO);

    logger.debug(
        "/createExtend API response body for "
            + spotbookedDTO.getReservationId()
            + " is "
            + "\n"
            + response.toString());
    return new ResponseEntity<>(response, HttpStatus.OK);
  }