summaryrefslogtreecommitdiff
path: root/lib/Travelynx/Controller/Api.pm
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-01-26 10:47:51 +0100
committerDaniel Friesel <derf@finalrewind.org>2020-01-26 10:47:51 +0100
commitc31254e996a0b2ddc03fdecdb27ab262b88911d1 (patch)
treebb60f38dae0e2bf46fb40657b064e36d3b96b32e /lib/Travelynx/Controller/Api.pm
parent1723f8c1fb52dc9830ab30421492a1b546f4e3c5 (diff)
import API: Add deprecated field, remove development check
Diffstat (limited to 'lib/Travelynx/Controller/Api.pm')
-rwxr-xr-xlib/Travelynx/Controller/Api.pm62
1 files changed, 30 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
}
);
}