summaryrefslogtreecommitdiff
path: root/lib/Travelynx
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-12-20 16:23:41 +0100
committerDaniel Friesel <derf@finalrewind.org>2019-12-20 16:23:41 +0100
commitbd372d57e2f9dfd8ba651e19f6adfa69ceda9c09 (patch)
tree5d92f7a48def3bec4e145b37f33b86ea59a60739 /lib/Travelynx
parentd0589781be804951eeec423cf5ea94d6840b27e3 (diff)
Travel API: Add "deprecated" field
Diffstat (limited to 'lib/Travelynx')
-rwxr-xr-xlib/Travelynx/Controller/Api.pm69
1 files changed, 41 insertions, 28 deletions
diff --git a/lib/Travelynx/Controller/Api.pm b/lib/Travelynx/Controller/Api.pm
index f5ea3e4..f0fa5db 100755
--- a/lib/Travelynx/Controller/Api.pm
+++ b/lib/Travelynx/Controller/Api.pm
@@ -174,8 +174,9 @@ sub travel_v1 {
if ( not $payload or ref($payload) ne 'HASH' ) {
$self->render(
json => {
- success => \0,
- error => 'Malformed JSON',
+ success => \0,
+ deprecated => \0,
+ error => 'Malformed JSON',
},
);
return;
@@ -184,7 +185,8 @@ sub travel_v1 {
if ( $self->app->mode ne 'development' ) {
$self->render(
json => {
- success => \0,
+ success => \0,
+ deprecated => \0,
error =>
'This feature is incomplete and only available in development mode',
},
@@ -197,8 +199,9 @@ sub travel_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;
@@ -209,8 +212,9 @@ sub travel_v1 {
if ( $uid > 2147483647 ) {
$self->render(
json => {
- success => \0,
- error => 'Malformed token',
+ success => \0,
+ deprecated => \0,
+ error => 'Malformed token',
},
);
return;
@@ -220,8 +224,9 @@ sub travel_v1 {
if ( $api_token ne $token->{'travel'} ) {
$self->render(
json => {
- success => \0,
- error => 'Invalid token',
+ success => \0,
+ deprecated => \0,
+ error => 'Invalid token',
},
);
return;
@@ -232,8 +237,9 @@ sub travel_v1 {
{
$self->render(
json => {
- success => \0,
- error => 'Missing or invalid action',
+ success => \0,
+ deprecated => \0,
+ error => 'Missing or invalid action',
},
);
return;
@@ -269,8 +275,9 @@ sub travel_v1 {
if ( not defined $train ) {
$self->render(
json => {
- success => \0,
- error => 'Fehler am Abfahrtsbahnhof: '
+ success => \0,
+ deprecated => \0,
+ error => 'Fehler am Abfahrtsbahnhof: '
. $status->{errstr},
status => $self->get_user_status_json_v1($uid)
}
@@ -292,17 +299,19 @@ sub travel_v1 {
if ($error) {
$self->render(
json => {
- success => \0,
- error => $error,
- status => $self->get_user_status_json_v1($uid)
+ success => \0,
+ deprecated => \0,
+ error => $error,
+ status => $self->get_user_status_json_v1($uid)
}
);
}
else {
$self->render(
json => {
- success => \1,
- status => $self->get_user_status_json_v1($uid)
+ success => \1,
+ deprecated => \0,
+ status => $self->get_user_status_json_v1($uid)
}
);
}
@@ -320,17 +329,19 @@ sub travel_v1 {
if ($error) {
$self->render(
json => {
- success => \0,
- error => $error,
- status => $self->get_user_status_json_v1($uid)
+ success => \0,
+ deprecated => \0,
+ error => $error,
+ status => $self->get_user_status_json_v1($uid)
}
);
}
else {
$self->render(
json => {
- success => \1,
- status => $self->get_user_status_json_v1($uid)
+ success => \1,
+ deprecated => \0,
+ status => $self->get_user_status_json_v1($uid)
}
);
}
@@ -340,17 +351,19 @@ sub travel_v1 {
if ($error) {
$self->render(
json => {
- success => \0,
- error => $error,
- status => $self->get_user_status_json_v1($uid)
+ success => \0,
+ deprecated => \0,
+ error => $error,
+ status => $self->get_user_status_json_v1($uid)
}
);
}
else {
$self->render(
json => {
- success => \1,
- status => $self->get_user_status_json_v1($uid)
+ success => \1,
+ deprecated => \0,
+ status => $self->get_user_status_json_v1($uid)
}
);
}