Repository navigation
API Contract
tguernier edited this page Apr 17, 2021
·
10 revisions
{
_id: ObjectID,
truncCode: String,
isFinished: Boolean,
preferences: Preference,
results: [Restaurant]
}
{
location: String,
distance: Integer,
price: Number,
timer: Number,
coordinates: Coordinates
}
{
name: String,
location: String,
numberOfVotes: Number,
coordinates: Coordinates
price: Number,
rating: Number,
images: String
}
{
lat: Number,
lng: Number
}
Create a new Session and return the sessionId and the truncated sessionId
- URL Params: None
- Example Data Params:
{
"preferences": {},
"results": []
}-
Headers:
- Content-Type: application/json
-
Success Response:
- Code: 201
- Example Content:
{
"sessionId": "605334010727e7af37aa2824",
"truncCode": "a2824"
}Get the session object with the provided truncated sessionId
-
URL Params:
- Required: id (truncated Id)
-
Example Data Params: None
-
Headers:
- Content-Type: application/json
-
Success Response:
- Code: 200
-
Error Response:
-
Code: 404
- Content:
{ "message": "Could not find session with that id" }- Code: 500
-
Code: 404
-
Example Content:
{
"_id": "60534086b68128b3509c0a73",
"truncCode": "c0a73",
"isFinished": true,
"preferences": {
"location": "Auckland",
"distance": 10,
"cuisines": [
"Thai",
"Japanese",
"Chinese"
],
"price": 20,
"timer": 600,
"coordinates": {
"lat": 34.6424325,
"lng": 10.2343462,
}
},
"results": []
}Updates fields on the specified session and returns the updated object
-
URL Params:
- Required: id (truncated Id)
- Example Data Params:
{
"isFinished": true,
"preferences": {
"location": "Auckland",
"distance": 10,
"cuisines": ["Thai", "Japanese", "Chinese"],
"price": 20,
"timer": 600,
"coordinates": {
"lat": 34.6424325,
"lng": 10.2343462
},
},
"results": [
{
"name": "Thai Restaurant",
"location": "1 Thai Street",
"numberOfVotes": 5,
"coords": {
"lat": 34.6424325,
"lng": 10.2343462,
},
"price": "$$",
"rating": 3.5,
"images": "",
},
{
"name": "Japanese Restaurant",
"location": "1 Japan Street",
"numberOfVotes": 3,
"coords": {
"lat": 34.6424325,
"lng": 10.2343462,
},
"price": "$$$",
"rating": 4.5,
"images": "",
},
{
"name": "Chinese Restaurant",
"location": "1 China Street",
"numberOfVotes": 5,
"coords": {
"lat": 34.9876543,
"lng": 10.2343462,
},
"price": "$",
"rating": 4.1,
"images": "",
}
],
}-
Headers:
- Content-Type: application/json
-
Success Response:
- Code: 200
-
Error Response:
-
Code: 404
- Content:
{ "message": "Could not find session with that id" }- Code: 400
- Code: 500
-
Code: 404
-
Example Content:
{
"_id": "60534086b68128b3509c0a73",
"truncCode": "c0a73",
"isFinished": true,
"preferences": {
"location": "Auckland",
"distance": 10,
"cuisines": [
"Thai",
"Japanese",
"Chinese"
],
"price": 20,
"timer": 600,
"coordinates": {
"lat": 34.6424325,
"lng": 10.2343462
}
},
"results": [
{
"name": "Thai Restaurant",
"location": "1 Thai Street",
"numberOfVotes": 5,
"coords": {
"lat": 34.6424325,
"lng": 10.2343462,
},
"price": "$$",
"rating": 3.5,
"images": "",
},
{
"name": "Japanese Restaurant",
"location": "1 Japan Street",
"numberOfVotes": 3,
"coords": {
"lat": 34.6424325,
"lng": 10.2343462,
},
"price": "$$$",
"rating": 4.5,
"images": "",
},
{
"name": "Chinese Restaurant",
"location": "1 China Street",
"numberOfVotes": 5,
"coords": {
"lat": 34.9876543,
"lng": 10.2343462,
},
"price": "$",
"rating": 4.1,
"images": "",
}
],
}