api code global jain
This commit is contained in:
133
app/Http/Controllers/Api/V1/Access/NotificationsController.php
Normal file
133
app/Http/Controllers/Api/V1/Access/NotificationsController.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1\Access;
|
||||
|
||||
use App\Constant\Constant;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Http\Controllers\Api\ApiController;
|
||||
use App\Repositories\Api\Access\Notification\NotificationsInterface as NotificationsRepository;
|
||||
|
||||
class NotificationsController extends ApiController
|
||||
{
|
||||
/**
|
||||
* @var NotificationsRepository
|
||||
*/
|
||||
protected $notificationsRepository;
|
||||
|
||||
/**
|
||||
* @param NotificationsRepository $notificationsRepository
|
||||
* NotificationsController constructor.
|
||||
*
|
||||
*/
|
||||
public function __construct(NotificationsRepository $notificationsRepository)
|
||||
{
|
||||
$this->notificationsRepository = $notificationsRepository;
|
||||
}
|
||||
|
||||
public function notificationListing(Request $request)
|
||||
{
|
||||
$response = [];
|
||||
|
||||
try {
|
||||
$response = $this->notificationsRepository->notificationListing($request->all());
|
||||
$this->setStatusCode($response['status']);
|
||||
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
$this->setStatusCode(Constant::CODE_403);
|
||||
}
|
||||
|
||||
return $this->respond($response);
|
||||
}
|
||||
|
||||
public function deleteNotification($id)
|
||||
{
|
||||
$response = [];
|
||||
|
||||
try {
|
||||
$response = $this->notificationsRepository->deleteNotification($id);
|
||||
$this->setStatusCode($response['status']);
|
||||
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
$this->setStatusCode(Constant::CODE_403);
|
||||
}
|
||||
return $this->respond($response);
|
||||
}
|
||||
|
||||
public function deleteAllNotifications()
|
||||
{
|
||||
$response = [];
|
||||
|
||||
try {
|
||||
$response = $this->notificationsRepository->deleteAllNotifications();
|
||||
$this->setStatusCode($response['status']);
|
||||
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
$this->setStatusCode(Constant::CODE_403);
|
||||
}
|
||||
return $this->respond($response);
|
||||
}
|
||||
|
||||
public function pushNotificationRegister(Request $request)
|
||||
{
|
||||
$response = [];
|
||||
|
||||
try{
|
||||
$response = $this->notificationsRepository->pushNotificationRegister($request);
|
||||
$this->setStatusCode($response['status']);
|
||||
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
$this->setStatusCode(Constant::CODE_403);
|
||||
}
|
||||
return $this->respond($response);
|
||||
}
|
||||
|
||||
public function deleteUserToken(Request $request)
|
||||
{
|
||||
$response = [];
|
||||
|
||||
try{
|
||||
$response = $this->notificationsRepository->deleteUserToken($request);
|
||||
$this->setStatusCode($response['status']);
|
||||
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
$this->setStatusCode(Constant::CODE_403);
|
||||
}
|
||||
return $this->respond($response);
|
||||
}
|
||||
|
||||
public function deleteExistingToken(Request $request)
|
||||
{
|
||||
$response = [];
|
||||
|
||||
try{
|
||||
$response = $this->notificationsRepository->deleteExistingDeviceToken($request);
|
||||
$this->setStatusCode($response['status']);
|
||||
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
$this->setStatusCode(Constant::CODE_403);
|
||||
}
|
||||
return $this->respond($response);
|
||||
}
|
||||
|
||||
public function getUnreadCounts()
|
||||
{
|
||||
$response = [];
|
||||
|
||||
try{
|
||||
$response = $this->notificationsRepository->getUnreadCounts();
|
||||
$this->setStatusCode($response['status']);
|
||||
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
$this->setStatusCode(Constant::CODE_403);
|
||||
}
|
||||
return $this->respond($response);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user