mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-02-22 19:56:29 +01:00
sig push event with bikeId
This commit is contained in:
parent
a8891eb704
commit
c7726be759
5 changed files with 34 additions and 13 deletions
|
@ -800,6 +800,7 @@ sub fetch_bike_tariff {
|
||||||
fetch => "one",
|
fetch => "one",
|
||||||
main_id => "IN::($main_ids)",
|
main_id => "IN::($main_ids)",
|
||||||
barcode => $bike_id,
|
barcode => $bike_id,
|
||||||
|
template_id => 205,
|
||||||
#int10 => 1,
|
#int10 => 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@ package Mod::APIshareeio;
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
|
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
|
||||||
#
|
#
|
||||||
|
#use lib qw(/var/www/copri-bike/shareeapp-sx/src);
|
||||||
|
#
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
use Exporter;
|
use Exporter;
|
||||||
|
@ -32,9 +34,7 @@ sub handler {
|
||||||
my $dbt = new DBtank;
|
my $dbt = new DBtank;
|
||||||
my $bw = new Basework;
|
my $bw = new Basework;
|
||||||
my $tk = new Shareework;
|
my $tk = new Shareework;
|
||||||
my $apif = new APIfunc;
|
|
||||||
|
|
||||||
my $dbh = "";
|
|
||||||
my %varenv = $cf->envonline();
|
my %varenv = $cf->envonline();
|
||||||
my $oprefix = $dbt->{operator}->{$varenv{dbname}}->{oprefix};
|
my $oprefix = $dbt->{operator}->{$varenv{dbname}}->{oprefix};
|
||||||
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
|
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
|
||||||
|
@ -42,7 +42,6 @@ sub handler {
|
||||||
my $user_agent = $q->user_agent();
|
my $user_agent = $q->user_agent();
|
||||||
my $aowner = 168;
|
my $aowner = 168;
|
||||||
my $debug=1;
|
my $debug=1;
|
||||||
my $dbh = "";
|
|
||||||
my $api_file = "/var/www/copri4/shareeconf/apikeys.cfg";
|
my $api_file = "/var/www/copri4/shareeconf/apikeys.cfg";
|
||||||
my $aconf = Config::General->new($api_file);
|
my $aconf = Config::General->new($api_file);
|
||||||
my %apikeyconf = $aconf->getall;
|
my %apikeyconf = $aconf->getall;
|
||||||
|
@ -91,11 +90,20 @@ sub handler {
|
||||||
|
|
||||||
|
|
||||||
#sig booking_update
|
#sig booking_update
|
||||||
sig_booking_update();# sig json post
|
sig_booking_update($q,\%varenv,$response,$aowner);# sig json post
|
||||||
|
|
||||||
#sig json api
|
#sig json api
|
||||||
sub sig_booking_update {
|
sub sig_booking_update {
|
||||||
|
my $q = shift;
|
||||||
|
my $varenv = shift;
|
||||||
|
my $response = shift || {};
|
||||||
|
my $aowner = shift || "";
|
||||||
|
|
||||||
|
$q->import_names('R');
|
||||||
|
my $dbt = new DBtank;
|
||||||
|
my $apif = new APIfunc;
|
||||||
|
my $dbh = "";
|
||||||
|
my $debug=1;
|
||||||
my $jrout = "seems to be not valid";
|
my $jrout = "seems to be not valid";
|
||||||
|
|
||||||
#sig using POST JSON
|
#sig using POST JSON
|
||||||
|
@ -124,13 +132,21 @@ sub sig_booking_update {
|
||||||
$response_in = decode_json($POSTDATA) if($POSTDATA);
|
$response_in = decode_json($POSTDATA) if($POSTDATA);
|
||||||
|
|
||||||
$response->{event} = "$response_in->{event}";
|
$response->{event} = "$response_in->{event}";
|
||||||
if($response_in->{event} && $response_in->{event} eq "RENTAL_END"){
|
if($response_in->{event}){
|
||||||
|
|
||||||
|
my $bikeId = $q->escapeHTML($response_in->{data}->{bikeId}) || "";#on push, bikeId is bike_id
|
||||||
my $rentalId = $q->escapeHTML($response_in->{data}->{rentalId}) || "";
|
my $rentalId = $q->escapeHTML($response_in->{data}->{rentalId}) || "";
|
||||||
my $rows = 0;
|
my $rows = 0;
|
||||||
my $booking_values = {};
|
my $booking_values = {};
|
||||||
|
|
||||||
if($rentalId){
|
if($response_in->{event} eq "RENTAL_START"){
|
||||||
|
$response->{response_state} = "OK: methode not implemented, because rental will started by App";
|
||||||
|
}
|
||||||
|
elsif($response_in->{event} eq "RESERVATION_END"){
|
||||||
|
$response->{response_state} = "OK: this request is still on development";
|
||||||
|
}
|
||||||
|
elsif($response_in->{event} eq "RENTAL_END"){
|
||||||
|
if($rentalId){
|
||||||
|
|
||||||
my $ctpos = {};
|
my $ctpos = {};
|
||||||
my $booking_pos = {
|
my $booking_pos = {
|
||||||
|
@ -159,7 +175,7 @@ sub sig_booking_update {
|
||||||
$q->param(-name=>'bike',-value=>"$ctpos->{ct_name}") if($ctpos->{ct_name});
|
$q->param(-name=>'bike',-value=>"$ctpos->{ct_name}") if($ctpos->{ct_name});
|
||||||
$q->param(-name=>'state',-value=>"available");
|
$q->param(-name=>'state',-value=>"available");
|
||||||
$q->param(-name=>'lock_state',-value=>"locked");
|
$q->param(-name=>'lock_state',-value=>"locked");
|
||||||
($rows, $booking_values) = $apif->booking_update($q,\%varenv,$authraw,$aowner,$sig_book) if($authraw->{c_id});
|
($rows, $booking_values) = $apif->booking_update($q,$varenv,$authraw,$aowner,$sig_book) if($authraw->{c_id});
|
||||||
|
|
||||||
#response is for sig json after rental-end
|
#response is for sig json after rental-end
|
||||||
$booking_values->{bikeId} = $sig_book->{bikeId};
|
$booking_values->{bikeId} = $sig_book->{bikeId};
|
||||||
|
@ -173,11 +189,13 @@ sub sig_booking_update {
|
||||||
$response->{response_state} = "Failure: there is no rental with rentalID=$rentalId";
|
$response->{response_state} = "Failure: there is no rental with rentalID=$rentalId";
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
$response->{response_state} = "Failure: no rentalId defined";
|
$response->{response_state} = "Failure: no rentalId defined";
|
||||||
}
|
}
|
||||||
|
}#end RENTAL_END
|
||||||
|
|
||||||
}#end event
|
}#end event
|
||||||
|
|
||||||
};#end eval
|
};#end eval
|
||||||
if ($@){
|
if ($@){
|
||||||
print FILE "failure! can not decode POST json, POSTDATA:\n" . Dumper($q->param('POSTDATA')) . "\n" if($debug);
|
print FILE "failure! can not decode POST json, POSTDATA:\n" . Dumper($q->param('POSTDATA')) . "\n" if($debug);
|
||||||
|
|
|
@ -215,6 +215,8 @@ $ct->{txt05}
|
||||||
|
|
||||||
$ct->{txt08}
|
$ct->{txt08}
|
||||||
$ct->{txt11}
|
$ct->{txt11}
|
||||||
|
|
||||||
|
Unsere Hotline erreichen Sie unter Tel.: +49 761 45370099
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -493,7 +493,7 @@ EOF
|
||||||
$oprefix = "$dbt->{operator}->{$varenv{dbname}}->{oprefix}-" if($node_meta->{tpl_id} == 224 || $node_meta->{tpl_id} == 228);
|
$oprefix = "$dbt->{operator}->{$varenv{dbname}}->{oprefix}-" if($node_meta->{tpl_id} == 224 || $node_meta->{tpl_id} == 228);
|
||||||
print $q->Tr();
|
print $q->Tr();
|
||||||
print $q->td({-class=>'left_italic_cms'},"$des"),"\n";
|
print $q->td({-class=>'left_italic_cms'},"$des"),"\n";
|
||||||
print $q->td({-class=>'content1_cms',-colspan=>2}, "$oprefix", $q->textfield(-class=>'etxt', -style=>"width:$w;",-name=>"$key", -override=>'1',-default=>"$ct_name")),"\n";
|
print $q->td({-class=>'content1_cms',-colspan=>2}, "$oprefix", $q->textfield(-class=>'etxt', -style=>"width:$w;",-name=>"$key", -override=>'1',-default=>"$ct_name"),$postdes),"\n";
|
||||||
}
|
}
|
||||||
elsif($key eq "barcode"){
|
elsif($key eq "barcode"){
|
||||||
my $w = $size . "em";
|
my $w = $size . "em";
|
||||||
|
|
|
@ -42,11 +42,11 @@ sub tpl(){
|
||||||
if($users_sharee->{c_id} && $R::sharee_edit ne "delete_account2" && ($users_sharee->{c_id} eq $varenv->{superu_id} || $dbt->{copri_conf}->{stage} eq "test" || $users_sharee->{txt08} eq "sigo\@sharee.bike")){
|
if($users_sharee->{c_id} && $R::sharee_edit ne "delete_account2" && ($users_sharee->{c_id} eq $varenv->{superu_id} || $dbt->{copri_conf}->{stage} eq "test" || $users_sharee->{txt08} eq "sigo\@sharee.bike")){
|
||||||
my $coo = $q->cookie('domcookie') || $q->param('sessionid') || "";
|
my $coo = $q->cookie('domcookie') || $q->param('sessionid') || "";
|
||||||
|
|
||||||
my $api_test = "sharee_fr01"; my $bike="FR1538";
|
#my $api_test = "sharee_fr01"; my $bike="FR1538";
|
||||||
#my $api_test = "sharee_fr01"; my $bike="FR4781";#Tracking and BVB test
|
#my $api_test = "sharee_fr01"; my $bike="FR4781";#Tracking and BVB test
|
||||||
#my $api_test = "sharee_kn"; my $bike="KN205";
|
#my $api_test = "sharee_kn"; my $bike="KN205";
|
||||||
#my $api_test = "sharee_wue"; my $bike="WUE5524";
|
#my $api_test = "sharee_wue"; my $bike="WUE5524";
|
||||||
#my $api_test = "sharee_sx"; my $bike="S3X1001";
|
my $api_test = "sharee_sx"; my $bike="S3X1001";
|
||||||
#my $api_test = "sharee_ren"; my $bike="REN2";
|
#my $api_test = "sharee_ren"; my $bike="REN2";
|
||||||
|
|
||||||
print $q->div({-style=>'float:right;text-align:right;height:25px;padding:6px 15px;background-color:white'},$q->a({-style=>"background-color:#ffffff;color:#$bgcolor1;", -href=>"$varenv->{metahost}/src/scripts/tests/index.pl?sessionid=$coo\&api_test=$api_test\&bike=$bike", -target=>'_blank'}," [ tests --> $api_test ] "),"$users_sharee->{txt08}",$q->a({-style=>"color:#$bgcolor1;", -href=>"logout_sharee$session"},"logout")),"\n";
|
print $q->div({-style=>'float:right;text-align:right;height:25px;padding:6px 15px;background-color:white'},$q->a({-style=>"background-color:#ffffff;color:#$bgcolor1;", -href=>"$varenv->{metahost}/src/scripts/tests/index.pl?sessionid=$coo\&api_test=$api_test\&bike=$bike", -target=>'_blank'}," [ tests --> $api_test ] "),"$users_sharee->{txt08}",$q->a({-style=>"color:#$bgcolor1;", -href=>"logout_sharee$session"},"logout")),"\n";
|
||||||
|
|
Loading…
Add table
Reference in a new issue