Dailys
Docs

Roles

This section describes the API for accessing the organisation's roles. This will include all of the roles of the organisation that the authenticated user has access to.

Index

This API route will return a paginated list of all of the roles that belong to the organisation.

The index endpoint can be used as a reliable form of searching, as search results are paginated, and related resources of the role are also searched to increase the effeciveness of the search.

This resource requires authorisation. Please read the documentation on authorisation.

URI

GET https://api.dailys.nz/api/v1/roles

Parameters

Parameter Type Description
sortKey string The sort key specifies which resource attribute you want to search by.
sortAsc integer The sort asc defines if sorting should be ascending, accepts: 0 or 1.
query string The search term the role has provided, to refine results.
page integer The page number requested; used for pagination.
limit integer The number of resrouces per page; maximum: 100 minimum: 1

Allowed Sort Keys

name, scope

Response

{
    "current_page": 1,
    "data": [
        {
            "id": 1,
            "scope": "organisations",
            "name": "Employee",
            "description": "Standard user.",
            "permissions": {
                ...
            },
            "created_at": "2000-01-01 00:00:00",
            "updated_at": "2000-01-01 00:00:00",
            "deleted_at": null,
            "deleted": false
        },
        {
            "id": 2,
            "scope": "projects",
            "name": "Project Manager",
            "description": "Log time and expenses, edit project, see reports.",
            "permissions": {
                ...
            },
            "created_at": "2000-01-01 00:00:00",
            "updated_at": "2000-01-01 00:00:00",
            "deleted_at": null,
            "deleted": false
        },
        ...
    ],
    "from": 1,
    "last_page": 1,
    "next_page_url": null,
    "path": "https://api.dailys.nz/api/v1/roles",
    "per_page": 100,
    "prev_page_url": null,
    "to": 5,
    "total": 5
}

Store

This API route will allow you to store a new role. There are required fields, as the resource does not already exist.

This resource requires authorisation. Please read the documentation on authorisation.

URI

POST https://api.dailys.nz/api/v1/roles

Parameters

Parameter Required Type Description
scope required string The scope of the role, i.e. the resource type for the role.
name required string The name of the role.
description required string The description of the role, to make it easily identifiable.
permissions required permissions The permissions that the role will grant to the assigned user.

Allowed Scopes

organisations, projects, clients, users, teams, invoices

Request

{
  "scope": "organisations",
  "name": "Administrator",
  "description": "The administrator for the organistion.",
  "permissions": {
      "resource": {},
      "subresources": {
          "clients": [
              "index",
              "store",
              "destroy"
          ]
      }
  }
}

Response

{
    "success": true,
    "role": {
        "id": 1,
        "scope": "organisations",
        "name": "Administrator",
        "description": "The administrator for the organistion.",
        "permissions": {
            "resource": [],
            "subresources": {
                "clients": [
                    "index",
                    "store",
                    "destroy"
                ]
            }
        },
        "updated_at": "2000-01-01 00:00:00",
        "created_at": "2000-01-01 00:00:00",
        "deleted": false,
        "organisation": {
            ...
        }
    }
}

Show

This API route will return the role's data, which includes the permissions that assgined users would be granted. This resource also returns the users who are assigned this role.

This resource requires authorisation. Please read the documentation on authorisation.

URI

GET https://api.dailys.nz/api/v1/roles/:ROLE_ID

Response

{
    "id": 1,
    "scope": "organisations",
    "name": "Administrator",
    "description": "The administrator for the organistion.",
    "permissions": {
        "resource": [],
        "subresources": {
            "clients": [
                "index",
                "store",
                "destroy"
            ]
        }
    },
    "created_at": "2000-01-01 00:00:00",
    "updated_at": "2000-01-01 00:00:00",
    "deleted_at": null,
    "users": [
        ...
    ],
    "deleted": false
}

Update

This API route will allow you to update role details. As this resource already exists, there are no required fields, so you can send as many or as few parameters as you would like.

This resource requires authorisation. Please read the documentation on authorisation.

URI

PUT https://api.dailys.nz/api/v1/roles/:ROLE_ID

Parameters

Parameter Type Description
scope string The scope of the role, i.e. the resource type for the role.
name string The name of the role.
description string The description of the role, to make it easily identifiable.
permissions permissions The permissions that the role will grant to the assigned user.

Allowed Scopes

organisations, projects, clients, users, teams, invoices

Request

{
    "name": "Another Name"
}

Response

{
    "success": true,
    "role": {
        "id": 1,
        "scope": "organisations",
        "name": "Another Name",
        "description": "The administrator for the organistion.",
        "permissions": {
            "resource": [],
            "subresources": {
                "clients": [
                    "index",
                    "store",
                    "destroy"
                ]
            }
        },
        "created_at": "2000-01-01 00:00:00",
        "updated_at": "2000-01-01 00:00:00",
        "deleted_at": null,
        "deleted": false,
        "organisation": {
            ...
    }
}

Destroy

This API route will allow you to archive a role. This role will no long be accessible using this API endpoint, however the role can be restored from the archives and the role will then be re-activated.

This resource requires authorisation. Please read the documentation on authorisation.

URI

DELETE https://api.dailys.nz/api/v1/roles/:ROLE_ID

Response

{
    "success": true,
    "role": {
        "id": 1,
        "scope": "organisations",
        "name": "Administrator",
        "description": "The administrator for the organistion.",
        "permissions": {
            "resource": [],
            "subresources": {
                "clients": [
                    "index",
                    "store",
                    "destroy"
                ]
            }
        },
        "created_at": "2000-01-01 00:00:00",
        "updated_at": "2000-01-01 00:00:00",
        "deleted_at": null,
        "deleted": false,
        "organisation": {
            ...
    }
}