diff --git a/.env.example b/.env.example index ddc0df8..5ae62c7 100644 --- a/.env.example +++ b/.env.example @@ -19,6 +19,7 @@ CACHE_DRIVER=file QUEUE_CONNECTION=sync MOBILEBACKEND_BASE_URL =https://ilink-app.com +MOBILEBACKENDTEST_BASE_URL=http://test.ilink-app.com:8080 WALLET_SERVICE_BASE_URL =https://ilink-app.com WALLET_SERVICE_NAME = walletService WALLET_SERVICE_KEY=yhSTSSqIO1uSE1icu09edPOeSFGxIDjo diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 8d21d9d..8f05ec7 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -87,10 +87,14 @@ class Handler extends ExceptionHandler if ( $exception instanceof ClientException) { - $message = $exception->getResponse()->getBody(); + $message = $exception->getMessage(); + $array = explode("\n", $message); + $error =json_decode($array[1]) ; $code = $exception->getCode(); - - return $this->errorResponse($message,$code); + if($error) + return $this->errorResponse($error->error,$code); + else + return $this->errorResponse($message,$code); } if($exception instanceof AuthenticationException) diff --git a/app/Http/Controllers/MobileBackendTestController.php b/app/Http/Controllers/MobileBackendTestController.php new file mode 100644 index 0000000..c93cfa8 --- /dev/null +++ b/app/Http/Controllers/MobileBackendTestController.php @@ -0,0 +1,35 @@ +mobilebackendtestService = $mobilebackendtestService; + } + + public function action(Request $request) + { + return $this->successResponse($this->mobilebackendtestService->action( + $request->getRequestUri(), $request->all() + )); + } + +} diff --git a/app/Services/MobileBackendTestService.php b/app/Services/MobileBackendTestService.php new file mode 100644 index 0000000..d9e60ca --- /dev/null +++ b/app/Services/MobileBackendTestService.php @@ -0,0 +1,26 @@ +baseUri = config('services.mobilebackendtest.base_uri'); + } + + public function action($uri , $data) + { + return $this->perfomRequest('POST',$uri.'.php',$data); + } +} diff --git a/config/services.php b/config/services.php index a64546e..ac2a068 100644 --- a/config/services.php +++ b/config/services.php @@ -4,6 +4,9 @@ return [ 'mobilebackend' => [ 'base_uri' => env('MOBILEBACKEND_BASE_URL'), ], + 'mobilebackendtest' => [ + 'base_uri' => env('MOBILEBACKENDTEST_BASE_URL'), + ], 'wallet_service' => [ 'base_uri' => env('WALLET_SERVICE_BASE_URL'), 'key'=> env('WALLET_SERVICE_KEY') diff --git a/routes/web.php b/routes/web.php index 16a108c..05b5922 100644 --- a/routes/web.php +++ b/routes/web.php @@ -36,14 +36,14 @@ */ $router->group(['prefix' => '/mobilebackendtest/interacted' , 'middleware' => 'auth:api'], function () use ($router){ - $router->post('LoginAction', 'MobileBackendController@action'); - $router->post('BalanceAction', 'MobileBackendController@action'); - $router->post('ConfigAction', 'MobileBackendController@action'); - $router->post('DemandeAction', 'MobileBackendController@action'); - $router->post('MembersAction', 'MobileBackendController@action'); - $router->post('LocationAction', 'MobileBackendController@action'); - $router->post('NetworkAction', 'MobileBackendController@action'); - $router->post('WalletAction', 'MobileBackendController@action'); + $router->post('LoginAction', 'MobileBackendTestController@action'); + $router->post('BalanceAction', 'MobileBackendTestController@action'); + $router->post('ConfigAction', 'MobileBackendTestController@action'); + $router->post('DemandeAction', 'MobileBackendTestController@action'); + $router->post('MembersAction', 'MobileBackendTestController@action'); + $router->post('LocationAction', 'MobileBackendTestController@action'); + $router->post('NetworkAction', 'MobileBackendTestController@action'); + $router->post('WalletAction', 'MobileBackendTestController@action'); }); @@ -54,16 +54,17 @@ // Transactions routes $router->group(['prefix' => '/transactions'] , function () use ($router){ - $router->post('','WalletControllerr@post'); + $router->post('','WalletController@post'); $router->get('{id_wallet}','WalletController@get'); }); // Credits routes $router->group(['prefix' => '/credits'] , function () use ($router){ $router->put('treatDemand/{id_demand}','WalletController@put'); + $router->put('cancelDemand/{id_demand}','WalletController@put'); }); - $router->post('/virement','WalletController@post'); + $router->put('/virement/{id_wallet}','WalletController@put'); // Wallets routes $router->group(['prefix' => '/wallets'] , function () use ($router){