Skip to content

Working Api's

Vishnu Prasad S edited this page Apr 16, 2016 · 4 revisions

Registration

Request

POST - URL : /register

{
  "userName": "vishnu2abc",
  "email": "[email protected]",
  "name": "vishnu",
  "bloodGroup": "0+ve",
  "dob": "24-03-1985",
  "password": "qwe",
  "confirmPassword": "qwe",
  "latitude": 0.01,
  "longitude": 0.02,
  "phoneNo": "12123"
}
Response
// Successful Message
{
  "status": "ok",
  "message": "Registration successful"
}
// Failed Message
{
  "status": "failed",
  "message": "Registration Failed",
  "comments": [
    "userName : vishnua3ABC Exists !",
    "email : vishnua@ABC Exists !"
  ]
}

Login

Request

POST - URL : /login

{
  "userName": "vishnu667",
  "password": "sam"
}
Response
// Successful Message
{
  "status": "ok",
  "token": "144af8494cca7c8b134b0f022abf1f0da380260ec22ff7b4a530ef1975822d3a",
  "message": "Login successful"
}
// Failed Message
{
  "status": "failed",
  "message": "Registration Failed",
  "comments": [
    "userName : vishnua3ABC Exists !",
    "email : vishnua@ABC Exists !"
  ]
}

Logout

Request

POST - URL : /logout

{
  "token": "144af8494cca7c8b134b0f022abf1f0da380260ec22ff7b4a530ef1975822d3a"
}
Response
{
  "status": "ok",
  "token": "144af8494cca7c8b134b0f022abf1f0da380260ec22ff7b4a530ef1975822d3a",
  "message": "Login successful"
}

Get Current User

POST - URL : /api/user/get

{
  "token": "049926a188ad7a8d8e15f52a993d701763cb9b4a5851ccc067dd95c202a3f722"
}
Response
// Successful Message
{
  "status": "ok",
  "user": {
    "name": "vishnu667",
    "bloodGroup": "0+ve",
    "email": "[email protected]",
    "dob": "0013-10-13",
    "zipCode": 0,
    "lon": 0.02,
    "lat": 0.01,
    "userName": "vishnu667",
    "phone": "12123"
  }
}
// Failed Message
{
  "status": "failed",
  "message": "auth Failed"
}

Register new Blood Request

POST - URL : /api/bloodRequest/register

{
  "token": "8acbbd80e7ce457e8cd5b816fa01302b0fe60c4f276acf349aa39021bf4e98a2",
  "data": {
    "contactNumber": "13245645",
    "hospitalName": "hospital name",
    "hospitalAddress": " hospital address1, Hospital address 2",
    "patientName": "Patient Name",
    "bloodGroup": "0+ve",
    "purpose": "reason for blood Request will be displayed to the donors",
    "comment": "",
    "requiredUnits": 3,
    "lat": 0.0,
    "lon": 0.0,
    "requiredWithin": 1462022163000
  }
}
Response
{
  "status": "ok",
  "bloodRequest": {
    "bloodGroup": "0+ve",
    "patientName": "Patient Name",
    "requiredWithin": 1462022163000,
    "purpose": "reason for blood Request will be displayed to the donors",
    "status": 0,
    "comment": "",
    "createdUserId": 1,
    "contactNumber": "13245645",
    "lon": 0.0,
    "requestId": 3,
    "hospitalAddress": " hospital address1, Hospital address 2",
    "requiredUnits": 3,
    "hospitalName": "hospital name",
    "fulfilledUnits": 0,
    "lat": 0.0,
    "promisedUnits": 0
  },
  "messages": ["Blood Request Created Successfully with Id 3"]
}

Get Blood Request Object

POST - URL : /api/bloodRequest/get

{
"token": "0e74847772ad2abe9836c66fc2688a826288440a12a5d5d8bf91edb3eded2abe",
  "requestId":1
}
Response
{
  "status": "ok",
  "bloodRequest": {
    "bloodGroup": "0+ve",
    "patientName": "Patient Name",
    "requiredWithin": 1462022163000,
    "purpose": "reason for blood Request will be displayed to the donors",
    "status": 0,
    "comment": "",
    "createdUserId": 1,
    "contactNumber": "13245645",
    "lon": 0.0,
    "requestId": 1,
    "hospitalAddress": " hospital address1, Hospital address 2",
    "requiredUnits": 3,
    "hospitalName": "hospital name",
    "fulfilledUnits": 0,
    "lat": 0.0,
    "promisedUnits": 0
  }
}