+ Add NotificationService
This commit is contained in:
parent
85d0c4e23a
commit
c76ed0ef2f
|
@ -23,3 +23,7 @@ MOBILEBACKENDTEST_BASE_URL=http://test.ilink-app.com:8080
|
||||||
WALLET_SERVICE_BASE_URL =https://ilink-app.com
|
WALLET_SERVICE_BASE_URL =https://ilink-app.com
|
||||||
WALLET_SERVICE_NAME = walletService
|
WALLET_SERVICE_NAME = walletService
|
||||||
WALLET_SERVICE_KEY=yhSTSSqIO1uSE1icu09edPOeSFGxIDjo
|
WALLET_SERVICE_KEY=yhSTSSqIO1uSE1icu09edPOeSFGxIDjo
|
||||||
|
|
||||||
|
NOTIFICATION_SERVICE_NAME = notificationService
|
||||||
|
NOTIFICATION_SERVICE_BASE_URL= http://localhost:8083
|
||||||
|
NOTIFICATION_SERVICE_KEY=RfXvPQzQRgwpzQYPnLfWpZzgx4QseHlg
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Services\NotificationService;
|
||||||
|
use App\Traits\ApiResponser;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class NotificationServiceController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponser;
|
||||||
|
/**
|
||||||
|
* @var notificationService
|
||||||
|
*/
|
||||||
|
public $notificationService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @param NotificationService $service
|
||||||
|
*/
|
||||||
|
public function __construct(NotificationService $service)
|
||||||
|
{
|
||||||
|
$this->notificationService = $service;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get(Request $request)
|
||||||
|
{
|
||||||
|
return $this->successResponse($this->notificationService->get(
|
||||||
|
substr($request->getRequestUri(),strlen(env('NOTIFICATION_SERVICE_NAME'))+1), $request->all(),$request->header()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function post(Request $request)
|
||||||
|
{
|
||||||
|
return $this->successResponse($this->notificationService->post(
|
||||||
|
substr($request->getRequestUri(),strlen(env('NOTIFICATION_SERVICE_NAME'))+1), $request->all(),$request->header()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function put(Request $request)
|
||||||
|
{
|
||||||
|
return $this->successResponse($this->notificationService->put(
|
||||||
|
substr($request->getRequestUri(),strlen(env('NOTIFICATION_SERVICE_NAME'))+1), $request->all(),$request->header()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete(Request $request)
|
||||||
|
{
|
||||||
|
return $this->successResponse($this->notificationService->delete(
|
||||||
|
substr($request->getRequestUri(),strlen(env('NOTIFICATION_SERVICE_NAME'))+1), $request->all(),$request->header()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Traits\ConsumesExternalService;
|
||||||
|
|
||||||
|
class NotificationService
|
||||||
|
{
|
||||||
|
use ConsumesExternalService;
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $baseUri ;
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $key ;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->baseUri = config('services.notification_service.base_uri');
|
||||||
|
$this->key = config('services.notification_service.key');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function post($uri , $data, $headers)
|
||||||
|
{
|
||||||
|
return $this->perfomRequest('POST',$uri,$data,$headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get($uri , $data, $headers)
|
||||||
|
{
|
||||||
|
return $this->perfomRequest('GET',$uri,$data,$headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function put($uri , $data, $headers)
|
||||||
|
{
|
||||||
|
return $this->perfomRequest('PUT',$uri,$data,$headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete($uri , $data, $headers)
|
||||||
|
{
|
||||||
|
return $this->perfomRequest('DELETE',$uri,$data,$headers);
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,5 +10,9 @@ return [
|
||||||
'wallet_service' => [
|
'wallet_service' => [
|
||||||
'base_uri' => env('WALLET_SERVICE_BASE_URL'),
|
'base_uri' => env('WALLET_SERVICE_BASE_URL'),
|
||||||
'key'=> env('WALLET_SERVICE_KEY')
|
'key'=> env('WALLET_SERVICE_KEY')
|
||||||
|
],
|
||||||
|
'notification_service' => [
|
||||||
|
'base_uri' => env('NOTIFICATION_SERVICE_BASE_URL'),
|
||||||
|
'key'=> env('NOTIFICATION_SERVICE_KEY')
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
|
@ -114,3 +114,15 @@
|
||||||
$router->post('update', 'WalletServiceController@post');
|
$router->post('update', 'WalletServiceController@post');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Routes for Notification Service
|
||||||
|
*/
|
||||||
|
$router->group(['prefix' => '/'.env('NOTIFICATION_SERVICE_NAME') ,'middleware' => 'auth:api'], function () use ($router){
|
||||||
|
// OneSingal routes
|
||||||
|
$router->group(['prefix'=>'/onesignal'], function () use ($router) {
|
||||||
|
$router->post('saveUser', 'NotificationServiceController@post');
|
||||||
|
$router->post('saveAgent', 'NotificationServiceController@post');
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue