{% extends "passerelle/manage/service_view.html" %}
{% load i18n passerelle %}

{% block description %}
{% if object.description %}{{object.description|linebreaks}}{% endif %}
{% endblock %}

{% block endpoints %}
<ul>
    <li>
        {% url "generic-endpoint" connector="greco" slug=object.slug endpoint="ping" as ping %}
        GET <a href="{{ ping }}">{{ ping }}</a>
        <br />
        {% trans 'Response:' %} <samp>
          {"data": "…[ping]", "err": 0}
        </samp>
    </li>
    <li>
        {% url "generic-endpoint" connector="greco" slug=object.slug endpoint="create" as create %}
        POST <a href="{{ create }}">{{ create }}</a>
        <br />
        {% trans 'JSON payload:' %} <samp>
          { {% for field in object.creation_fields %}"{{ field }}":&nbsp;"…"{% if not forloop.last %},
          {% endif %}{% endfor %} }
        </samp>
        <br />
        {% trans 'Response:' %} <samp>
          {"data": {"application": "…", "etat": "1 - Créée", "iddemande": "…", "idgreco": "…", "motifsrejet": null}, "err": 0}
        </samp>
    </li>
    <li>
        {% url "generic-endpoint" connector="greco" slug=object.slug endpoint="status" as status %}
        GET <a href="{{ status }}?idgreco=…&iddemande=…">{{ status }}?idgreco=…&iddemande=…</a>
        <br />
        {% trans 'Response:' %} <samp>
          {"data": {"commentaireReponse": null, "comptesRendus": null, "dateResolutionEffective": null, "dateResolutionPrevue": "YYYY-MM-DD",
                    "etat": "1 - Créée", "groupeResponsable": null, "iddemande": "…", "idgreco": "…", "motifsrejet": null, "suiteDonnee": null},
          "err": 0}
        </samp>
    </li>
    <li>
        {% url "generic-endpoint" connector="greco" slug=object.slug endpoint="add-information" as addinfo %}
        POST <a href="{{ addinfo }}">{{ addinfo }}</a>
        <br />
        {% trans 'JSON payload:' %} <samp>
          {"idgreco": "…", "iddemande": "…", "information": "…"}
        </samp>
        <br />
        {% trans 'Response:' %} <samp>
          {"data": {"iddemande": "…", "idgreco": "…", "motifsrejet": null}, "err": 0}
        </samp>
    </li>
    <li>
        {% url "generic-endpoint" connector="greco" slug=object.slug endpoint="update" as update %}
        POST <a href="{{ update }}">{{ update }}</a>
        <br />
        {% trans 'JSON payload:' %} <samp>
          {"idgreco": "…", "iddemande": "…", "comment": "…"}
        </samp>
        <br />
        {% trans 'Response:' %} <samp>
          {"data": {"iddemande": "…", "idgreco": "…", "motifsrejet": null}, "err": 0}
        </samp>
    </li>
</ul>
{% endblock %}

{% block security %}
<p>
  {% trans 'Access is limited to the following API users:' %}
</p>
{% access_rights_table resource=object permission='can_access' %}
{% endblock %}
