owned this note
owned this note
Published
Linked with GitHub
## Admin(web)
# First factor Login
Login in with default password or password that you have updated with
## Request format
```
POST /api/admin/login
{
"user_name":"{username}",
"password":"{password}"
}
```
## Response format
`phone_number` registered phone number.
### Username and password found
```
HTTP 200 OK
{
"data":{
"phone_number":"82738213",
"admin_id": "3"
}
}
```
### Username or password not found
```
HTTP 404 Not Found
Content-Type: application/json
{
"error":{
"message": "Account Not Found"
}
}
```
# Request JWT
This api should return a jwt after validating the input verificationid with firebase server.
## Request
```
POST /api/admin/jwt
Content-Type: application/json
{
"verification_id":"{verification_id}",
"admin_id": "3"
}
```
## Response
### Success
```
HTTP 200 OK
Content-Type: application/json
{
"data":{
"token":"token",
"default_password":false,
"user":{
"admin_id": 6,
"full_name": {fullName},
"user_name": {userName},
"phone_number": {phoneNumber},
}
}
}
```
### User still using default password
```
HTTP 200 OK
Content-Type: application/json
{
"data":{
"token":"nil",
"default_password":true,
"user":{
"admin_id": 6,
"full_name": {fullName},
"user_name": {userName},
"phone_number": {phoneNumber},
}
}
}
```
### Cannot be verified on firebase
```
HTTP 404 Not Found
Content-Type: application/json
{
"error":{
"message":"User not authenticated"
}
}
```
### User not did not perform first factor login
```
HTTP 401 Unauthorized
Content-Type: application/json
{
"error":{
"message":"Requires login first"
}
}
```
# Update Password
using bearer token obtained from login update password.
This is only for password that are still using the default one
## Request
```
POST /admin/password
{
user_name: {userName},
password: {password}
}
```
## Response success
```
HTTP 200 OK
Content-Type: application/json
{
"data":{
"token":"token"
}
}
```
## Response fail password in wrong format
```
HTTP 422 Unprocessable Entity
{
"password": [
"Password does not meet the criteria of minimum length of 8 and minimum 1 lower cased, 1 upper case and must contain at least a number."
]
}
```
## Response fail
```
HTTP 404 Not Found
{
"error": {
"message": "Update password not required"
}
}
```
# Import users
```
POST
http://api/admin/importUser
Authorisation Bearer Token
Body : csv file
Response-success:
{"status":"Success","message":"Users have been imported successfully."}
Response-error:
400 Bad Request
{"error":"An error while decoding token."}
401 Unauthorised
{"error": "Token not provided"}
```
# Admin Logout
```
POST
http://api/admin/{id}/logout
Authorisation Bearer Token
Response-success:
200 ok
{"message":"Users has been log out."}
Response-error:
400 Bad Request
{"error":"Provided token is expired. User has been Log out"}
```
# Reset User Password
reset the password of the mobile users
```
POST
Request:
http://api/admin/resetUserPassword
{
"user_id": "1"
}
Response-sucess:
200 OK
{"message":"User's password resetted"}
Response-error:
400 Bad Request
{"error":"Access denied is not activated for this user"}
```
# Confirm User Booking
#### All other bookings that coincide will also be disapproved
```
POST
http://api/admin/booking/{booking_id}
Request:
Authorisation Bearer Token
Response-success:
200 ok
{"message":"Booking approves, all other bookings that coincide have been disapproved."}
```
# Create Maintenance
```
POST
http://api/admin/maintenance
Authorisation Bearer Token
Request:
{
"startTime": "2019-08-10 13:00:08",
"endTime": "2019-08-10 14:00:08",
"facilityID": "6"
}
Response:
201 created
Content-Type: application/json
{
"data": {
"maintenance": {
"maintenance_id": 0,
"start_datetime": "2019-08-19 16:20:00",
"end_datetime": "2019-08-19 15:20:00",
"facility": {
"facility_id": 5,
"facility_name": "Auditorium"
}
}
}
}
```
# Retrieves all unavailable slot for a facility for a date sorted by the earliest to latest unavailable slot
```
POST
GET /api/admin/facility/{facility_id}/unavailableslots
Authorization: Bearer {jwt_token}
Request:
{
"date": "2019-08-20"
}
Response-success:
HTTP 200 OK
Content-Type: application/json
{
"data":{
"bookings":[
{
"type":"BOOKING",
"booking_id":"{bookingID}",
"start_datetime": "{bookingStartTime}",
"end_datetime":"{bookingEndTime}",
"booking_name":"{bookingName}",
"booking_contact": "{bookingContact}",
"booker_name":"{bookerName}",
"booking_status":"{bookingStatus}",
"facility":{
"facility_id":"{facilityID}",
"facility_name":"{facilityName}"
}
},
{
"type":"BOOKING",
"booking_id":"{bookingID}",
"start_datetime": "{bookingStartTime}",
"end_datetime":"{bookingEndTime}",
"booking_name":"{bookingName}",
"booking_contact": "{bookingContact}",
"booker_name":"{bookerName}",
"booking_status":"{bookingStatus}",
"facility":{
"facility_id":"{facilityID}",
"facility_name":"{facilityName}"
}
},
{
"type":"MAINTENANCE",
"maintenance_id":"{maintainanceid}",
"start_datetime": "{startDatetime}",
"end_datetime":"{bookingEndTime}",
"facility":{
"facility_id":"{facilityID}",
"facility_name":"{facilityName}"
}
},
{
"type":"MAINTENANCE",
"maintenance_id":"{maintainanceid}",
"start_datetime": "{startDatetime}",
"end_datetime":"{bookingEndTime}",
"facility":{
"facility_id":"{facilityID}",
"facility_name":"{facilityName}"
}
}
],
}
}
```
### No slots found
```
HTTP 404 Not Found
Content-Type: application/json
{
"message":"No unavailable event slots"
}
```
# Get Pending Booking for a facility
```
POST
Request:
https://api/admin/PendingBookings
Authorisation Bearer Token
{
"facilityID": "1"
}
Response-success:
{
"PendingBookings": [
{
"booking_id": 3,
"start_datetime": "2019-08-06 17:23:08",
"end_datetime": "2019-08-06 18:23:08",
"booking_name": "Physical Training",
"booking_contact": 98456556,
"booker_name": "Barbara Benjamin",
"NoOfCancellation": 0
}
]
}
```
### No pending booking found
```
HTTP 404 Not Found
Content-Type: application/json
{
"message":"No Pending bookings found"
}
```