Perfect Gym api

Ratings

This API allow users to rate classes and instructors.

Overview

In PerfectGym user can rate two entities:

To be able to submit rating user has to attend rated class. Using class id user rates class type and instructor conducting class.

If class has no assigned instructor, user can rate only class type. Rating is an integer value of 1 to 5.

Each class attandence allows user to submit rating for both: class type and instructor, even if element (class type or instructor) has been already rated. Subsequent ratings adds up to element rating.

Ranking

Ratings data can be used to create class types or instructors rankings. Problem arises though: should element with rating 5 based on one submision be heigher then element with rating 4.7 based on 20 submitions?

To solve this problem PerfectGym API calculates rankingFactor using Bayesian estimate. Sorting elements by rankingFactor ascending sets elements in the proper ranking order.

Rating properties

Rating is described by the following properties

Name Type Description
rating decimal Avarage rating, if element was never rated, rating is null.
submitionsCount int Ratings count or 0 if element was never rated.
rankingFactor decimal Ranking factor allows to sort elements in proper ranking order.

Execute class rating alt text alt text

POST Classes/RateClass

Rates class on behalf of user.

Employee mode parameters

Name Type Description
classId long Required. Class identifier. Request rates fitness class identified by classId.
userId long Required. User identifier. Request rates fitness class on behalf of user identified by userId.
rating int Required. Rating. Value of 1 to 5. Rating user assigns to selected classes.

User mode parameters

Name Type Description
classId long Required. Class identifier. Request rates fitness class identified by classId on behalf of authenticated identifier.
rating int Required. Rating. Value of 1 to 5. Rating user assigns to selected classes.

Response

Class details if class rating is successful, or collection of errors with class rating error codes otherwise.

Employee mode example request

In this example we assign rating 5 to classes with id = 1677 by user with id = 40.

curl -i 
     -X POST 
     -H "Authorization: Bearer  $ACCESS_TOKEN"  
     http://yoursubdomain.perfectgym.com/Api/Classes/RateClass
        ?classId=1677
        &userId=40
        &classRating=5

Example response

Status: 200 OK
{
  "elements": [
    {
      "booked": true,
      "attended": true,
      "standby": false,
      "userClassRating": 5,
      "userInstructorRating": "",
      "classType": {
        "id": 1,
        "timestamp": 263952,
        "name": "Box",
        "photoUrl": "",
        "iconUrl": "",
        "description": "Box perfectly combines cardio and strength training under the guise of groove!",
        "rating": {
          "rating": 4.1,
          "votesCount": 1234,
          "rankingSort": 2.3
        },
        "category": {
          "id": 2,
          "category": "MIX",
          "imageUrl": "https://yourdomain.perfectgym.pl/Api/Files/Photo?xxxxxxxxx",
          "isDeleted": false,
          "isProductRequiredForBooking": false,
          "name": "Mix",
          "timestamp": 1223165441
        }
      },
      "instructor": {
        "id": 52,
        "timestamp": 376826,
        "firstName": "Agatha",
        "lastName": "Strickland",
        "displayName": "Agatha Strickland",
        "email": "a.strickland@cyberbotics.com",
        "photoUrl": "",
        "sex": "Female",
        "rating": {
          "rating": 4.7,
          "votesCount": 1234,
          "rankingSort": 3.3
        },
        "isActive": true,
        "isDeleted": false
      },
      "club": {
        "id": 2,
        "timestamp": 271990,
        "name": "Fibo Cyberbotics",
        "shortName": "Cyberbotics",
        "symbol": "FCBR",
        "type": "Normal",
        "openDate": "2015-01-01",
        "latitude": 52.51038,
        "longitude": 13.39763,
        "email": "club@cyberbotics.com",
        "phoneNumber": "+49 12 123 456 789",
        "timezone": "Central European Standard Time",
        "address": {
          "line1": "Leipziger Str. 46/47",
          "line2": "",
          "city": "Berlin",
          "postalCode": "10-117",
          "country": "Germany"
        },
        "isDeleted": false,
        "isHidden": false
      },
      "id": 1677,
      "timestamp": 254718,
      "isDeleted": false,
      "startDate": "2015-12-03T06:15:00",
      "endDate": "2015-12-03T07:15:00",
      "attendeesCount": 7,
      "attendeesLimit": 20,
      "clubZone": "Fitness"
    }
  ]
}

