-
Notifications
You must be signed in to change notification settings - Fork 1
Review
The review module manages user and rental reviews, allowing renters to add, view, edit, and delete reviews. This module also includes functionality for searching reviews, checking and sending coupons to users, and updating user ratings based on reviews.
This function allows a renter to add a new review for another user who rented an item from him.
POST /review/user
- Extract Review Details: Retrieves the required data from the request body.
- Validation: Validates that the necessary fields are provided.
-
Insert Review Record: Adds the review to the
Reviewtable with relevant details, including the reviewer and reviewee IDs, rating, and comment. - Response: Returns a success message or an error if any issues arise during insertion.
This function allows users to add reviews specifically for rentals.
POST /review/rental
- Extract Review Details: Gathers the rental review data from the request body.
- Validation: Checks for necessary fields.
-
Insert Rental Review Record: Adds a new review to the
Reviewtable, associating it with the specific rental. - Response: Sends a confirmation message upon successful insertion.
Fetches all reviews related to a specific rental by rental_id.
GET /review/Rental/:rental_id
-
Rental ID Extraction: Retrieves the
rental_idfrom the URL parameters. -
Database Query: Finds all reviews associated with the provided
rental_id. - Response: Returns a list of reviews for the rental or an error if none are found.
Retrieves all reviews for a particular user by Userid.
GET /review/User/:Userid
-
User ID Extraction: Extracts
Useridfrom the URL parameters. - Database Query: Retrieves reviews where the target is the specified user.
- Response: Returns the list of user reviews or an error if none are found.
Enables a user to edit an existing review that they authored.
PUT review/:review_id/:reviewer_id
- Extract Review ID and Reviewer ID: Retrieves these IDs from the URL parameters.
-
Validation and Authorization Check: Confirms that the review exists and the
reviewer_idmatches the authenticated user. - Update Review Content: Modifies the review content based on new information provided in the request body.
- Response: Sends a success message or error message if the update fails.
Allows users to delete a review they have authored by providing the review_id.
DELETE /review/:review_id
-
Extract Review ID: Gets
review_idfrom the URL parameters. - Authorization Check: Confirms that the user has permission to delete this review.
-
Delete Review: Removes the review from the
Reviewtable. - Response: Sends a confirmation message upon successful deletion.
Searches for reviews based on a keyword.
GET /review/data/:name
-
Extract Search Keyword: Gets
namefrom the URL parameters. -
Database Query: Searches the
Reviewtable for reviews that match the keyword. - Response: Returns a list of reviews that match the search criteria.
Checks the eligibility of a user for a coupon and sends it via chatting if eligible.
GET /review/send-coupon/:user_id
-
User ID Extraction: Gets
user_idfrom the URL parameters. - Eligibility Check: Verifies if the user qualifies for a coupon.
- Send Coupon: If eligible, sends a coupon to the user.
- Response: Returns a success message if the coupon is sent or an error if not eligible.
Updates a user’s rating based on the average of all received reviews.
PUT /review/update-user-ratings
-
Extract User ID: Obtains the
user_idfrom the request body. - Calculate New Rating: Computes the average rating from all reviews for the specified user.
-
Update User Record: Updates the user’s rating in the
userstable. - Response: Returns a success message upon successful rating update.
POST /review/user Content-Type: application/json{ "reviewer_id":1 , "reviewer_user_id":2 , "rating":4.5 , "comment":"this person is reliable " }