User

The Users of BuildingDepot have either of the two roles SuperUser and Default User through which we maintain the access control. The Super User is the admin of BuildingDepot who has permission to add,remove,read,write,delete any entity. The Default User has limited access and does not have permission to add,remove any building and dataservice related entity.Only the SuperUser can add another user and the SuperUser by default in every Building Depot installation is admin@buildingdepot.org. A new User can be added by the SuperUser in the CentralService at http://www.example.com:81/api/user.

Add a new User

This request creates a new User in the Central Service. Only the SuperUser can add a new user

Example request:

POST /api/user HTTP/1.1
Accept: application/json; charset=utf-8

{
  "data":{
      "first_name": "New"
      "last_name":"User",
      "email":"newuser@gmail.com",
      "role":"super"
  }
}

Example response (for success):

HTTP/1.1 200 OK
Content-Type: application/json

{
  "success": "True"
}

Example response (for failure):

HTTP/1.1 200 OK
Content-Type: application/json


{
  "success": "False",
  "error": "User already exists"
}

{
  "success": "False",
  "error": " Missing parameters"
}

{
  "success": "False",
  "error": " Missing data"
}

Get User Details

This request retrieves first name, last_name, email and role of the User specified in the request.

Example request:

GET /api/user/newuser@gmail.com HTTP/1.1
Accept: application/json; charset=utf-8

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{   "success": "True",
      "first_name": "New"
      "last_name":"User",
      "email":"newuser@gmail.com",
      "role":"super"
}

Example response (for failure):

HTTP/1.1 200 OK
Content-Type: application/json

{
  "success": "False",
  "error": " User does not exist"
}

Remove User

This request deletes the requested User from Building Depot.Only the Super user can delete the User in BuildingDepot.

Example request:

DELETE /api/User/newuser@gmail.com HTTP/1.1
Accept: application/json; charset=utf-8

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "success": "True"
}

Example response (for failure):

HTTP/1.1 200 OK
Content-Type: application/json

{
  "success": "False",
  "error": " User does not exist"
}