Skip to content

Latest commit

 

History

History
181 lines (135 loc) · 3.02 KB

File metadata and controls

181 lines (135 loc) · 3.02 KB

API: User

Name Endpoint
Signup POST /api/user/signup
Signin POST /api/user/signin
Signout POST /api/user/signout
Profile GET /api/user/:id
Update PUT /api/user/me

User signup with email and password.

The success will response with a sid value, set it in the cookie name _sid for all requests in order to be authorized as a user.

sample request

curl -X POST "https://smartlogistic.info/api/user/signup" \
-H "Content-Type: application/json" \
-d '{
  "email": "a@b.com",
  "password": "password", 
  "first_name": "A", 
  "last_name": "B"
}'

sample response

{
  "status": "SUCCESS",
  "data": {
    "first_name": "A",
    "last_name": "B",
    "display_name": "B A",
    "id": 2,
    "sid": "96c4a9ef-ce14-4d7c-8b59-aee30ff532d7"
  }
}

User signin using email and password.

The success will response with a sid value, set it in the cookie name _sid for all requests in order to be authorized as a user.

sample request

curl -X POST "https://smartlogistic.info/api/user/signin" \
-H "Content-Type: application/json" \
-d '{
  "email": "a@b.com",
  "password": "password"
}'

sample response

{
  "status": "SUCCESS",
  "data": {
    "id": 2,
    "first_name": "A",
    "last_name": "B",
    "display_name": "B A",
    "avatar": "",
    "cover": "",
    "birthdate": "",
    "sex": 0,
    "city": "",
    "intro": "",
    "site": "",
    "rc": 0,
    "lc": 0,
    "nc": "0",
    "role": "",
    "updated": "Tue Jan 31 2017 04:15:44 GMT+0700 (ICT)",
    "sid": "89f92655-17b5-45f4-9bb8-8014b2e6ff5d"
  }
}

User signout.

sample request

curl -X POST "https://smartlogistic.info/api/user/signout" \
--cookie "_sid=89f92655-17b5-45f4-9bb8-8014b2e6ff5d"

sample response

{
  "status": "SUCCESS",
  "data": ""
}

Get a user profile.

sample request

curl -X GET "https://smartlogistic.info/api/user/1"

sample response

{
  "status": "SUCCESS",
  "data": {
    "id": 2,
    "first_name": "A",
    "last_name": "B",
    "display_name": "B A",
    "avatar": null,
    "cover": null,
    "birthdate": null,
    "sex": 0,
    "city": null,
    "intro": null,
    "site": null,
    "rc": 0,
    "lc": 0,
    "nc": 0,
    "role": "",
    "updated": "2017-01-30T21:15:44.000Z"
  }
}

Update my profile.

sample request

curl -X PUT "https://smartlogistic.info/api/user/me" \
--cookie "_sid=96c4a9ef-ce14-4d7c-8b59-aee30ff532d7" \
-H "Content-Type: application/json" \
-d '{
  "prop": "display_name",
  "value": "B T A"
}'

sample response

{
  "status": "SUCCESS",
  "data": ""
}