ورود | ثبت نام
  • FA
  • EN

API Docs

POST /api/v1/ratings

Sets the authenticated user's rating for a specified element (gym or training service). If the user has not rated the element yet, a new rating is created. If they have already rated it, the existing rating is updated with the new score.


Permissions

PermissionDescription
view (ratable)Must have view permission on the ratable
ratings.createRate an element

Request Body Parameters

NameTypeRequiredDescriptionExample
ratable_typestringYesType of the element (gym or training_service)"gym"
ratable_idintYesID of the element to rate10
scoreintYesScore between 1 and 55

Request Example

{
  "ratable_type": "gym",
  "ratable_id": 10,
  "score": 5
}

Response

201 Created

Returned when a new rating was created. Returns the created rating resource.

Example

{
  "rating": {
    "id": 123,
    "user_id": 42,
    "ratable_type": "App\\Models\\Gym",
    "ratable_id": 10,
    "score": 5
  }
}

For a full schema, see Rating Resource.


200 OK

Returned when the user already had a rating for this element and it was updated. Returns the updated rating resource.

Example

{
  "rating": {
    "id": 123,
    "user_id": 42,
    "ratable_type": "App\\Models\\Gym",
    "ratable_id": 10,
    "score": 4
  }
}

For a full schema, see Rating Resource.


Error Responses

StatusDescriptionReference
422Validation errorValidation error
401UnauthorizedAuthentication error
403Forbidden (no permission)Permission error
footer wave
logo

دمبل، دنیای هوشمند ورزش و تغذیه

LinkedinInstagramXYoutubeTelegramGitHub