diff options
| -rwxr-xr-x | lib/Travelynx/Controller/Api.pm | 62 | ||||
| -rw-r--r-- | templates/api_documentation.html.ep | 2 | 
2 files changed, 32 insertions, 32 deletions
diff --git a/lib/Travelynx/Controller/Api.pm b/lib/Travelynx/Controller/Api.pm index 96817fb..e55b2b2 100755 --- a/lib/Travelynx/Controller/Api.pm +++ b/lib/Travelynx/Controller/Api.pm @@ -354,19 +354,9 @@ sub import_v1 {  	if ( not $payload or ref($payload) ne 'HASH' ) {  		$self->render(  			json => { -				success => \0, -				error   => 'Malformed JSON', -			}, -		); -		return; -	} - -	if ( $self->app->mode ne 'development' ) { -		$self->render( -			json => { -				success => \0, -				error => -'This feature is incomplete and only available in development mode', +				success    => \0, +				deprecated => \0, +				error      => 'Malformed JSON',  			},  		);  		return; @@ -377,8 +367,9 @@ sub import_v1 {  	if ( $api_token !~ qr{ ^ (?<id> \d+ ) - (?<token> .* ) $ }x ) {  		$self->render(  			json => { -				success => \0, -				error   => 'Malformed token', +				success    => \0, +				deprecated => \0, +				error      => 'Malformed token',  			},  		);  		return; @@ -389,19 +380,21 @@ sub import_v1 {  	if ( $uid > 2147483647 ) {  		$self->render(  			json => { -				success => \0, -				error   => 'Malformed token', +				success    => \0, +				deprecated => \0, +				error      => 'Malformed token',  			},  		);  		return;  	}  	my $token = $self->get_api_token($uid); -	if ( $api_token ne $token->{'import'} ) { +	if ( not $token->{'import'} or $api_token ne $token->{'import'} ) {  		$self->render(  			json => { -				success => \0, -				error   => 'Invalid token', +				success    => \0, +				deprecated => \0, +				error      => 'Invalid token',  			},  		);  		return; @@ -412,8 +405,9 @@ sub import_v1 {  	{  		$self->render(  			json => { -				success => \0, -				error   => 'missing fromStation or toStation', +				success    => \0, +				deprecated => \0, +				error      => 'missing fromStation or toStation',  			},  		);  		return; @@ -480,8 +474,9 @@ sub import_v1 {  		my ($first_line) = split( qr{\n}, $@ );  		$self->render(  			json => { -				success => \0, -				error   => $first_line +				success    => \0, +				deprecated => \0, +				error      => $first_line  			}  		);  		return; @@ -508,17 +503,19 @@ sub import_v1 {  	if ($error) {  		$self->render(  			json => { -				success => \0, -				error   => $error +				success    => \0, +				deprecated => \0, +				error      => $error  			}  		);  	}  	elsif ( $payload->{dryRun} ) {  		$self->render(  			json => { -				success => \1, -				id      => $journey_id, -				result  => $journey +				success    => \1, +				deprecated => \0, +				id         => $journey_id, +				result     => $journey  			}  		);  	} @@ -527,9 +524,10 @@ sub import_v1 {  		$tx->commit;  		$self->render(  			json => { -				success => \1, -				id      => $journey_id, -				result  => $journey +				success    => \1, +				deprecated => \0, +				id         => $journey_id, +				result     => $journey  			}  		);  	} diff --git a/templates/api_documentation.html.ep b/templates/api_documentation.html.ep index 0c8c534..c20d37c 100644 --- a/templates/api_documentation.html.ep +++ b/templates/api_documentation.html.ep @@ -203,6 +203,7 @@  		<p style="font-family: Monospace;">  		{<br/>  			"success" : true,<br/> +			"deprecated" : true / false, (falls true: Diese API-Version wird irgendwann abgeschaltet, bitte auf eine neue umsteigen)<br/>  			"id" : 1234, (ID der eingetragenen Zugfahrt)<br/>  			"result" : { ... } (Eingetragene Daten, Datenformat nicht näher spezifiziert und beliebig variabel)<br/>  		} @@ -213,6 +214,7 @@  		<p style="font-family: Monospace;">  		{<br/>  			"success" : false,<br/> +			"deprecated" : true / false, (falls true: Diese API-Version wird irgendwann abgeschaltet, bitte auf eine neue umsteigen)<br/>  			"error" : "Begründung"<br/>  		}  		</p>  | 
