Project

General

Profile

Actions

CompressPdf #482

open

Develop POST api for rating (POST /v1/ratings API)

Added by Zahid Hassan over 1 year ago. Updated over 1 year ago.

Status:
Complete
Priority:
High
Assignee:
Category:
feature
Target version:
Start date:
10/15/2024
Due date:
10/15/2024 (about 18 months late)
% Done:

100%

Estimated time:
4:00 h

Description

Description:

The current implementation of the POST /v1/ratings API for user rating submissions follows RESTful best practices and proper conventions.

Status Codes:

The API currently returns 200 OK for updates, 201 Created for new entries, and 404 Not Found if no record is found. For example:

  • 200 OK should indicate a successful update of an existing rating.
  • 201 Created should indicate a new rating submission.
  • 404 Not Found when the record (e.g., tool_id or session_id) is not found.

Response Structure:

The response body must maintain a consistent structure across success and error responses. Success responses should include a message, session_id, and a status flag. Example:

{
  "message": "rating updated",
  "session_id": "cm29xtg7b0000bjmegguel3mg",
  "status": true
}

Error responses should return an appropriate error message and status:

{
  "message": "record not found.",
  "status": false
}

Request Body Validation:

Ensure that proper validation is in place for the incoming request body:

  • rating should be an integer and within a valid range (e.g., 1-5).
  • tool_id must be a valid integer.
  • session_id should be a valid string, potentially following a format like CUID.

Error Handling:

Ensure consistent error handling mechanisms are implemented for missing or invalid data.

  • For non-existing records, return 404 Not Found with a clear error message.

Swagger Documentation:

  • The Swagger documentation should clearly reflect the API’s behavior, including all request parameters and response schemas.
  • Make sure all status codes (200, 201, 404) and their corresponding responses are accurately documented.
Actions

Also available in: Atom PDF