Responses
This describes PerfectGym API responses basics.
Overview
Responses contains resources list or individual resources for GET requests. For POST requests, individual resource that request operates on is returned.
Each API response is wrapped in a standard structure called the envelope, which holds the results of the API call, plus the metadata related to the request. In case of logical errors, error detailes are enclosed in error envelope.
Response Envelope
Response envelope encloses resources list or individual resources returned by PerfectGym API.
Response envelope properties
Attribute Name | Description |
---|---|
elements |
A collection of objects the payload carries. In case of individual resource, elements contain only one object. |
Example
Status: 200 OK
{
"elements": [
{
"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
}
},
{
"id": 2,
"timestamp": 382653,
"name": "POWER JOGA",
"photoUrl": "",
"iconUrl": "",
"description": "Power Yoga is definitely an intense workout that will make you sweat.",
"rating": {
"rating": 4.1,
"votesCount": 4321,
"rankingSort": 4.3
},
"category": {
"id": 2,
"category": "MIX",
"imageUrl": "https://yourdomain.perfectgym.pl/Api/Files/Photo?xxxxxxxxx",
"isDeleted": false,
"isProductRequiredForBooking": false,
"name": "Mix",
"timestamp": 1223165441
}
}
]
}
Error Response Envelope
Error response envelope encloses information about logical errors that occured during API calls.
Error responses come with HTTP 400
status code.
Error envelope properties
Attribute Name | Description |
---|---|
errors |
An array of Error objects, each representing logical error that occured during API call. |
Example
Status: 400 Bad Request
{
"errors": [
{
"code": "ClassAlreadyBooked",
"property": "",
"message": ""
}
]
}
Summary Representations
When you fetch a list of resources, the response includes a subset of the attributes for that resource. This is the "summary" representation of the resource. (Some attributes are computationally expensive for the API to provide. For performance reasons, the summary representation excludes those attributes. To obtain those attributes, fetch the "detailed" representation.)
Example
When you get a list of classes, you get the summary representation of each class type. Here, we fetch the list of classes in a given club:
GET Classes/Classes/{clubId}
Detailed Representations
When you fetch an individual resource, the response typically includes all attributes for that resource. This is the "detailed" representation of the resource.
Example
When you get an individual class, you get the detailed representation of the class:
GET Classes/Class/{classId}
The documentation provides an example response for each API method. The example response illustrates all attributes that are returned by that method.