summaryrefslogtreecommitdiff
path: root/templates/api_documentation.html.ep
blob: de0231dcb75b56f5de8421b2ababd43b07f7c395 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
% my $api_root = $self->url_for('/api/v1')->to_abs->scheme('https');
% my $token = {};
% my $uid;
% if (is_user_authenticated()) {
	% $uid = current_user()->{id};
	% $token = get_api_token();
% }

<h1>API</h1>

<div class="row">
	<div class="col s12">
		Die folgenden API-Endpunkte werden aktuell unterstützt.
	</div>
</div>

<h2>Status</h2>
<div class="row">
	<div class="col s12">
		<p style="font-family: Monospace;">
			% if ($token->{status}) {
				curl <%= $api_root %>/status/<%= $uid %>-<%= $token->{status} // 'TOKEN' %>
			% }
			% else {
				curl <%= $api_root %>/status/TOKEN
			% }
		</p>
		<p>
		Beispiel / Layout:
		</p>
		<p style="font-family: Monospace;">
		{<br/>
			"deprecated" : true / false, (falls true: Diese API-Version wird irgendwann abgeschaltet, bitte auf eine neue umsteigen)<br/>
			"checkedIn" : true / false,<br/>
			"fromStation" : { (letzter Checkin)<br/>
				"name" : "Essen Hbf",<br/>
				"ds100" : "EE",<br/>
				"uic" : 8000098,<br/>
				"latitude" : 51.451355,<br/>
				"longitude" : 7.014793,<br/>
				"scheduledTime": 1556083680,<br/>
				"realTime": 1556083680,<br/>
			},<br/>
			"toStation" : { (zugehöriger Checkout. Wenn noch nicht eingetragen, sind alle Felder null)<br/>
				"name" : "Essen Stadtwald",<br/>
				"ds100" : "EESA",<br/>
				"uic" : 8001896,<br/>
				"latitude" : 51.422853,<br/>
				"longitude" : 7.023296,<br/>
				"scheduledTime": 1556083980, (ggf. null)<br/>
				"realTime": 1556083980, (ggf. null)<br/>
			},<br/>
			"train" : {<br/>
			"type" : "S", (aktueller / letzter Zugtyp)<br/>
			"line" : "6", (Linie als String, nicht immer numerisch, ggf. null)<br/>
			"no" : "30634", (Zugnummer als String)<br/>
			"id" : "7512500863736016593", (IRIS-spezifische Zug-ID)<br/>
			},<br/>
			"actionTime" : 1234567, (UNIX-Timestamp des letzten Checkin/Checkout)<br/>
		}
		</p>
		<p>
			Im Fehlerfall: <span style="font-family: Monospace;">{ "error" : "Begründung" }</span>
		</p>
	</div>
</div>
<!--
<h3>History</h3>
<div class="row">
	<div class="col s12">
		<p>
			Coming soon.
		</p>
	</div>
</div>-->

<h3>Import</h3>
<div class="row">
	<div class="col s12">
		<p>
			Manueller Import vergangener Zugfahrten (eine Fahrt pro API-Aufruf).
		</p>
		<p style="font-family: Monospace;">
			curl -X POST -H "Content-Type: application/json" -d '{"token":"<%= $uid %>-<%= $token->{status} // 'TOKEN' %>"}' <%= $api_root %>/import
		</p>
		<p>Payload (alle nicht als optional markierten Felder sind Pflicht):</p>
		<p style="font-family: Monospace;">
		{<br/>
			"token" : "<%= $token->{import} // 'TOKEN' %>",<br/>
			"dryRun" : True/False, (optional: wenn True, wird die Eingabe validiert, aber keine Zugfahrt angelegt)<br/>
			"cancelled" : True/False, (Zugausfall?)<br/>
			"train" : {<br/>
			"type" : "S", (Zugtyp, z.B. ICE, RE, S)<br/>
			"line" : "6", (Linie als String, bei Zügen ohne Linie wie IC/ICE u.ä. null)<br/>
			"no" : "30634", (Zugnummer als String)<br/>
			},<br/>
			"fromStation" : { (Start / Checkin)<br/>
			"name" : "Essen Hbf", (Name oder DS100)<br/>
			"scheduledTime": 1556083680, (UNIX-Timestamp)<br/>
			"realTime": 1556083680, (UNIX-Timestamp, optional, default == scheduledTime)<br/>
			},<br/>
			"toStation" : { (Ziel / Checkout)<br/>
				"name" : "Essen Stadtwald", (Name oder DS100)<br/>
				"scheduledTime": 1556083980, (UNIX-Timestamp)<br/>
				"realTime": 1556083980, (UNIX-Timestamp, optional, default == scheduledTime)<br/>
			},<br/>
			"route" : [ (optionale Liste mit Unterwegshalten als Name oder DS100, darf keine Stationen vor Checkin oder nach Checkout beinhalten)<br/>
				"Essen Hbf",<br/>
				"Essen Süd",<br/>
				"Essen Stadtwald"<br/>
			],<br/>
			"comment" : "Beliebiger Text" (optionaler Freitext-Kommentar)<br/>
		}
		</p>
		<p>
			Antwort bei Erfolg (der Inhalt von "result" ist von dryRun unabhängig):
		</p>
		<p style="font-family: Monospace;">
		{<br/>
			"success" : True,<br/>
			"id" : 1234, (ID der eingetragenen Zugfahrt)<br/>
			"result" : { ... } (Eingetragene Daten, Inhalt ist variabel)<br/>
		}
		</p>
		<p>
			Antwort bei Fehler:
		</p>
		<p style="font-family: Monospace;">
		{<br/>
			"success" : False,<br/>
			"error" : "Begründung"<br/>
		}
		</p>
	</div>
</div>