Legislation WebServices

Version Date Notes By
0.2 2020-04-07 Fix wrong endpoint. Small fix FPA
0.1 2020-04-06 Initial release FPA

Login

Authenticates the user and obtains the authentication token.

Request

Method URL
POST /api/auth/login
Headers Type
Content-Type application/json
Parameters Content
email varchar(255)
password varchar(255)

Response

  • HTTP status code 200
{
    "token": "<token>",
    "token_type": "bearer",
    "expires_in": 43200
}

All the following requests must include the token.

  • HTTP status code 401
{
    "status": false,
    "message": "Credenciais inválidas."
}
  • HTTP status code 401
{
    "status": false,
    "message": "Esta conta encontra-se inativa."
}

Diploma classifications

Active diploma classifications

This endpoint returns a collection of active diploma classifications

Request

Method URL
GET /legislation/management/diploma-classifications/active
Headers Content
Content-Type application/json
Authorization Bearer

Response

  • HTTP status code 200
[
    {
        "id": 299,
        "parent_id": null,
        "lft": 2621,
        "rgt": 2658,
        "depth": 0,
        "client_id": null,
        "country_id": 620,
        "order": "2",
        "name": "Ambiente",
        "ancestors_and_self": [
            "Ambiente"
        ],
        "status_id": 1,
        "created_at": "2018-06-15 13:40:59",
        "created_by": 2,
        "updated_at": "2018-07-20 15:32:53",
        "updated_by": 2,
        "subscribed": 0
    },
    {
        "id": 298,
        "parent_id": 299,
        "lft": 2634,
        "rgt": 2641,
        "depth": 1,
        "client_id": null,
        "country_id": 620,
        "order": "2.1",
        "name": "Gestão de Resíduos",
        "ancestors_and_self": [
            "Ambiente",
            "Gestão de Resíduos"
        ],
        "status_id": 1,
        "created_at": "2018-06-15 13:40:59",
        "created_by": 2,
        "updated_at": "2018-10-30 12:41:52",
        "updated_by": 7,
        "subscribed": 0
    }
] 

Diplomas

Get diploma's history

This endpoint returns a collection of diplomas, with the possibility to indicate a checkpoint date.

Request

Method URL
GET /legislation/diplomas/history
GET /legislation/diplomas/history?from=
Headers Content
Content-Type application/json
Authorization Bearer
Parameters Content
timestamp dateTime(Y-m-d H:i:s)

If it is the first time this synchronization is performed, you must use the first URL (without the query parameter).

Response

  • HTTP status code 200
[
    {
        "diploma": {
            "id": 18570,
            "applicabilities": [],
            "country": {
                "id": 620,
                "capital": "Lisbon",
                "citizenship": "Portuguese",
                "country_code": "620",
                "currency": "euro",
                "currency_code": "EUR",
                "currency_sub_unit": "cent",
                "currency_symbol": "€",
                "currency_decimals": 2,
                "full_name": "Portuguese Republic",
                "iso_3166_2": "PT",
                "iso_3166_3": "PRT",
                "name": "Portugal",
                "region_code": "150",
                "sub_region_code": "039",
                "eea": 1,
                "calling_code": "351",
                "flag": "PT.png"
            },
            "source": {
                "id": 2,
                "client_id": null,
                "country_id": 620,
                "order": 2,
                "name": "Comunitária",
                "own_flag_id": null,
                "status_id": 1
            },
            "type": {
                "id": 47,
                "client_id": null,
                "country_id": 620,
                "acronym": "DCS",
                "name": "Decisão",
                "status_id": 1
            },
            "number": "113/05/C",
            "name": "Decisão nº 113/05/C/2020 de 06 de Abril",
            "summary": "Resumo das decisões da Comissão Europeia relativas às autorizações de colocação no mercado para utilização e/ou às autorizações de utilização de substâncias enumeradas no anexo XIV do Regulamento (CE) n.o 1907/2006 do Parlamento Europeu e do Conselho relativo ao registo, avaliação, autorização e restrição dos produtos químicos (REACH) [Publicado nos termos do disposto no artigo 64.o, n.o 9, do Regulamento (CE) n.o 1907/2006 (JO L 396 de 30.12.2006, p. 1.)]",
            "resume": null,
            "published_at": "2020-04-06",
            "status": {
                "id": 1,
                "label_class": "badge-success",
                "name": "Em vigor"
            },
            "keywords": [],
            "viewing_document": {
                "id": 30064,
                "relatable_id": 18570,
                "relatable_type": "WeMake\\Legislation\\Models\\Diploma",
                "mime_type": "application/pdf",
                "file_name": "4RiqONwQ04Sa35YVeKS7HcGpScxXBc2g.pdf",
                "display_name": "DCS113-05-C-2020-PT",
                "extension": "pdf",
                "size": 514079,
                "file_hash": "93bf128b5088e8d1ca09532139790269",
                "description": null,
                "created_at": "2020-04-06 16:16:56",
                "created_by": 7,
                "updated_at": "2020-04-06 16:17:58",
                "updated_by": 7,
                "deleted_at": null,
                "deleted_by": null
            },
            "consolidated_document": null,
            "detailed_classifications": [
                {
                    "id": 86332,
                    "parent_id": 86319,
                    "lft": 2692,
                    "rgt": 2693,
                    "depth": 1,
                    "client_id": 3,
                    "country_id": 620,
                    "order": "2.2",
                    "name": "Substâncias Perigosas",
                    "ancestors_and_self": [
                        "Ambiente",
                        "Substâncias Perigosas"
                    ],
                    "status_id": 1,
                    "created_at": "2018-07-20 16:09:49",
                    "created_by": 1,
                    "updated_at": "2018-07-20 16:09:49",
                    "updated_by": 1,
                    "subscribed": 1,
                    "pivot": {
                        "diploma_id": 18570,
                        "classification_id": 86332
                    }
                }
            ],
            "legal_connections": [
                {
                    "id": 81117,
                    "owner_diploma_id": 18570,
                    "owned_diploma_id": 6208,
                    "legal_connection_type_id": 12,
                    "commencement_date": null,
                    "notes": null,
                    "original": 1,
                    "client_id": null,
                    "manual_owned_diploma": null
                }
            ],
            "commencement_date": null
        },
        "type": {
            "id": 1,
            "label_class": "badge-success",
            "name": "Criação"
        },
        "timestamp": "2020-04-06 16:18:00"
    }
] 

Get diploma's sheet

This endpoint returns the diploma's sheet on PDF format, given its ID.

Request

Method URL
GET /legislation/diplomas//sheet
Headers Content
Content-Type application/json
Authorization Bearer
Parameters Content
diploma_id int

Response

A blob with the file's content.

WKHTMLTOPDF - "Too many open files" error

Usually occurs in Legislation's applicability reports when hundreds or more pages are being generated for a PDF. Must change 3 values, one in /etc/php/8.x/fpm/php-fpm.conf and the others are the .env timeout variables:

  • php-fpm.conf: rlimit_files = 2048
  • .env: WKHTML_PDF_TIMEOUT=120
  • .env: WKHTML_IMG_TIMEOUT=120