-
Notifications
You must be signed in to change notification settings - Fork 0
API for Admins
michaelkringelhede edited this page Oct 22, 2022
·
4 revisions
Admins can be created using the API:
POST /api/admins
{
"name": "Zaphod Beeblebrox",
"email": "[email protected]",
"password": "Pan-Galactic Gargle Blaster",
"phone": "+44 1978 1980"
}
Response will be similar to:
{
"id": "bb115c88-b404-4ebe-9297-e8fb9524285f",
"created": true,
"token": "eyJhbGciOiJ...ETCcfoKZ6xA4bZuw",
"error": null,
"errorCode": null
}
Once the admin is created you can use the token returned from "Create admin" or you can fetch a new token like this:
POST /admins/login
{
"email": "[email protected]",
"password": "Pan-Galactic Gargle Blaster"
}
Response will be similar to:
{
"successful": true,
"token": "eyJhbGciOiJ...ZqS0Gj48ifOUew04",
"errorCode": null,
"error": null
}
Admins can create new locations using the API (needs to be logged in as Admin first):
The login token should be sent as value to the authorization
header.
POST /api/locations
Authorization: eyJhbGciOiJ...zdOUex7uEFQjf-Kw
{
"year": 2022,
"jid": "5gb75n",
"name": "Magrathea 2022"
}
Response will be similar to:
{
"id": "79b42f6d-bfa2-49e9-ab07-542359864877",
"created": true,
"errorCode": null,
"error": null
}
Admins can fetch their own locations using the API (needs to be logged in as Admin first):
The login token should be sent as value to the authorization
header.
GET /api/locations
Authorization: eyJhbGciOiJ...zdOUex7uEFQjf-Kw
Response will be similar to:
{
"locations": [
{
"id": "79b42f6d-bfa2-49e9-ab07-542359864877",
"year": 2022,
"jid": "5gb13d",
"country": "gb",
"name": "Guildford",
"owner": "d4db6e5d-b5a3-4e8c-b1a4-8fbbadda9b0d",
"created": "2022-01-24 15:13:04"
},
{
"id": "dd938fb3-dbdc-41f0-a93a-52ce7a65cd42",
"year": 2022,
"jid": "5gb25e",
"country": "gb",
"name": "London",
"owner": "d4db6e5d-b5a3-4e8c-b1a4-8fbbadda9b0d",
"created": "2022-01-31 16:25:35"
}
],
"errorCode": null,
"error": null
}