The Kompis project aims to make it easy to for everyone to get home after a night out. We will provide a platform where users can ask for someone to drive them home, or drivers to advertise when they are available.
- Create user :
POST /users
→ open endpoint - Authorize :
POST /users/authorize
→ open endpoint - Get user :
GET /users/{id:number}
- Get current user :
GET /users/current
- Delete current user :
DELETE /users/current
- Send firebase token :
PUT /users/current/firebase
- Get listings :
GET /listings
- Create listing :
POST /listings
- Get listing :
GET /listings/{id:number}
- Delete listing :
DELETE /listings/{id:number}
- Activate listing :
GET /listings/{id:number}/activate
- Deactivate listing :
GET /listings/{id:number}/deactivate
- Assign current user to listing :
POST /listings/{id:number}/assign
- Unassign user from listing :
GET /listings/{id:number}/unassign
POST /users
Creates a new user that can be logged into.
Request
Headers:
Content-Type: application/json
Body:
{
"email": "[email protected]",
"password": "password",
"displayName": "Roger Doger"
}
Responses
200 OK
on success
Headers:
Content-Type: application/json
Body:
{
"id": 1,
"displayName": "Roger Doger"
}
409 CONFLICT
if a user with the given email exists
POST /users/authorize
Receive authorization for use with endpoints requiring authorization. If the client supports firebase cloud messaging, a token should be provided in the body.
Request
Headers:
Content-Type: application/json
Body:
{
"email": "[email protected]",
"password": "password",
"firebaseToken": "(optional)"
}
Responses
200 OK
on success
Headers:
Content-Type: application/json
Authorization: Bearer xxx.yyy.zzz
Body:
{
"id": 1,
"displayName": "Roger Doger"
}
404 CONFLICT
if a user with the given email does not exist403 FORBIDDEN
if a user with the given email already exist
GET /users/{id:number}
Get the user with the given ID.
Request
Headers:
Authorization: Bearer xxx.yyy.zzz
Responses
200 OK
on success
Headers:
Content-Type: application/json
Authorization: Bearer xxx.yyy.zzz
Body:
{
"id": 1,
"displayName": "Roger Doger"
}
403 FORBIDDEN
ifAuthorization
header is invalid404 NOT FOUND
if user with the given id was not found
GET /users/current
Get the current authorized user.
Request
Headers:
Authorization: Bearer xxx.yyy.zzz
Responses
200 OK
on success
Headers:
Authorization: Bearer xxx.yyy.zzz
Body:
{
"id": 1,
"displayName": "Roger Doger"
}
403 FORBIDDEN
ifAuthorization
header is invalid
DELETE /users/current
Delete the current authorized user. All listings where this user is the assignee will be unassigned and all listings where this user is the owner will be deleted.
The client should get rid of the Authorization
token manually.
Request
Headers:
Authorization: Bearer xxx.yyy.zzz
Responses
200 OK
on success
Headers:
Authorization: Bearer xxx.yyy.zzz
403 FORBIDDEN
ifAuthorization
header is invalid
PUT /users/current/firebase
Update the firebase token for the current authorized user.
Request
Headers:
Authorization: Bearer xxx.yyy.zzz
Parameters:
- token - the firebase token assigned to the client of the current authorized user
Responses
200 OK
on success
Headers:
Authorization: Bearer xxx.yyy.zzz
403 FORBIDDEN
ifAuthorization
header is invalid
Body:
{
"id": 1,
"displayName": "Roger Doger"
}
403 FORBIDDEN
ifAuthorization
header is invalid
GET /listings
Gets a list of all listings.
Request
Headers:
Authorization: Bearer xxx.yyy.zzz
Responses
200 OK
on success
Headers:
Content-Type: application/json
Authorization: Bearer xxx.yyy.zzz
Body:
[
{
"id": 2,
"title": "Need pickup at Oslo",
"driver": false,
"active": true,
"owner": {
"id": 1,
"displayName": "Roger Doger"
},
"location": {
"id": 10,
"latitude": "98.76",
"longitude": "54.32",
"accuracy": "99.1"
},
"assignee": {
"id": 12,
"user": {
"id": 9,
"displayName": "Harry"
},
"location": {
"id": 10,
"latitude": "12.34",
"longitude": "23.45",
"accuracy": "99.1"
}
}
}, ...
]
403 FORBIDDEN
ifAuthorization
header is invalid
POST /listings
Creates a new listing owned by the current logged in user.
Request
Headers:
Content-Type: application/json
Authorization: Bearer xxx.yyy.zzz
Body:
{
"title": "Need pickup at Oslo",
"driver": false,
"location": {
"latitude": "98.76",
"longitude": "54.32",
"accuracy": "99.1"
}
}
Responses
200 OK
on success
Headers:
Content-Type: application/json
Authorization: Bearer xxx.yyy.zzz
Body:
{
"id": 2,
"title": "Need pickup at Oslo",
"driver": false,
"active": true,
"owner": {
"id": 1,
"displayName": "Roger Doger"
},
"location": {
"id": 10,
"latitude": "98.76",
"longitude": "54.32",
"accuracy": "99.1"
},
"assignee": null
}
403 FORBIDDEN
ifAuthorization
header is invalid
GET /listings/{id:number}
Gets the listing with the given ID.
Request
Headers:
Authorization: Bearer xxx.yyy.zzz
Responses
200 OK
on success
Headers:
Content-Type: application/json
Authorization: Bearer xxx.yyy.zzz
Body:
{
"id": 2,
"title": "Need pickup at Oslo",
"driver": false,
"active": true,
"owner": {
"id": 1,
"displayName": "Roger Doger"
},
"location": {
"id": 10,
"latitude": "98.76",
"longitude": "54.32",
"accuracy": "99.1"
},
"assignee": null
}
403 FORBIDDEN
ifAuthorization
header is invalid404 NOT FOUND
if a listing with the given ID was not found
DELETE /listings/{id:number}
Delete the listing with the given ID if it is owned by the current authorized user.
Request
Headers:
Authorization: Bearer xxx.yyy.zzz
Responses
200 OK
on success
Headers:
Authorization: Bearer xxx.yyy.zzz
403 FORBIDDEN
if the listing is not owned by the current authorized user403 FORBIDDEN
ifAuthorization
header is invalid404 NOT FOUND
if a listing with the given ID was not found
GET /listings/{id:number}/activate
Activate the listing with the given ID if it is owned by the current authorized user.
Request
Headers:
Authorization: Bearer xxx.yyy.zzz
Responses
200 OK
on success
Headers:
Authorization: Bearer xxx.yyy.zzz
403 FORBIDDEN
if the listing is not owned by the current authorized user403 FORBIDDEN
ifAuthorization
header is invalid404 NOT FOUND
if a listing with the given ID was not found
GET /listings/{id:number}/deactivate
Deactivate the listing with the given ID if it is owned by the current authorized user.
Request
Headers:
Authorization: Bearer xxx.yyy.zzz
Responses
200 OK
on success
Headers:
Authorization: Bearer xxx.yyy.zzz
403 FORBIDDEN
if the listing is not owned by the current authorized user403 FORBIDDEN
ifAuthorization
header is invalid404 NOT FOUND
if a listing with the given ID was not found
POST /listings/{id:number}/assign
Assign the current logged in user to the listing with the given ID and store the assignees location in the listing.
Request
Headers:
Authorization: Bearer xxx.yyy.zzz
Body:
{
"latitude": "12.34",
"longitude": "23.45",
"accuracy": "99.1"
}
Responses
200 OK
on success
Headers:
Authorization: Bearer xxx.yyy.zzz
403 FORBIDDEN
ifAuthorization
header is invalid404 NOT FOUND
if a listing with the given ID was not found409 CONFLICT
if the listing already has an assignee
GET /listings/{id:number}/unassign
If the current authorized user is the owner of the listing with the given ID, the assignee will be removed from the listing. If the current authorized user is assigned to the listing, they will remove themselves from the listing.
Request
Headers:
Authorization: Bearer xxx.yyy.zzz
Responses
200 OK
on success
Headers:
Authorization: Bearer xxx.yyy.zzz
403 FORBIDDEN
if you either don't own the listing, or are not assigned to the listing403 FORBIDDEN
ifAuthorization
header is invalid404 NOT FOUND
if a listing with the given ID was not found