Skip to content

Example API documentation

yhkalayci edited this page Oct 23, 2017 · 1 revision

Endpoints

/hospital/patient/

GET

Returns all patients without any parameter.

Resource URL

http://34.208.111.47:8080/hospital/patient/

Example Request

GET http://127.0.0.1:8000/hospital/patient/

Example Response

{"patients": [{"name": "qwer", "lastname": "qwerty", "age": 34}, {"name": "rttyu", "lastname": "qwe", "age": 45}, {"name": "kkkkkk", "lastname": "llllll", "age": 34}]}

POST

Creates a patient with new id.

Endpoint

POST /hospital/patient/

Resource URL

http://34.208.111.47:8080/hospital/patient/

Response Format

On success, the HTTP status code in the response header is 200 OK and the response body contains a patient object in JSON format. On error, the header status code is an error code and the response body contains the following JSON object:

{"status":"FAIL", "message":"wrong data format"}

Example

request: $ curl -X POST 34.208.111.47:8080/hospital/patient/ -d '{"name": "Kerem", "lastname": "Kolsuz", "age": 25},'

response:

{
    "status":"OK", "message":""
}

/hospital/patient:id

GET

Get information about a single patient.

Request Parameters

PATH PARAMETER VALUE
id The id for the patient.

Resource URL

http://34.208.111.47:8080/hospital/patient/{id}

Example Request

request: $ curl -X GET 127.0.0.1:8000/hospital/patient/1/

Example Response

{"name": "qwer", "lastname": "qwerty", "age": 34}'

PUT

Modify an existing patient, in particular change its fields such as name, age or lastname.

Request Parameters

PATH PARAMETER VALUE
id The id for the patient.

Resource URL

http://34.208.111.47:8080/hospital/patient/{id}

Example Request

$ curl -X PUT 34.208.111.47:8080/hospital/patient/1/ -d '{"name": "Firat", "lastname":"Tekin", "Age":30 }'

Example Response

{"status": "OK", "message": ""}'

DELETE

Deletes existing patient via given id.

Endpoint

DELETE /hospital/patient/{id}

Request Parameters

PATH PARAMETER VALUE
id The id for the patient.

Resource URL

http://34.208.111.47:8080/hospital/patient/{id}

Response Format

On success, the HTTP status code in the response header is 200 OK and the response body contains a patient object in JSON format. On error, the header status code is an error code and the response body contains the following JSON object:

{"status":"FAIL", "message":"patient does not exist"}

Example

request: $ curl -X DELETE 34.208.111.47:8080/hospital/patient_single/1/ -d '{"name": "rttyu"}'

response:

{
    "status":"OK", "message":""
}

/hospital/doctor/

GET

Returns all doctors without any parameter.

Resource URL

http://34.208.111.47:8080/hospital/doctor/

Example Request

GET http://127.0.0.1:8000/hospital/doctor/

Example Response

