Skip to content

Departments

Introduction

Departments are used to depict various organizational units, by which the addressing of content in different modules can be executed.

List

Get a list of all Departments.

Model & Relations

Namespace

App\Department

Relations

RelationKeyTypeRelation Field(s)
RolesrolesHas manyroles.department_id

Definition

GET /api/departments

Example Request

php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('GET', '/api/departments', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);

Example Response

json
[
  {
    "id": 2,
    "name": "Usergroup-1",
    "created_at": "2019-01-21 13:54:19",
    "updated_at": "2019-01-21 13:54:19",
    "deleted_at": null
  },
  {
    "id": 3,
    "name": "Usergroup-2",
    "created_at": "2019-01-21 13:54:24",
    "updated_at": "2019-01-21 13:54:24",
    "deleted_at": null
  }
]

Get

Get a single Department by id.

Definition

GET /api/departments/{id}

Example Request

php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('GET', '/api/departments/2', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);

Example Response

json
{
  "id": 2,
  "name": "Usergroup-1",
  "created_at": "2019-01-21 13:54:19",
  "updated_at": "2019-01-21 13:54:19",
  "deleted_at": null
}

Get Availability Information

Get the Availability Information for Departments

Definition

GET /api/departments/availability-information

Example Request

php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('GET', '/api/departments/availability-information', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);

Example Response

json
{
  "available": 40,
  "used": 12
}

Create

Create a new Department.

Definition

POST /api/departments

Request Keys

KeyTypeDefaultDescription
name *string-Name of the Department

Keys with * are required.

Note

The request can fail if the maximum Number of Departments is already reached.

Example Request

php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('POST', '/api/departments', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'name' => 'Usergroup-3'
    ]
]);

Example Response

json
{
  "status": "success",
  "data": {
    "name": "Usergroup-3",
    "created_at": "2019-01-21 13:54:34",
    "updated_at": "2019-01-21 13:54:34",
    "id": 4
  }
}

Update

Update an existing Department by id.

Definition

PUT /api/departments/{id}

Request Keys

KeyTypeDescription
namestringName of the Department

Example Request

php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('PUT', '/api/departments/4', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'name' => 'Usergroup3',
    ]
]);

Example Response

json
{
  "status": "success",
  "data": {
    "id": 4,
    "name": "Usergroup3",
    "created_at": "2019-01-21 13:54:34",
    "updated_at": "2019-01-21 14:05:42",
    "deleted_at": null
  }
}

Delete

Delete an existing Department by id.

Definition

DELETE /api/departments/{id}

Example Request

php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('DELETE', '/api/departments/4', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);

Example Response

json
{
  "status": "success",
  "data": []
}