Commit ae218969 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

API: Add lax option

parent 9adec3ee
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -958,7 +958,7 @@ sub startup {

	$self->helper(
		'journey_sanity_check' => sub {
			my ( $self, $journey ) = @_;
			my ( $self, $journey, $lax ) = @_;

			if ( $journey->{sched_duration} and $journey->{sched_duration} < 0 )
			{
@@ -983,7 +983,12 @@ sub startup {
			{
				return 'Zugfahrten mit über 500 km/h? Schön wär\'s.';
			}
			if ( $journey->{edited} & 0x0010 ) {
			if ( $journey->{route} and @{ $journey->{route} } > 99 ) {
				my $stop_count = @{ $journey->{route} };
				return
"Die Zugfahrt hat $stop_count Unterwegshalte. Also ich weiß ja nicht so recht.";
			}
			if ( $journey->{edited} & 0x0010 and not $lax ) {
				my @unknown_stations
				  = $self->grep_unknown_stations( map { $_->[0] }
					  @{ $journey->{route} } );
+2 −1
Original line number Diff line number Diff line
@@ -452,7 +452,8 @@ sub import_v1 {
			journey_id => $journey_id,
			verbose    => 1
		);
		$error = $self->journey_sanity_check($journey);
		$error
		  = $self->journey_sanity_check( $journey, $payload->{lax} ? 1 : 0 );
	}

	if ($error) {
+6 −5
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@
		<p>Payload zum Einchecken, optional mit Zielwahl:</p>
		<p style="font-family: Monospace;">
		{<br/>
			"token" : "<%= $uid %>-<%= $token->{import} // 'TOKEN' %>",<br/>
			"token" : "<%= $uid %>-<%= $token->{travel} // 'TOKEN' %>",<br/>
			"action" : "checkin",<br/>
			"train" : {<br/>
				"type" : "ICE",<br/>
@@ -92,7 +92,7 @@
		<p>Payload zur Wahl eines neuen Ziels, wenn bereits eingecheckt:</p>
		<p style="font-family: Monospace;">
		{<br/>
			"token" : "<%= $uid %>-<%= $token->{import} // 'TOKEN' %>",<br/>
			"token" : "<%= $uid %>-<%= $token->{travel} // 'TOKEN' %>",<br/>
			"action" : "checkout",<br/>
			"force" : True/False, (wenn True: Checkout jetzt durchführen und auftretende Fehler ignorieren. Kann zu Logeinträgen ohne Ankunftsdaten führen.)<br/>
			"toStation" : "Berlin Hbf", (DS100 oder EVA-Nummer sind ebenfalls möglich)<br/>
@@ -102,7 +102,7 @@
		<p>Payload zum Rückgängigmachen eines Checkins (nur während der Fahrt möglich):</p>
		<p style="font-family: Monospace;">
		{<br/>
			"token" : "<%= $uid %>-<%= $token->{import} // 'TOKEN' %>",<br/>
			"token" : "<%= $uid %>-<%= $token->{travel} // 'TOKEN' %>",<br/>
			"action" : "undo"<br/>
		}
		</p>
@@ -135,13 +135,14 @@
			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
			curl -X POST -H "Content-Type: application/json" -d '{"token":"<%= $uid %>-<%= $token->{import} // 'TOKEN' %>"}' <%= $api_root %>/import
		</p>
		<p>Payload (alle nicht als optional markierten Felder sind Pflicht):</p>
		<p style="font-family: Monospace;">
		{<br/>
			"token" : "<%= $uid %>-<%= $token->{import} // 'TOKEN' %>",<br/>
			"dryRun" : True/False, (optional: wenn True, wird die Eingabe validiert, aber keine Zugfahrt angelegt)<br/>
			"lax" : True/Fals, (optional: wenn True, werden unbekannte Unterwegshalte akzeptiert)<br/>
			"cancelled" : True/False, (Zugausfall?)<br/>
			"train" : {<br/>
			"type" : "S", (Zugtyp, z.B. ICE, RE, S)<br/>
@@ -173,7 +174,7 @@
		{<br/>
			"success" : True,<br/>
			"id" : 1234, (ID der eingetragenen Zugfahrt)<br/>
			"result" : { ... } (Eingetragene Daten, Inhalt ist variabel)<br/>
			"result" : { ... } (Eingetragene Daten, Datenformat nicht näher spezifiziert und beliebig variabel)<br/>
		}
		</p>
		<p>