API updates
This commit is contained in:
34
app/Api/ApiServiceProvider.php
Normal file
34
app/Api/ApiServiceProvider.php
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Api;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class ApiServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Bootstrap the application events.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the service provider.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
// Add routes
|
||||||
|
// if (isInstall()) {
|
||||||
|
$routes = app_path('/Api/routes.php');
|
||||||
|
if (file_exists($routes)) {
|
||||||
|
require $routes;
|
||||||
|
}
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
63
app/Api/routes.php
Normal file
63
app/Api/routes.php
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* ================================================================================================
|
||||||
|
* @version v1
|
||||||
|
* @access public
|
||||||
|
* @copyright (c) 2016, Ladybird web solution
|
||||||
|
* @author Vijay Sebastian<vijay.sebastian@ladybirdweb.com>
|
||||||
|
* @name Faveo
|
||||||
|
*/
|
||||||
|
Route::group(['prefix' => 'api/v1'], function () {
|
||||||
|
Route::post('authenticate', '\App\Api\v1\TokenAuthController@authenticate');
|
||||||
|
Route::get('authenticate/user', '\App\Api\v1\TokenAuthController@getAuthenticatedUser');
|
||||||
|
Route::get('/database-config', ['as' => 'database-config', 'uses' => '\App\Api\v1\InstallerApiController@config_database']);
|
||||||
|
Route::get('/system-config', ['as' => 'database-config', 'uses' => '\App\Api\v1\InstallerApiController@config_system']);
|
||||||
|
/*
|
||||||
|
* Helpdesk
|
||||||
|
*/
|
||||||
|
Route::group(['prefix' => 'helpdesk'], function () {
|
||||||
|
Route::post('create', '\App\Api\v1\ApiController@createTicket');
|
||||||
|
Route::post('reply', '\App\Api\v1\ApiController@ticketReply');
|
||||||
|
Route::post('edit', '\App\Api\v1\ApiController@editTicket');
|
||||||
|
Route::post('delete', '\App\Api\v1\ApiController@deleteTicket');
|
||||||
|
Route::post('assign', '\App\Api\v1\ApiController@assignTicket');
|
||||||
|
Route::get('open', '\App\Api\v1\ApiController@openedTickets');
|
||||||
|
Route::get('unassigned', '\App\Api\v1\ApiController@unassignedTickets');
|
||||||
|
Route::get('closed', '\App\Api\v1\ApiController@closeTickets');
|
||||||
|
Route::get('agents', '\App\Api\v1\ApiController@getAgents');
|
||||||
|
Route::get('teams', '\App\Api\v1\ApiController@getTeams');
|
||||||
|
Route::get('customers', '\App\Api\v1\ApiController@getCustomers');
|
||||||
|
Route::get('customer', '\App\Api\v1\ApiController@getCustomer');
|
||||||
|
Route::get('ticket-search', '\App\Api\v1\ApiController@searchTicket');
|
||||||
|
Route::get('ticket-thread', '\App\Api\v1\ApiController@ticketThreads');
|
||||||
|
Route::get('url', '\App\Api\v1\ApiExceptAuthController@checkUrl');
|
||||||
|
Route::get('check-url', '\App\Api\v1\ApiExceptAuthController@urlResult');
|
||||||
|
Route::get('api_key', '\App\Api\v1\ApiController@generateApiKey');
|
||||||
|
Route::get('help-topic', '\App\Api\v1\ApiController@getHelpTopic');
|
||||||
|
Route::get('sla-plan', '\App\Api\v1\ApiController@getSlaPlan');
|
||||||
|
Route::get('priority', '\App\Api\v1\ApiController@getPriority');
|
||||||
|
Route::get('department', '\App\Api\v1\ApiController@getDepartment');
|
||||||
|
Route::get('tickets', '\App\Api\v1\ApiController@getTickets');
|
||||||
|
Route::get('ticket', '\App\Api\v1\ApiController@getTicketById');
|
||||||
|
Route::get('inbox', '\App\Api\v1\ApiController@inbox');
|
||||||
|
Route::get('trash', '\App\Api\v1\ApiController@getTrash');
|
||||||
|
Route::get('my-tickets-agent', '\App\Api\v1\ApiController@getMyTicketsAgent');
|
||||||
|
Route::post('internal-note', '\App\Api\v1\ApiController@internalNote');
|
||||||
|
/*
|
||||||
|
* Newly added
|
||||||
|
*/
|
||||||
|
Route::get('customers-custom', '\App\Api\v1\ApiController@getCustomersWith');
|
||||||
|
Route::get('collaborator/search', '\App\Api\v1\ApiController@collaboratorSearch');
|
||||||
|
Route::post('collaborator/create', '\App\Api\v1\ApiController@addCollaboratorForTicket');
|
||||||
|
Route::post('collaborator/remove', '\App\Api\v1\ApiController@deleteCollaborator');
|
||||||
|
Route::post('collaborator/get-ticket', '\App\Api\v1\ApiController@getCollaboratorForTicket');
|
||||||
|
Route::get('my-tickets-user', '\App\Api\v1\ApiController@getMyTicketsUser');
|
||||||
|
Route::get('dependency', '\App\Api\v1\ApiController@dependency');
|
||||||
|
Route::post('register', '\App\Api\v1\ApiController@createUser');
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FCM token response
|
||||||
|
*/
|
||||||
|
Route::post('fcmtoken', ['as' => 'fcmtoken', 'uses' => 'Common\PushNotificationController@fcmToken']);
|
||||||
|
});
|
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Controllers\Api\v1;
|
namespace App\Api\v1;
|
||||||
|
|
||||||
use App\Http\Controllers\Agent\helpdesk\TicketController as CoreTicketController;
|
use App\Http\Controllers\Agent\helpdesk\TicketController as CoreTicketController;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Controllers\Api\v1;
|
namespace App\Api\v1;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Controllers\Api\v1;
|
namespace App\Api\v1;
|
||||||
|
|
||||||
// controllers
|
// controllers
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Controllers\Api\v1;
|
namespace App\Api\v1;
|
||||||
|
|
||||||
use App\Http\Controllers\Common\PhpMailController;
|
use App\Http\Controllers\Common\PhpMailController;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Controllers\Api\v1;
|
namespace App\Api\v1;
|
||||||
|
|
||||||
use App\Http\Controllers\Common\PhpMailController;
|
use App\Http\Controllers\Common\PhpMailController;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
@@ -6,13 +6,16 @@ namespace App\Exceptions;
|
|||||||
use Bugsnag;
|
use Bugsnag;
|
||||||
//use Illuminate\Validation\ValidationException;
|
//use Illuminate\Validation\ValidationException;
|
||||||
use Bugsnag\BugsnagLaravel\BugsnagExceptionHandler as ExceptionHandler;
|
use Bugsnag\BugsnagLaravel\BugsnagExceptionHandler as ExceptionHandler;
|
||||||
|
use Config;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Auth\Access\AuthorizationException;
|
|
||||||
// use Symfony\Component\HttpKernel\Exception\HttpException;
|
// use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
// use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
// use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
|
use Illuminate\Auth\Access\AuthorizationException;
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
use Illuminate\Foundation\Validation\ValidationException;
|
use Illuminate\Foundation\Validation\ValidationException as foundation;
|
||||||
use Illuminate\Session\TokenMismatchException;
|
use Illuminate\Session\TokenMismatchException;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
class Handler extends ExceptionHandler
|
class Handler extends ExceptionHandler
|
||||||
@@ -25,11 +28,13 @@ class Handler extends ExceptionHandler
|
|||||||
protected $dontReport = [
|
protected $dontReport = [
|
||||||
// 'Symfony\Component\HttpKernel\Exception\HttpException',
|
// 'Symfony\Component\HttpKernel\Exception\HttpException',
|
||||||
\Illuminate\Http\Exception\HttpResponseException::class,
|
\Illuminate\Http\Exception\HttpResponseException::class,
|
||||||
ValidationException::class,
|
foundation::class,
|
||||||
AuthorizationException::class,
|
AuthorizationException::class,
|
||||||
HttpResponseException::class,
|
HttpResponseException::class,
|
||||||
ModelNotFoundException::class,
|
ModelNotFoundException::class,
|
||||||
\Symfony\Component\HttpKernel\Exception\HttpException::class,
|
\Symfony\Component\HttpKernel\Exception\HttpException::class,
|
||||||
|
ValidationException::class,
|
||||||
|
\DaveJamesMiller\Breadcrumbs\Exception::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,21 +48,37 @@ class Handler extends ExceptionHandler
|
|||||||
*/
|
*/
|
||||||
public function report(Exception $e)
|
public function report(Exception $e)
|
||||||
{
|
{
|
||||||
dd($e);
|
Bugsnag::setBeforeNotifyFunction(function ($error) { //set bugsnag
|
||||||
$debug = \Config::get('app.bugsnag_reporting');
|
return false;
|
||||||
$debug = ($debug) ? 'true' : 'false';
|
});
|
||||||
if ($debug == 'false') {
|
// check if system is running in production environment
|
||||||
Bugsnag::setBeforeNotifyFunction(function ($error) {
|
if (\App::environment() == 'production') {
|
||||||
return false;
|
$debug = Config::get('app.bugsnag_reporting'); //get bugsang reporting preference
|
||||||
});
|
if ($debug) { //if preference is true for reporting
|
||||||
} else {
|
$version = Config::get('app.version'); //set app version in report
|
||||||
$version = \Config::get('app.version');
|
Bugsnag::setAppVersion($version);
|
||||||
Bugsnag::setAppVersion($version);
|
Bugsnag::setBeforeNotifyFunction(function ($error) { //set bugsnag
|
||||||
|
return true;
|
||||||
|
}); //set bugsnag reporting as true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::report($e);
|
return parent::report($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a validation exception into a JSON response.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Illuminate\Validation\ValidationException $exception
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\JsonResponse
|
||||||
|
*/
|
||||||
|
protected function invalidJson($request, ValidationException $exception)
|
||||||
|
{
|
||||||
|
return response()->json($exception->errors(), $exception->status);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render an exception into an HTTP response.
|
* Render an exception into an HTTP response.
|
||||||
*
|
*
|
||||||
@@ -75,6 +96,14 @@ class Handler extends ExceptionHandler
|
|||||||
return response()->json(['message' => $e->getMessage(), 'code' => $e->getStatusCode()]);
|
return response()->json(['message' => $e->getMessage(), 'code' => $e->getStatusCode()]);
|
||||||
case $e instanceof \Tymon\JWTAuth\Exceptions\TokenInvalidException:
|
case $e instanceof \Tymon\JWTAuth\Exceptions\TokenInvalidException:
|
||||||
return response()->json(['message' => $e->getMessage(), 'code' => $e->getStatusCode()]);
|
return response()->json(['message' => $e->getMessage(), 'code' => $e->getStatusCode()]);
|
||||||
|
case $e instanceof TokenMismatchException:
|
||||||
|
if ($request->ajax() || $request->wantsJson()) {
|
||||||
|
$result = ['fails' => \Lang::get('lang.session-expired')];
|
||||||
|
|
||||||
|
return response()->json(compact('result'), 402);
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->back()->with('fails', \Lang::get('lang.session-expired'));
|
||||||
default:
|
default:
|
||||||
return $this->common($request, $e);
|
return $this->common($request, $e);
|
||||||
}
|
}
|
||||||
@@ -92,11 +121,13 @@ class Handler extends ExceptionHandler
|
|||||||
{
|
{
|
||||||
if (config('app.debug') == true) {
|
if (config('app.debug') == true) {
|
||||||
return parent::render($request, $e);
|
return parent::render($request, $e);
|
||||||
} elseif ($e instanceof ValidationException) {
|
} elseif ($e instanceof foundation) {
|
||||||
|
return parent::render($request, $e);
|
||||||
|
} elseif ($e instanceof \Illuminate\Validation\ValidationException) {
|
||||||
return parent::render($request, $e);
|
return parent::render($request, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->view('errors.500');
|
return response()->view('errors.500');
|
||||||
//return redirect()->route('error500', []);
|
//return redirect()->route('error500', []);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +143,7 @@ class Handler extends ExceptionHandler
|
|||||||
{
|
{
|
||||||
$seg = $request->segments();
|
$seg = $request->segments();
|
||||||
if (in_array('api', $seg)) {
|
if (in_array('api', $seg)) {
|
||||||
return response()->json(['status' => '404']);
|
return response()->json(['success' => false, 'message' => trans('lang.invalid_attempt')], 404);
|
||||||
}
|
}
|
||||||
if (config('app.debug') == true) {
|
if (config('app.debug') == true) {
|
||||||
if ($e->getStatusCode() == '404') {
|
if ($e->getStatusCode() == '404') {
|
||||||
@@ -174,7 +205,22 @@ class Handler extends ExceptionHandler
|
|||||||
// return parent::render($request, $e);
|
// return parent::render($request, $e);
|
||||||
// }
|
// }
|
||||||
case $e instanceof TokenMismatchException:
|
case $e instanceof TokenMismatchException:
|
||||||
|
if ($request->ajax() || $request->wantsJson()) {
|
||||||
|
$result = ['fails' => \Lang::get('lang.session-expired')];
|
||||||
|
|
||||||
|
return response()->json(compact('result'), 402);
|
||||||
|
}
|
||||||
|
|
||||||
return redirect()->back()->with('fails', \Lang::get('lang.session-expired'));
|
return redirect()->back()->with('fails', \Lang::get('lang.session-expired'));
|
||||||
|
case $e instanceof AuthorizationException:
|
||||||
|
return redirect('/')->with('fails', \Lang::get('lang.access-denied'));
|
||||||
|
case $e instanceof MethodNotAllowedHttpException:
|
||||||
|
if (stripos($request->url(), 'api')) {
|
||||||
|
$result = ['message' => \Lang::get('lang.methon_not_allowed'), 'success' => false];
|
||||||
|
|
||||||
|
return response()->json($result, 405);
|
||||||
|
}
|
||||||
|
$this->render500($request, $e);
|
||||||
default:
|
default:
|
||||||
return $this->render500($request, $e);
|
return $this->render500($request, $e);
|
||||||
}
|
}
|
||||||
|
@@ -187,7 +187,7 @@ return [
|
|||||||
App\FaveoLog\LaravelLogViewerServiceProvider::class,
|
App\FaveoLog\LaravelLogViewerServiceProvider::class,
|
||||||
App\FaveoStorage\StorageServiceProvider::class,
|
App\FaveoStorage\StorageServiceProvider::class,
|
||||||
Yajra\Datatables\DatatablesServiceProvider::class,
|
Yajra\Datatables\DatatablesServiceProvider::class,
|
||||||
|
\App\Api\ApiServiceProvider::class,
|
||||||
],
|
],
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
@@ -696,68 +696,7 @@ Route::group(['middleware' => ['web']], function () {
|
|||||||
Route::get('/inbox/data', ['as' => 'api.inbox', 'uses' => 'Agent\helpdesk\TicketController@get_inbox']);
|
Route::get('/inbox/data', ['as' => 'api.inbox', 'uses' => 'Agent\helpdesk\TicketController@get_inbox']);
|
||||||
// Route::get('/report', 'HomeController@getreport');
|
// Route::get('/report', 'HomeController@getreport');
|
||||||
// Route::get('/reportdata', 'HomeController@pushdata');
|
// Route::get('/reportdata', 'HomeController@pushdata');
|
||||||
/*
|
|
||||||
* ================================================================================================
|
|
||||||
* @version v1
|
|
||||||
* @access public
|
|
||||||
* @copyright (c) 2016, Ladybird web solution
|
|
||||||
* @author Vijay Sebastian<vijay.sebastian@ladybirdweb.com>
|
|
||||||
* @name Faveo
|
|
||||||
*/
|
|
||||||
Route::group(['prefix' => 'api/v1'], function () {
|
|
||||||
Route::post('authenticate', 'Api\v1\TokenAuthController@authenticate');
|
|
||||||
Route::get('authenticate/user', 'Api\v1\TokenAuthController@getAuthenticatedUser');
|
|
||||||
Route::get('/database-config', ['as' => 'database-config', 'uses' => 'Api\v1\InstallerApiController@config_database']);
|
|
||||||
Route::get('/system-config', ['as' => 'database-config', 'uses' => 'Api\v1\InstallerApiController@config_system']);
|
|
||||||
/*
|
|
||||||
* Helpdesk
|
|
||||||
*/
|
|
||||||
Route::group(['prefix' => 'helpdesk'], function () {
|
|
||||||
Route::post('create', 'Api\v1\ApiController@createTicket');
|
|
||||||
Route::post('reply', 'Api\v1\ApiController@ticketReply');
|
|
||||||
Route::post('edit', 'Api\v1\ApiController@editTicket');
|
|
||||||
Route::post('delete', 'Api\v1\ApiController@deleteTicket');
|
|
||||||
Route::post('assign', 'Api\v1\ApiController@assignTicket');
|
|
||||||
Route::get('open', 'Api\v1\ApiController@openedTickets');
|
|
||||||
Route::get('unassigned', 'Api\v1\ApiController@unassignedTickets');
|
|
||||||
Route::get('closed', 'Api\v1\ApiController@closeTickets');
|
|
||||||
Route::get('agents', 'Api\v1\ApiController@getAgents');
|
|
||||||
Route::get('teams', 'Api\v1\ApiController@getTeams');
|
|
||||||
Route::get('customers', 'Api\v1\ApiController@getCustomers');
|
|
||||||
Route::get('customer', 'Api\v1\ApiController@getCustomer');
|
|
||||||
Route::get('ticket-search', 'Api\v1\ApiController@searchTicket');
|
|
||||||
Route::get('ticket-thread', 'Api\v1\ApiController@ticketThreads');
|
|
||||||
Route::get('url', 'Api\v1\ApiExceptAuthController@checkUrl');
|
|
||||||
Route::get('check-url', 'Api\v1\ApiExceptAuthController@urlResult');
|
|
||||||
Route::get('api_key', 'Api\v1\ApiController@generateApiKey');
|
|
||||||
Route::get('help-topic', 'Api\v1\ApiController@getHelpTopic');
|
|
||||||
Route::get('sla-plan', 'Api\v1\ApiController@getSlaPlan');
|
|
||||||
Route::get('priority', 'Api\v1\ApiController@getPriority');
|
|
||||||
Route::get('department', 'Api\v1\ApiController@getDepartment');
|
|
||||||
Route::get('tickets', 'Api\v1\ApiController@getTickets');
|
|
||||||
Route::get('ticket', 'Api\v1\ApiController@getTicketById');
|
|
||||||
Route::get('inbox', 'Api\v1\ApiController@inbox');
|
|
||||||
Route::get('trash', 'Api\v1\ApiController@getTrash');
|
|
||||||
Route::get('my-tickets-agent', 'Api\v1\ApiController@getMyTicketsAgent');
|
|
||||||
Route::post('internal-note', 'Api\v1\ApiController@internalNote');
|
|
||||||
/*
|
|
||||||
* Newly added
|
|
||||||
*/
|
|
||||||
Route::get('customers-custom', 'Api\v1\ApiController@getCustomersWith');
|
|
||||||
Route::get('collaborator/search', 'Api\v1\ApiController@collaboratorSearch');
|
|
||||||
Route::post('collaborator/create', 'Api\v1\ApiController@addCollaboratorForTicket');
|
|
||||||
Route::post('collaborator/remove', 'Api\v1\ApiController@deleteCollaborator');
|
|
||||||
Route::post('collaborator/get-ticket', 'Api\v1\ApiController@getCollaboratorForTicket');
|
|
||||||
Route::get('my-tickets-user', 'Api\v1\ApiController@getMyTicketsUser');
|
|
||||||
Route::get('dependency', 'Api\v1\ApiController@dependency');
|
|
||||||
Route::post('register', 'Api\v1\ApiController@createUser');
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
|
||||||
* FCM token response
|
|
||||||
*/
|
|
||||||
Route::post('fcmtoken', ['as' => 'fcmtoken', 'uses' => 'Common\PushNotificationController@fcmToken']);
|
|
||||||
});
|
|
||||||
/*
|
/*
|
||||||
* Update module
|
* Update module
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user