diff --git a/.env.example b/.env.example index 1252e1d..ddc0df8 100644 --- a/.env.example +++ b/.env.example @@ -19,4 +19,6 @@ CACHE_DRIVER=file QUEUE_CONNECTION=sync MOBILEBACKEND_BASE_URL =https://ilink-app.com -MOBILEBACKENDTEST_BASE_URL =https://ilink-app.com +WALLET_SERVICE_BASE_URL =https://ilink-app.com +WALLET_SERVICE_NAME = walletService +WALLET_SERVICE_KEY=yhSTSSqIO1uSE1icu09edPOeSFGxIDjo diff --git a/app/Http/Controllers/WalletController.php b/app/Http/Controllers/WalletController.php new file mode 100644 index 0000000..cfad70f --- /dev/null +++ b/app/Http/Controllers/WalletController.php @@ -0,0 +1,37 @@ +walletService = $walletService; + } + + public function activated(Request $request) + { + + return $this->successResponse($this->walletService->get( + substr($request->getRequestUri(),strlen(env('WALLET_SERVICE_NAME'))+1), $request->all() + )); + } + +} diff --git a/app/Services/WalletService.php b/app/Services/WalletService.php new file mode 100644 index 0000000..04efe04 --- /dev/null +++ b/app/Services/WalletService.php @@ -0,0 +1,36 @@ +baseUri = config('services.wallet_service.base_uri'); + $this->key = config('services.wallet_service.key'); + } + + public function post($uri , $data) + { + return $this->perfomRequest('POST',$uri,$data); + } + + public function get($uri , $data) + { + return $this->perfomRequest('GET',$uri,$data); + } +} diff --git a/app/Traits/ApiResponser.php b/app/Traits/ApiResponser.php index 3d92162..f548ef7 100644 --- a/app/Traits/ApiResponser.php +++ b/app/Traits/ApiResponser.php @@ -13,7 +13,7 @@ trait ApiResponser public function errorResponse($message , $code) { - return response()->json(['error' => $message , 'code'=> $code]); + return response()->json(['error' => $message , 'code'=> $code],$code); } public function errorMessage($message , $code) diff --git a/app/Traits/ConsumesExternalService.php b/app/Traits/ConsumesExternalService.php index 2f44e6b..215109e 100644 --- a/app/Traits/ConsumesExternalService.php +++ b/app/Traits/ConsumesExternalService.php @@ -20,6 +20,10 @@ trait ConsumesExternalService 'base_uri' => $this->baseUri, ]); + if(isset($this->key)){ + $headers['Authorization'] = $this->key; + } + $response = $client->request($method , $requestUrl , ['json'=> $body , 'form_params' => $formParams , 'headers' => $headers] ); return $response->getBody()->getContents(); diff --git a/config/services.php b/config/services.php index 3676c5f..a64546e 100644 --- a/config/services.php +++ b/config/services.php @@ -4,7 +4,8 @@ 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 839c52b..7f70c16 100644 --- a/routes/web.php +++ b/routes/web.php @@ -18,17 +18,26 @@ /** * Routes for MobileBackend */ - $router->group(['prefix' => '/mobilebackend/interacted'], function () use ($router){ + $router->group(['prefix' => '/mobilebackend/interacted' , 'middleware' => 'clients.credentials'], function () use ($router){ - $router->group(['middleware' => 'clients.credentials'], 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'); - }); }); + /** + * Routes for Wallet Service + */ + $router->group(['prefix' => '/'.env('WALLET_SERVICE_NAME') ,'middleware' => 'clients.credentials'], function () use ($router){ + + // Wallets routes + $router->group(['prefix' => '/wallets'] , function () use ($router){ + $router->get('activated', 'WalletController@activated'); + }); + });