Example error response

Subsequent rating for class with id = 1677 and for user with id = 40 generates following error:

Status: 400 Bad Request
{
  "errors": [
    {
      "code": "ClassAlreadyRated",
      "property": "",
      "message": ""
    }
  ]
}

Execute instructor rating alt text alt text

POST Classes/RateInstructor

Rates instructor conducting class on behalf of user.

Employee mode parameters

Name Type Description
classId long Required. Class identifier. Request rates instructor conducting class identified by classId.
userId long Required. User identifier. Request rates instructor on behalf of user identified by userId.
rating int Required. Rating. Value of 1 to 5. Rating user assigns to selected instructor.

User mode parameters

Name Type Description
classId long Required. Class identifier. Request rates instructor conducting class identified by classId on behalf of authenticated identifier.
rating int Required. Rating. Value of 1 to 5. Rating user assigns to selected instructor.

Response

Class details if instructor rating is successful, or collection of errors with instructor rating error codes otherwise.

Employee mode example request

In this example we assign rating 4 to instructor conducting classes with id = 1677 by user with id = 40.

curl -i 
     -X GET 
     -H "Authorization: Bearer  $ACCESS_TOKEN"  
     http://yoursubdomain.perfectgym.com/Api/Classes/RateInstructor
        ?classId=1677
        &userId=40
        &isntructorRating=4

Example response

Status: 200 OK
{
  "elements": [
    {
      "booked": true,
      "attended": true,
      "standby": false,
      "userClassRating": 5,
      "userInstructorRating": 4,
      "classType": {
        "id": 1,
        "timestamp": 263952,
        "name": "Box",
        "photoUrl": "",
        "iconUrl": "",
        "description": "Box perfectly combines cardio and strength training under the guise of groove!",
        "rating": {
          "rating": 4.1,
          "votesCount": 1234,
          "rankingSort": 2.3
        },
        "category": {
          "id": 2,
          "category": "MIX",
          "imageUrl": "https://yourdomain.perfectgym.pl/Api/Files/Photo?xxxxxxxxx",
          "isDeleted": false,
          "isProductRequiredForBooking": false,
          "name": "Mix",
          "timestamp": 1223165441
        }
      },
      "instructor": {
        "id": 52,
        "timestamp": 376826,
        "firstName": "Agatha",
        "lastName": "Strickland",
        "displayName": "Agatha Strickland",
        "email": "a.strickland@cyberbotics.com",
        "photoUrl": "",
        "sex": "Female",
        "rating": {
          "rating": 4.7,
          "votesCount": 1234,
          "rankingSort": 3.3
        },
        "isActive": true,
        "isDeleted": false
      },
      "club": {
        "id": 2,
        "timestamp": 271990,
        "name": "Fibo Cyberbotics",
        "shortName": "Cyberbotics",
        "symbol": "FCBR",
        "type": "Normal",
        "openDate": "2015-01-01",
        "latitude": 52.51038,
        "longitude": 13.39763,
        "email": "club@cyberbotics.com",
        "phoneNumber": "+49 12 123 456 789",
        "timezone": "Central European Standard Time",
        "address": {
          "line1": "Leipziger Str. 46/47",
          "line2": "",
          "city": "Berlin",
          "postalCode": "10-117",
          "country": "Germany"
        },
        "isDeleted": false,
        "isHidden": false
      },
      "id": 1677,
      "timestamp": 254718,
      "isDeleted": false,
      "startDate": "2015-12-03T06:15:00",
      "endDate": "2015-12-03T07:15:00",
      "attendeesCount": 7,
      "attendeesLimit": 20,
      "clubZone": "Fitness"
    }
  ]
}

Example error response

Subsequent instructor rating for class with id = 1677 and for user with id = 40 generates following error:

Status: 400 Bad Request
{
  "errors": [
    {
      "code": "InstructorAlreadyRated",
      "property": "",
      "message": ""
    }
  ]
}
Perfect Gym api