# API

## Generam token

<mark style="color:blue;">`GET`</mark> `https://admin.duae.esempla.srl/api/v1/login`

#### Path Parameters

| Name          | Type   | Description                       |
| ------------- | ------ | --------------------------------- |
| Authorization | string | Metoda de autorizare "Basic Auth" |

#### Request Body

| Name     | Type   | Description                             |
| -------- | ------ | --------------------------------------- |
| Username | string | Numele secret al Organizatiei (din sso) |
| Password | string | Tokenul secret al Proectului (din sso)  |

{% tabs %}
{% tab title="200 Exemplul rezultatului corect, am generat tokenul" %}

```
{
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6IjEifQ.eyJpc3MiOiIxIiwiYXVkIjoiMSIsImp0aSI6IjEiLCJpYXQiOjE1NTQ3MTE2NjgsIm5iZiI6MTU1NDcxMTY2OCwiZXhwIjoxNTU0NzE1MjY4LCJ0ZXRzUHJvdmlkZXIxIjpudWxsfQ.ANTAox50qRJLRnLU6EPv7dY6gGRATAjaRaJyz0ICXM8"
}
```

{% endtab %}

{% tab title="401 Problema cu autorizarea,
Username, Password sun indicate incorect" %}

```
{
    "name": "Unauthorized",
    "message": "Your request was made with invalid credentials.",
    "code": 0,
    "status": 401
}
```

{% endtab %}

{% tab title="404 Metoda este setata incorect, sau variabilele din SNS pentru conectarea la SSO sunt indicate incorect" %}

```
{
    "name": "Not Found",
    "message": "Page not found.",
    "code": 0,
    "status": 404,
    "previous": {
        "name": "Invalid Route",
        "message": "Unable to resolve the request \"v1/loginn\".",
        "code": 0
    }
}
```

{% endtab %}
{% endtabs %}

<mark style="color:blue;">`GET`</mark> `https://admin.duae.esempla.srl/api/v1/getDuaeTemplate`

#### Path Parameters

| Name          | Type   | Description                         |
| ------------- | ------ | ----------------------------------- |
| Authorization | string | Metoda de autorizare "Bearer Token" |

#### Request Body

| Name  | Type   | Description     |
| ----- | ------ | --------------- |
| Token | string | Indicam tokenul |

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

```
{
    "payload": {
        "template": "[{\"object\":\"Object\",\"value\":[{\"simple\":\"item\"}]},{\"simple\":\"item\"}]"
    },
    "error": null
}
```

{% endtab %}

{% tab title="401 tokenul incoerct" %}

```
{
    "name": "Unauthorized",
    "message": "Your request was made with invalid credentials.",
    "code": 0,
    "status": 401,
    "type": "yii\\web\\UnauthorizedHttpException"
}
```

{% endtab %}

{% tab title="404 api metoda incorecta" %}

```
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>Not Found (#404)</title>
        <style>
        body {
            font: normal 9pt "Verdana";
            color: #000;
            background: #fff;
        }

        h1 {
            font: normal 18pt "Verdana";
            color: #f00;
            margin-bottom: .5em;
        }

        h2 {
            font: normal 14pt "Verdana";
            color: #800000;
            margin-bottom: .5em;
        }

        h3 {
            font: bold 11pt "Verdana";
        }

        p {
            font: normal 9pt "Verdana";
            color: #000;
        }

        .version {
            color: gray;
            font-size: 8pt;
            border-top: 1px solid #aaa;
            padding-top: 1em;
            margin-bottom: 1em;
        }
    </style>
    </head>
    <body>
        <h1>Not Found (#404)</h1>
        <h2>Page not found.</h2>
        <p>
        The above error occurred while the Web server was processing your request.
    </p>
        <p>
        Please contact us if you think this is a server error. Thank you.
    </p>
        <div class="version">
        2019-06-27 08:55:22    </div>
    </body>
</html>
```

{% endtab %}
{% endtabs %}

<mark style="color:blue;">`GET`</mark> `https://admin.duae.esempla.srl/api/v1/getOrganization?user_id=999999999`

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
|      | string |             |

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

```
```

{% endtab %}
{% endtabs %}
