From 5fe4174febbf833e0fdbfd5f1500883720c420df Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 14 Dec 2019 20:46:02 +0100 Subject: Add API entry point for journey import --- templates/account.html.ep | 27 +++++++++++++++-- templates/api_documentation.html.ep | 60 +++++++++++++++++++++++++++++++++---- 2 files changed, 80 insertions(+), 7 deletions(-) (limited to 'templates') diff --git a/templates/account.html.ep b/templates/account.html.ep index b3ec52a..a9f1bb0 100644 --- a/templates/account.html.ep +++ b/templates/account.html.ep @@ -169,7 +169,7 @@ %= end - + --> Travel @@ -192,7 +192,30 @@ %= end - --> + + + Import + + % if ($token->{import}) { + %= $acc->{id} . '-' . $token->{import} + % } + % else { + — + % } + + + %= form_for 'set_token' => begin + %= csrf_field + %= hidden_field 'token' => 'import' + + + %= end + + diff --git a/templates/api_documentation.html.ep b/templates/api_documentation.html.ep index dd59be6..de0231d 100644 --- a/templates/api_documentation.html.ep +++ b/templates/api_documentation.html.ep @@ -41,7 +41,7 @@ "scheduledTime": 1556083680,
"realTime": 1556083680,
},
- "fromStation" : { (zugehöriger Checkout. Wenn noch nicht eingetragen, sind alle Felder null)
+ "toStation" : { (zugehöriger Checkout. Wenn noch nicht eingetragen, sind alle Felder null)
"name" : "Essen Stadtwald",
"ds100" : "EESA",
"uic" : 8001896,
@@ -72,14 +72,64 @@ Coming soon.

- +--> -

Travel

+

Import

- Ein- und Auschecken per API. Coming soon. + Manueller Import vergangener Zugfahrten (eine Fahrt pro API-Aufruf). +

+

+ curl -X POST -H "Content-Type: application/json" -d '{"token":"<%= $uid %>-<%= $token->{status} // 'TOKEN' %>"}' <%= $api_root %>/import +

+

Payload (alle nicht als optional markierten Felder sind Pflicht):

+

+ {
+ "token" : "<%= $token->{import} // 'TOKEN' %>",
+ "dryRun" : True/False, (optional: wenn True, wird die Eingabe validiert, aber keine Zugfahrt angelegt)
+ "cancelled" : True/False, (Zugausfall?)
+ "train" : {
+ "type" : "S", (Zugtyp, z.B. ICE, RE, S)
+ "line" : "6", (Linie als String, bei Zügen ohne Linie wie IC/ICE u.ä. null)
+ "no" : "30634", (Zugnummer als String)
+ },
+ "fromStation" : { (Start / Checkin)
+ "name" : "Essen Hbf", (Name oder DS100)
+ "scheduledTime": 1556083680, (UNIX-Timestamp)
+ "realTime": 1556083680, (UNIX-Timestamp, optional, default == scheduledTime)
+ },
+ "toStation" : { (Ziel / Checkout)
+ "name" : "Essen Stadtwald", (Name oder DS100)
+ "scheduledTime": 1556083980, (UNIX-Timestamp)
+ "realTime": 1556083980, (UNIX-Timestamp, optional, default == scheduledTime)
+ },
+ "route" : [ (optionale Liste mit Unterwegshalten als Name oder DS100, darf keine Stationen vor Checkin oder nach Checkout beinhalten)
+ "Essen Hbf",
+ "Essen Süd",
+ "Essen Stadtwald"
+ ],
+ "comment" : "Beliebiger Text" (optionaler Freitext-Kommentar)
+ } +

+

+ Antwort bei Erfolg (der Inhalt von "result" ist von dryRun unabhängig): +

+

+ {
+ "success" : True,
+ "id" : 1234, (ID der eingetragenen Zugfahrt)
+ "result" : { ... } (Eingetragene Daten, Inhalt ist variabel)
+ } +

+

+ Antwort bei Fehler: +

+

+ {
+ "success" : False,
+ "error" : "Begründung"
+ }

---> -- cgit v1.2.3