$ pip3 install -r requirements.txtThen execute run.sh file:
$ ./run.sh
...Definition
GET /api/users/all (Login required)
Response
200 OKon success401 UNAUTHORIZEDon unauthorized access
[
{
"aadhar_card": "123214983204",
"address": "Shivanand Bungalows B/H Annapurna Restaurant Jashodanagar",
"avatar": "https://www.gravatar.com/avatar/4edab099fecc10e6f090d5567ab7c2aa?d=identicon&s=128",
"email": "[email protected]",
"firstname": "Ninad",
"id": 1,
"lastname": "Sachania",
"middlename": "Jaimin",
"phone_number": "9099869696",
"rfid": null
}
]It will return an empty array ([]) if there are no users.
Definition
POST /api/users/token
Arguments
This API call expects "Basic" authentication scheme. In that:
- The username and the password are combined with a colon (
aladdin:opensesame). - The resulting string is base64 encoded (
YWxhZGRpbjpvcGVuc2VzYW1l).
Then Authorization header is included with the <type> as "Basic" and <credentials> as the base64 encoded string:
Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l
Response
200 OKon success
{
"token": "4Id5JpPZ3NtYUgqlcNy5m12mjrbytZxt"
}If you make a call and a token is already present then that token is returned instead of a new token.
401 UNAUTHORIZEDwhen the username or password fields are missing or empty
{
"error": "Unauthorized"
}Definition
DELETE /api/users/token
Response
200 OKon success
{
"message": "Token delete successfully."
}401 UNAUTHORIZEDwhen the token is wrong on not present
{
"error": "Unauthorized"
}Definition
GET /api/users (Authorization required)
Response
200 OKon success
{
"aadhar_card": "123214983204",
"address": "Shivanand Bungalows B/H Annapurna Restaurant Jashodanagar",
"avatar": "https://www.gravatar.com/avatar/4edab099fecc10e6f090d5567ab7c2aa?d=identicon&s=128",
"email": "[email protected]",
"firstname": "Ninad",
"id": 1,
"lastname": "Sachania",
"middlename": "Jaimin",
"phone_number": "9099869696",
"rfid": null
}401 UNAUTHORIZEDwhen the token is wrong on not present
{
"error": "Unauthorized"
}Definition
POST /api/users (Authorization required)
Arguments
firstname: stringmiddlename: stringlastname: stringemail: stringaadhar_card: stringThe aadhar_card of the user (it should be 12 in length).phone_number: stringIt should be 10 in length.address: stringThe address of the userpassword: string
Response
201 CREATEDon success
{
"aadhar_card": "123456789012",
"address": "India",
"avatar": "https://www.gravatar.com/avatar/c89cf6721f229f50dfddb66873f6779e?d=identicon&s=128",
"email": "[email protected]",
"firstname": "Sagar",
"id": 3,
"lastname": "Gohil",
"middlename": "B",
"phone_number": "9099869695",
"rfid": null
}409 CONFLICTif theemail,phone_numberoraadhar_cardalready exists.
{
"error": "Conflict",
"message": "Sorry! This email is already in use"
}{
"error": "Conflict",
"message": "Sorry! This phone number is already in use."
}{
"error": "Conflict",
"message": "Sorry! This aadhar number is already in use."
}Definition
PUT /api/users (Authorization required)
Arguments
firstname: stringmiddlename: stringlastname: stringaddress: stringThe address of the user
Response
200 OKon success
The response will contain the user's details.
{
"aadhar_card": "123214983204",
"address": "Shivanand Bungalows B/H Annapurna Restaurant Jashodanagar.",
"avatar": "https://www.gravatar.com/avatar/4edab099fecc10e6f090d5567ab7c2aa?d=identicon&s=128",
"email": "[email protected]",
"firstname": "Ninad",
"id": 1,
"lastname": "Sachania",
"middlename": "Jaimin",
"phone_number": "9099869696",
"rfid": null
}400 BAD REQUESTif you the request tries to changeemail,aadhar_cardor thephone_numberof the user.
{
"error": "Bad Request",
"message": "Can't change email, aadhar_card and phone_number."
}400 BAD REQUESTif the request contains an unknown field
{
"error": "Bad Request",
"message": "Unknown key: firstnae"
}Definition
GET /api/users/static_information (Authorization required)
Response
200 OKon success
{
"allergies": "From stupid people.",
"bloodgroup": "A+",
"current_medication": "Vitamin B12",
"dob": "Tue, 07 Jul 1998 00:00:00 GMT",
"emergency_contact": "9099869696",
"gender": "Male",
"height": 180,
"id": 1,
"weight": 71.0
}204 NO CONTENTif there is no static information
Definition
PUT /api/users/static_information (Authorization required)
Arguments
dob: dateDate of Birthgender: stringemergency_contact: stringLength should be 10height: stringweight: stringbloodgroup: stringallergies: stringcurrent_medication: string
Definition
GET /api/users/dynamic_information (Authorization required)
Response
200 OKon success
[
{
"date_created": "Mon, 16 Mar 2020 12:26:14 GMT",
"diagnosis": "Flu",
"doctor_id": 1,
"id": 1,
"next_case_id": 0,
"notes": "",
"prescribed_medication": "Rest",
"previous_case_id": 0,
"symptoms": "Cold, dry cough, runny nose."
},
{
"date_created": "Mon, 16 Mar 2020 12:34:33 GMT",
"diagnosis": "Food poisoning",
"doctor_id": 1,
"id": 2,
"next_case_id": 0,
"notes": "Plenty of rest and high intake of fluids.",
"prescribed_medication": "Rest and Paracetamol",
"previous_case_id": 0,
"symptoms": "Stomachache"
}
]204 NO CONTENTif there are no dynamic records present
Definition
POST /api/users/changepw (Authorization required)
Arguments
current_password: stringnew_password: string
Response
200 OKon success
{
"message": "Password successfully changed."
}401 UNAUTHORIZEDwhen the token is wrong on not present
{
"error": "Unauthorized"
}400 BAD REQUESTwhen the current password is incorrect.
{
"error": "Bad Request",
"message": "Current password incorrect. Please try again."
}400 BAD REQUESTifcurrent_passwordand/ornew_passwordfields are missing in the request
{
"error": "Bad Request",
"message": "'current_password' and 'new_password' fields are required."
}Definition
POST /api/users/reset_password_request
Arguments
email: stringThe email id of the user
Response
200 OKon success
{
"message": "Check your email for instructions to reset your password."
}400 BAD REQUESTwhen a email of a non-existent account is passed as arguments
{
"error": "Bad Request",
"message": "Sorry! Email '[email protected]' not found."
}Definition
POST /api/users/qrcode (Authorization required)
Arguments
No arguments required.
Response
200 OKon success
{
"path": "/static/qrcodes/5.png"
}400 BAD REQUESTif the user's has not filled out their static information
{
"error": "Bad Request",
"message": "To generate a QR code first fill out your static information."
}