SHARE
TWEET

AuthorizationService

mbskot May 20th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. declare(strict_types=1);
  3.  
  4. namespace App\Blockchain\Services\Withdrawal;
  5.  
  6. use App\Blockchain\Domain\Withdrawal\Process\AuthorizationMethodResolver;
  7. use App\Blockchain\Domain\Withdrawal\Process\WithdrawalProcessNotFoundException;
  8. use App\Blockchain\Domain\Withdrawal\Process\WithdrawalProcessRepository;
  9. use App\Services\AtomicExecutor;
  10.  
  11. final class AuthorizeWithdrawalService
  12. {
  13.     /**
  14.      * @var AtomicExecutor
  15.      */
  16.     private $atomicExecutor;
  17.     /**
  18.      * @var AuthorizationMethodResolver
  19.      */
  20.     private $authorizationMethodResolver;
  21.     /**
  22.      * @var WithdrawalProcessRepository
  23.      */
  24.     private $withdrawalProcessRepository;
  25.  
  26.     public function __construct(
  27.         AtomicExecutor $atomicExecutor,
  28.         AuthorizationMethodResolver $authorizationMethodResolver,
  29.         WithdrawalProcessRepository $withdrawalProcessRepository
  30.     ) {
  31.         $this->atomicExecutor = $atomicExecutor;
  32.         $this->authorizationMethodResolver = $authorizationMethodResolver;
  33.         $this->withdrawalProcessRepository = $withdrawalProcessRepository;
  34.     }
  35.  
  36.     /**
  37.      * @throws WithdrawalProcessNotFoundException
  38.      */
  39.     public function execute(AuthorizeWithdrawal $request): void
  40.     {
  41.         $do = function () use ($request): void {
  42.             $withdrawalProcess = $this->withdrawalProcessRepository
  43.                 ->getWithdrawalProcessById($request->getWithdrawalProcessId());
  44.  
  45.             $authorizationProvider = $this->authorizationMethodResolver
  46.                 ->getAuthorizationProviderByUser($withdrawalProcess->getCreatedBy());
  47.  
  48.             $withdrawalProcess->requestAuthorization($authorizationProvider);
  49.         };
  50.  
  51.         $this->atomicExecutor->execute($do);
  52.     }
  53. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top