mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-21 05:24:01 +00:00
Merge branch 'dillon/45-air-shipment-update-with-master' into development
This commit is contained in:
@@ -72,6 +72,7 @@ class UpdateDoFromYDPortalProcessor
|
||||
|
||||
|
||||
} catch (\Exception $exception){
|
||||
log::debug($exception);
|
||||
throw new InternalServerErrorException('failed to approve address due to an error related to YD portal');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ namespace App\Classes\Modules\WePost\ControllersLogic;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\WePost\Services\CreatesWePostNotification;
|
||||
use App\Classes\Modules\WePost\DataTransferObjects\WePostNotificationObject;
|
||||
use App\Classes\Modules\WePost\DataTransferObjects\WePostProcessNotificationObject;
|
||||
use App\Classes\Modules\WePost\Standards\Rules\CanProcessWePostNotification;
|
||||
use App\Http\Resources\WePostNotificationResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -24,14 +26,19 @@ class ProcessWePostNotificationLogic extends AbstractControllerLogic
|
||||
/** @var CreatesWePostNotification */
|
||||
private $createsWePostNotification;
|
||||
|
||||
/** @var CanProcessWePostNotification */
|
||||
private $canProcessWePostNotification;
|
||||
|
||||
/**
|
||||
* ProcessWePostNotificationLogic constructor.
|
||||
* @param CreatesWePostNotification $createsWePostNotification
|
||||
* @param CanProcessWePostNotification $canProcessWePostNotification
|
||||
*/
|
||||
public function __construct(
|
||||
CreatesWePostNotification $createsWePostNotification)
|
||||
CreatesWePostNotification $createsWePostNotification, CanProcessWePostNotification $canProcessWePostNotification)
|
||||
{
|
||||
$this->createsWePostNotification = $createsWePostNotification;
|
||||
$this->canProcessWePostNotification = $canProcessWePostNotification;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,6 +50,9 @@ class ProcessWePostNotificationLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new WePostProcessNotificationObject($request->query('api-key'));
|
||||
$this->canProcessWePostNotification->passes($object);
|
||||
|
||||
$request->merge([
|
||||
'isApiPub' => true,
|
||||
]);
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\WePost\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
|
||||
class WePostProcessNotificationObject implements DataTransferObject
|
||||
{
|
||||
/** @var string */
|
||||
private string $token;
|
||||
|
||||
/**
|
||||
* WePostProcessNotificationObject constructor.
|
||||
* @param string $token
|
||||
*/
|
||||
public function __construct(
|
||||
string $token
|
||||
) {
|
||||
$this->token = $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getToken(): string
|
||||
{
|
||||
return $this->token;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\WePost\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Models\PersonalAccessTokens;
|
||||
|
||||
class CanProcessWePostNotification extends AbstractRule
|
||||
{
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
$personalAccessToken = PersonalAccessTokens::where('token', $object->getToken())->first();
|
||||
if($personalAccessToken){
|
||||
$abilities = json_decode($personalAccessToken->abilities, true);
|
||||
if (in_array('process notification', $abilities)|| in_array('*', $abilities)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,6 +9,7 @@ Route::group(['middleware' => 'apipub', 'prefix' => 'v1', 'as' => 'apipub.'], fu
|
||||
Route::get('transactions/mappable/query', 'Transactions\ListMappableTransactionsController@list')->name('transaction.mappable.list');
|
||||
Route::get('groups/query', 'Transactions\ListGroupsController@list')->name('group.list');
|
||||
|
||||
//this is used on PerfexCRM
|
||||
Route::group(['prefix' => 'feedback', 'as' => 'feedback.', 'namespace' => 'HelpMenu'], function () {
|
||||
Route::post('/generate', 'GenerateFeedbackUrlController@generate')->name('feedback.url.generate');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user