Add walletService
This commit is contained in:
parent
edf677ae1c
commit
a4c699f60a
|
@ -19,4 +19,6 @@ CACHE_DRIVER=file
|
||||||
QUEUE_CONNECTION=sync
|
QUEUE_CONNECTION=sync
|
||||||
|
|
||||||
MOBILEBACKEND_BASE_URL =https://ilink-app.com
|
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
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Services\WalletService;
|
||||||
|
use App\Traits\ApiResponser;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
|
||||||
|
class WalletController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponser;
|
||||||
|
/**
|
||||||
|
* @var WalletService
|
||||||
|
*/
|
||||||
|
public $walletService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @param WalletService $walletService
|
||||||
|
*/
|
||||||
|
public function __construct(WalletService $walletService)
|
||||||
|
{
|
||||||
|
$this->walletService = $walletService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function activated(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
return $this->successResponse($this->walletService->get(
|
||||||
|
substr($request->getRequestUri(),strlen(env('WALLET_SERVICE_NAME'))+1), $request->all()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Traits\ConsumesExternalService;
|
||||||
|
|
||||||
|
class WalletService
|
||||||
|
{
|
||||||
|
use ConsumesExternalService;
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $baseUri ;
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $key ;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,7 +13,7 @@ trait ApiResponser
|
||||||
|
|
||||||
public function errorResponse($message , $code)
|
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)
|
public function errorMessage($message , $code)
|
||||||
|
|
|
@ -20,6 +20,10 @@ trait ConsumesExternalService
|
||||||
'base_uri' => $this->baseUri,
|
'base_uri' => $this->baseUri,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if(isset($this->key)){
|
||||||
|
$headers['Authorization'] = $this->key;
|
||||||
|
}
|
||||||
|
|
||||||
$response = $client->request($method , $requestUrl , ['json'=> $body , 'form_params' => $formParams , 'headers' => $headers] );
|
$response = $client->request($method , $requestUrl , ['json'=> $body , 'form_params' => $formParams , 'headers' => $headers] );
|
||||||
|
|
||||||
return $response->getBody()->getContents();
|
return $response->getBody()->getContents();
|
||||||
|
|
|
@ -4,7 +4,8 @@ return [
|
||||||
'mobilebackend' => [
|
'mobilebackend' => [
|
||||||
'base_uri' => env('MOBILEBACKEND_BASE_URL'),
|
'base_uri' => env('MOBILEBACKEND_BASE_URL'),
|
||||||
],
|
],
|
||||||
'mobilebackendtest' => [
|
'wallet_service' => [
|
||||||
'base_uri' => env('MOBILEBACKENDTEST_BASE_URL'),
|
'base_uri' => env('WALLET_SERVICE_BASE_URL'),
|
||||||
|
'key'=> env('WALLET_SERVICE_KEY')
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
|
@ -18,17 +18,26 @@
|
||||||
/**
|
/**
|
||||||
* Routes for MobileBackend
|
* 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('LoginAction', 'MobileBackendController@action');
|
||||||
$router->post('BalanceAction', 'MobileBackendController@action');
|
$router->post('BalanceAction', 'MobileBackendController@action');
|
||||||
$router->post('ConfigAction', 'MobileBackendController@action');
|
$router->post('ConfigAction', 'MobileBackendController@action');
|
||||||
$router->post('DemandeAction', 'MobileBackendController@action');
|
$router->post('DemandeAction', 'MobileBackendController@action');
|
||||||
$router->post('MembersAction', 'MobileBackendController@action');
|
$router->post('MembersAction', 'MobileBackendController@action');
|
||||||
|
$router->post('LocationAction', 'MobileBackendController@action');
|
||||||
$router->post('NetworkAction', 'MobileBackendController@action');
|
$router->post('NetworkAction', 'MobileBackendController@action');
|
||||||
$router->post('WalletAction', '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');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue