> For the complete documentation index, see [llms.txt](https://liams-organization-5.gitbook.io/scottishglen/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://liams-organization-5.gitbook.io/scottishglen/api-routes/employees.md).

# Employees

## Get ALL Employees

<mark style="color:blue;">`GET`</mark> `api/employees/`

{% tabs %}
{% tab title="200: OK Employees\[]" %}
Responds with an Array of [Employees](/scottishglen/api-routes/employees.md)
{% endtab %}
{% endtabs %}

## Get Employee

<mark style="color:blue;">`GET`</mark> `api/employees/:id`

#### Path Parameters

| Name                                 | Type   | Description            |
| ------------------------------------ | ------ | ---------------------- |
| id<mark style="color:red;">\*</mark> | String | The ID of the Employee |

{% tabs %}
{% tab title="200: OK Employee" %}
Returns an [Employee](/scottishglen/types/employee.md) object.
{% endtab %}

{% tab title="404: Not Found " %}

{% endtab %}
{% endtabs %}

## Insert Employee

<mark style="color:green;">`POST`</mark> `api/employees/`

#### Request Body

| Name                                              | Type       | Description                                    |
| ------------------------------------------------- | ---------- | ---------------------------------------------- |
| forename<mark style="color:red;">\*</mark>        | String     | The First Name of the Employee                 |
| surname<mark style="color:red;">\*</mark>         | String     | The Family Name of the Employee                |
| department<mark style="color:red;">\*</mark>      | Department | The Department of the Employee                 |
| password<mark style="color:red;">\*</mark>        | String     | The account password                           |
| confirmPassword<mark style="color:red;">\*</mark> | String     | The users confirmation of the account password |

{% tabs %}
{% tab title="400: Bad Request " %}

{% endtab %}

{% tab title="500: Internal Server Error " %}

{% endtab %}

{% tab title="200: OK " %}

{% endtab %}
{% endtabs %}

## Login as User

<mark style="color:green;">`POST`</mark> `api/employees/login`

#### Request Body

| Name                                       | Type   | Description                                 |
| ------------------------------------------ | ------ | ------------------------------------------- |
| email<mark style="color:red;">\*</mark>    | String | The e-mail for the User Account             |
| password<mark style="color:red;">\*</mark> | String | The plaintext password for the User Account |

{% tabs %}
{% tab title="400: Bad Request " %}

{% endtab %}

{% tab title="200: OK { email: string, password: string }" %}
Once data has been returned, the user's session has been authenticated.
{% endtab %}
{% endtabs %}

## Encrypt Password

<mark style="color:green;">`POST`</mark> `api/employees/generate-password`

Encrypt a password using the API via BCrypt.

#### Request Body

| Name                                       | Type   | Description                                 |
| ------------------------------------------ | ------ | ------------------------------------------- |
| password<mark style="color:red;">\*</mark> | String | The plaintext password for the User Account |

{% tabs %}
{% tab title="400: Bad Request " %}

{% endtab %}

{% tab title="200: OK { status: true, password: string }" %}

{% endtab %}
{% endtabs %}

## Delete ALL Employees

<mark style="color:red;">`DELETE`</mark> `api/employees/`

{% tabs %}
{% tab title="200: OK " %}

{% endtab %}
{% endtabs %}

## Delete Employee

<mark style="color:red;">`DELETE`</mark> `api/employees/:id`

#### Path Parameters

| Name                                 | Type   | Description            |
| ------------------------------------ | ------ | ---------------------- |
| id<mark style="color:red;">\*</mark> | String | The ID of the Employee |

{% tabs %}
{% tab title="200: OK " %}

{% endtab %}
{% endtabs %}

## Edit Employee

<mark style="color:purple;">`PATCH`</mark> `api/employees/:id`

#### Path Parameters

| Name                                 | Type   | Description            |
| ------------------------------------ | ------ | ---------------------- |
| id<mark style="color:red;">\*</mark> | String | The ID of the Employee |

#### Request Body

| Name                                         | Type       | Description                     |
| -------------------------------------------- | ---------- | ------------------------------- |
| forename<mark style="color:red;">\*</mark>   | String     | The First Name of the Employee  |
| surname<mark style="color:red;">\*</mark>    | String     | The Family Name of the Employee |
| department<mark style="color:red;">\*</mark> | Department | The Department of the Employee  |

{% tabs %}
{% tab title="200: OK " %}

{% endtab %}
{% endtabs %}
