UserAPI - MikeAWilliams/white_card GitHub Wiki

Note, the apis listed do not include authentication or authorization.

User record

A user record consists of some basic public information about them as well as the authorizations they have for one or more diciplines

Example

{
  "realName": "Mike Williams",
  "scaName": "Logan of Logan",
  "email": "[email protected]",
  "blueCardNumber": 123456,
  "diciplines": [
    {
      "name": "Rapier",
      "expirationDate": "2018-11-13",
      "authorizedBy":223456,
      "authorizations": [
        {
          "name": "Heavy Rapier",
          "authorized": false
        },
        {
          "name": "Light Rapier",
          "authorized": true
        }
      ]
    }
  ]
}

Schema

{
  "title": "User Record",
  "type": "object",
  "required": ["realName","scaName","email","blueCardNumber","diciplines"],
  "properties": {
    "realName": {
      "type": "string",
      "description": "the users real name"
    },
      "scaName": {
      "type": "string",
      "description": "the users sca name"
    },
      "email": {
      "type": "string",
      "description": "the users email. Used for authentication"
    },
    "blueCardNumber": {
      "type": "integer",
      "description": "the users blue card number"
    },
    "diciplines": {
      "type": "array",
      "description": "A list of dicipline authorizations for this user",
      "items": {
        "type": "object",
        "required":["name","expirationDate","authorizedBy","authorizations"],
        "properties": {
          "name": {
            "type": "string",
            "description": "The dicipline name"
          },
          "expirationDate": {
            "type": "string",
            "format": "date",
            "description": "the expiration date in international format"
          },
          "authorizedBy":{
            "type":"integer",
            "description":"the blue card number of the am who issued the authorization",
          },
          "authorizations": {
            "type": "array",
            "description": "A list of authizations held by a user in this dicipline",
            "items": {
              "type": "object",
              "required": [
                "name",
                "authorized"
              ],
              "properties": {
                "name": {
                  "type": "string",
                  "description": "the name of the authorization"
                },
                "authorized": {
                  "type": "boolean",
                  "description": "does the current user posess this authorization"
                }
              }
            }
          }
        }
      }
    }
  }
}

API

GET /api/v1/users

Description

retrieve all user data

Request Body

none

Response

200 Successful

{
   "users": [ {"All User Records as above"}]
}

GET /api/v1/users/blueCardNumber

Description

retrieve user data for user with blueCardNumber

Request Body

none

Response

200 Successful, 404 Not found

Successful response Body

{
"A user data as above"
}

POST /api/v1/users/blueCardNumber

Description

Create a new user data with the provided blue card number

Request Body

{
"A user data as above"
}

Response

200 Successful, 403 User already exists

Error response Body

{
"The existing user data as above"
}

PUT /api/v1/users/blueCardNumber

Description

Replace an existing user data with the one in the body for the given blueCardNumber

Request Body

{
"A user data as above"
}

Response

200 Successful, 404 User not found

Successful response body

{
"old":"The previous existing user data as above",
"new":"The user data as in the body of the request as above"
}

DELETE /api/v1/users/blueCardNumber

Description

Delete the user associated with the blueCardNumber

Request Body

none

### Response
200 Successful, 404 User not found
### Successful response body
```json
{
"The user record that was deleted as above",
}