diff --git a/app/web/integrare_examples.py b/app/web/integrare_examples.py index fb89520..278b3b3 100644 --- a/app/web/integrare_examples.py +++ b/app/web/integrare_examples.py @@ -69,6 +69,50 @@ def _payload_json_compact(account_id: int) -> str: return json.dumps(_payload_prezentari_dict(account_id), separators=(",", ":"), ensure_ascii=False) +def _exemplu_cerere_dict() -> dict: + """Cerere exemplu completa: ambele forme de prestatie + campuri optionale uzuale.""" + return { + "prezentari": [ + { + "vin": "WVWZZZ1JZXW000001", + "nr_inmatriculare": "B123ABC", + "data_prestatie": "2026-06-22", + "odometru_final": "150000", + "odometru_initial": "149500", + "prestatii": [ + {"cod_prestatie": "OE-1"}, + {"cod_op_service": "SF01", "denumire": "Schimb filtru ulei"}, + ], + } + ], + "rar_env": "test", + } + + +def _exemplu_raspuns_dict() -> dict: + """Raspuns exemplu in forma implicita `minim`: 6 chei fixe per rezultat.""" + return { + "results": [ + { + "index": 0, + "submission_id": 123, + "vehicul": "B123ABC", + "status": "queued", + "motiv": None, + "id_prezentare": None, + } + ] + } + + +def exemplu_json() -> dict: + """Perechea cerere/raspuns JSON formatata pentru cardul din pagina Integrare.""" + return { + "cerere": json.dumps(_exemplu_cerere_dict(), indent=2, ensure_ascii=False), + "raspuns": json.dumps(_exemplu_raspuns_dict(), indent=2, ensure_ascii=False), + } + + def _snippet_curl_prezentari(base_url: str, account_id: int) -> str: payload = _payload_json_str(account_id) return f"""curl -X POST "{base_url}/v1/prezentari" \\ diff --git a/app/web/routes.py b/app/web/routes.py index 15720a8..8d9c469 100644 --- a/app/web/routes.py +++ b/app/web/routes.py @@ -516,7 +516,7 @@ def _render_integrare(request: Request, conn, account_id: int) -> str: configurate pe cont), preia base_url real si genereaza snippet-uri multi-limbaj. """ from ..mapping import account_or_default - from .integrare_examples import exemple as _exemple + from .integrare_examples import exemple as _exemple, exemplu_json as _exemplu_json acct = account_or_default(account_id) row_creds = conn.execute( @@ -538,6 +538,7 @@ def _render_integrare(request: Request, conn, account_id: int) -> str: "account_id": acct, "base_url": base_url, "exemple": ex, + "exemplu_json": _exemplu_json(), "are_cheie": are_cheie, "are_creds": are_creds, "csrf_token": csrf_token, diff --git a/app/web/templates/_integrare.html b/app/web/templates/_integrare.html index 072d71b..775ed5b 100644 --- a/app/web/templates/_integrare.html +++ b/app/web/templates/_integrare.html @@ -216,6 +216,41 @@ + {# Card: exemplu cerere + raspuns JSON pentru POST /v1/prezentari #} +
+ POST /v1/prezentari — o prezentare cu doua operatii: una cu cod RAR direct
+ (cod_prestatie), una cu cod intern + denumire (mapata automat de gateway).
+
Cerere
+{{ exemplu_json["cerere"] | e }}
+ Raspuns 200 (forma implicita minim)
{{ exemplu_json["raspuns"] | e }}
+ vin, nr_inmatriculare, data_prestatie (YYYY-MM-DD), odometru_final (string), prestatii (min. 1).cod_prestatie (cod RAR din nomenclator) SAU cod_op_service + denumire — gateway-ul le mapeaza la cod RAR.odometru_initial, obs; rar_env ("test" / "prod") — absent = mediul implicit al contului.index = pozitia din cerere). status: queued (in coada), needs_mapping / needs_data / error (blocat — vezi motiv).id_prezentare e completat doar cand randul era DEJA trimis la RAR (duplicat detectat); altfel apare ulterior, in dashboard sau la GET /v1/prezentari/{id}.held)? Trimite "raspuns": "complet" in body.