Feat(booking): Added updateBookingStatus
All checks were successful
ktm-booking-bot/ktm-booking-bot/pipeline/head This commit looks good
All checks were successful
ktm-booking-bot/ktm-booking-bot/pipeline/head This commit looks good
This commit is contained in:
@@ -123,3 +123,37 @@ func (env *Env) deleteBookingRoute(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
render.Render(w, r, env.NewBookingResponse(booking))
|
||||
}
|
||||
|
||||
// Change booking status
|
||||
// @Summary Changing booking status
|
||||
// @Description Description
|
||||
// @Tags ktmtrainbot Booking
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param bookingID path string true "Booking ID"
|
||||
// @Param status path string true "Status"
|
||||
// @Success 200 {object} BookingResponse
|
||||
// @Failure 400 {object} common.ErrResponse
|
||||
// @Router /api/v1/ktmtrainbot/booking/{bookingID}/{status} [put]
|
||||
func (env *Env) updateBookingStatusRoute(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
currUser, ok := ctx.Value(user.UserContextKey).(*user.User)
|
||||
if !ok {
|
||||
err := errors.New("user not logged in")
|
||||
render.Render(w, r, common.ErrInternalError(err))
|
||||
return
|
||||
}
|
||||
_ = currUser
|
||||
|
||||
bookingID := chi.URLParam(r, "bookingID")
|
||||
status := chi.URLParam(r, "status")
|
||||
|
||||
booking, err := env.updateBookingStatus(currUser, bookingID, status)
|
||||
|
||||
if err != nil {
|
||||
render.Render(w, r, common.ErrInvalidRequest(err))
|
||||
return
|
||||
}
|
||||
|
||||
render.Render(w, r, env.NewBookingResponse(booking))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user