` {"doctors": [{"name": "Deniz", "lastname": "Tekin", "age": 34}, {"name": "Sami", "lastname": "Ozan", "age": 45}, {"name": "Yasemin", "lastname": "Olsun", "age": 29}]}

POST

Creates a doctorwith new id.

Endpoint

POST /hospital/doctor/

Resource URL

http://34.208.111.47:8080/hospital/doctor/

Response Format

On success, the HTTP status code in the response header is 200 OK and the response body contains the following:

{
    "status":"OK", "message":""
}

On error, the header status code is an error code and the response body contains the following JSON object:

{
   "status": "FAIL",
   "message": "wrong data format"
}

Example

request: $ curl -X POST 34.208.111.47:8080/hospital/doctor/ -d '{"name": "Ahmet", "lastname": "Mehmet", "age": 46},'

response:

{
    "status":"OK", "message":""
}

/hospital/doctor/:id

GET

Get information for a single doctor.

Request Parameters

PATH PARAMETER VALUE
id The id for the doctor.

Resource URL

http://34.208.111.47:8080/hospital/doctor/{id}

Example Request

request: $ curl -X GET 34.208.111.47:8080/hospital/doctor/1/

Example Response

{"name": "Deniz", "lastname": "Yilmaz", "age": 38}'

PUT

Modify an existing doctor, in particular change its fields such as name, age.

Request Parameters

PATH PARAMETER VALUE
id The id for the department.

Resource URL

http://34.208.111.47:8080/hospital/doctor/{id}

Example Request

$ curl -X PUT 34.208.111.47:8080/hospital/doctor/1/ -d '{"name": "Firat", "lastname":"Tekin", "Age":30 }'

Example Response

{"status": "OK", "message": ""}'

DELETE

Deletes a doctor in given id.

Endpoint

DELETE /hospital/doctor/{id}

Request Parameters

PATH PARAMETER VALUE
id The id for the doctor.

Resource URL

http://34.208.111.47:8080/hospital/doctor/{id}

Response Format

On success, the HTTP status code in the response header is 200 OK and the response body contains a doctor object in JSON format. On error, the header status code is an error code and the response body contains the following JSON object:

{"status":"FAIL", "message":"doctor does not exist"}

Example

request: $ curl -X DELETE 34.208.111.47:8080/hospital/doctor_single/1/ -d '{"name": "Deniz Yılmaz"}'

response:

{
    "status":"OK", "message":""
}

/hospital/department/

GET

Returns departments without any parameter.

Resource URL

http://34.208.111.47:8080/hospital/department/

Example Request

GET http://127.0.0.1:8000/hospital/department/

Example Response

{"departments": [{"name": "Goz"}, {"name": "Kulak"}, {"name": "Kardiyoloji"}]}

/hospital/department/:id

Get a department

Get information for a single department.

Endpoint

GET /hospital/department/{id}

Request Parameters

PATH PARAMETER VALUE
id The id for the department.

Response Format

On success, the HTTP status code in the response header is 200 OK and the response body contains a department object in JSON format. On error, the header status code is an error code and the response body contains the following JSON object:

{"status":"FAIL", "message":"department does not exist"}

Example

request: $ curl -X GET 127.0.0.1:8000/hospital/department/1/

response:

{
    "name": "Kulak Burun Bogaz"
}

Modify a department

Modify an existing department, in particular change its name.

Endpoint

PUT /hospital/department/{id}

Request Parameters

PATH PARAMETER VALUE
id The id for the department.
QUERY PARAMETER VALUE
name The new name for the existing department

Response Format

On success, the HTTP status code in the response header is 200 OK and the response body contains a department object in JSON format. On error, the header status code is an error code and the response body contains the following JSON object:

{"status":"FAIL", "message":"department does not exist"}

Example

request: $ curl -X PUT 34.208.111.47:8080/hospital/department/1/ -d '{"name": "Kulak Burun Bogaz"}'

response:

{
    "status":"OK", "message":""
}

Delete a department

Deletes a department in given id.

Endpoint

DELETE /hospital/department/{id}

Request Parameters

PATH PARAMETER VALUE
id The id for the department.

Resource URL

http://34.208.111.47:8080/hospital/department/{id}

Response Format

On success, the HTTP status code in the response header is 200 OK and the response body contains a department object in JSON format. On error, the header status code is an error code and the response body contains the following JSON object:

{"status":"FAIL", "message":"department does not exist"}

Example

$ curl -X DELETE 34.208.111.47:8080/hospital/doctor/3/ -d '{"name": "Dahiliye"}'

response:

{
    "status":"OK", "message":""
}

Endpoints

/hospital/rendezvous/

GET

Returns all rendezvous without any parameter.

Resource URL

http://34.208.111.47:8080/hospital/rendezvous/

Example Request

GET http://127.0.0.1:8000/hospital/rendezvous/

Example Response

` {"rendezvous": [{"Patient name and lastname": "qwer qwerty", "time": "2017-04-23T22:07:39.117Z", "Doctor name and lastname": "Kazim Kazim"}, {"Patient name and lastname": "kkkkkk llllll", "time": "2017-04-23T23:06:05.880Z", "Doctor name and lastname": "Deniz Yilmaz"}, {"Patient name and lastname": "kkkkkk llllll", "time": "2017-04-23T23:07:27.308Z", "Doctor name and lastname": "qwert qwerty"}, {"Patient name and lastname": "qwer qwerty", "time": "2017-05-08T21:49:24.362Z", "Doctor name and lastname": "Deniz Yilmaz"}, {"Patient name and lastname": "qwer qwerty", "time": "2017-05-08T21:50:57.062Z", "Doctor name and lastname": "Deniz Yilmaz"}]}

POST

Post rendezvous information and send a rendezvous to the database

QUERY PARAMETER VALUE
doctor_id The id of relevant doctor
patient_id The id of relevant patient

Resource URL

http://34.208.111.47:8080/hospital/rendezvous

Example Request

POST http://34.208.111.47:8080/hospital/rendezvous

Example Response

{"status": "OK", "message": "rendezvous added"}

/hospital/rendezvous/:id

GET

Returns single rendezvous without any parameter.

Resource URL

http://34.208.111.47:8080/hospital/rendezvous/{id}

Example Request

GET http://34.208.111.47:8080/hospital/rendezvous/{id}

Example Response

{"Time": "2017-04-23 22:07:39.117858+00:00", "Patient": "qwer qwerty", "Doctor Name": "Kazim Kazim"}

DELETE

Deletes a rendezvous in given id.

Endpoint

DELETE /hospital/rendezvous/{id}

Request Parameters

PATH PARAMETER VALUE
id The id for the rendezvous.

Resource URL

http://34.208.111.47:8080/hospital/rendezvous/{id}

Response Format

On success, the HTTP status code in the response header is 200 OK and the response body contains a rendezvous object in JSON format. On error, the header status code is an error code and the response body contains the following JSON object:

{ "message": "rendezvous does not exist", "status": "FAIL" }

Example

request: $ curl -X DELETE 34.208.111.47:8080/hospital/rendezvous_single/1/

response:

{
    "status":"OK", "message":""
}

GET Hospital/Patient/

Returns all patients without any parameter.

Resource URL

http://127.0.0.1:8000/hospital/patient/

Example Request

GET http://127.0.0.1:8000/hospital/patient/

Example Response

{"patients": [{"name": "qwer", "lastname": "qwerty", "age": 34}, {"name": "rttyu", "lastname": "qwe", "age": 45}, {"name": "kkkkkk", "lastname": "llllll", "age": 34}]}

Delete a doctor

Deletes a doctor in given id.

Endpoint

DELETE /hospital/doctor/{id}

Request Parameters

PATH PARAMETER VALUE
id The id for the doctor.

Response Format

On success, the HTTP status code in the response header is 200 OK and the response body contains a doctor object in JSON format. On error, the header status code is an error code and the response body contains the following JSON object:

{"status":"FAIL", "message":"doctor does not exist"}

Example

request: $ curl -X DELETE 34.208.111.47:8080/hospital/doctor_single/1/ -d '{"name": "Deniz Yılmaz"}'

response:

{
    "status":"OK", "message":""
}
Clone this wiki locally