DormantService.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace App\Services;
  3. use App\Interfaces\DormantInterface;
  4. use App\Services\DormantAction\DormantAccountDeletionReminder;
  5. use App\Services\DormantAction\DormantAccountEmailNotifier;
  6. use App\Services\DormantAction\DormantDataRemover;
  7. use App\Services\DormantAction\MemberToDormantAccountMigrator;
  8. class DormantService implements DormantInterface
  9. {
  10. private $callApiService;
  11. private $dormantAccountEmailNotifier;
  12. private $memberToDormantAccountMigrator;
  13. private $dormantAccountDeletionReminder;
  14. private $dormantDataRemover;
  15. public function __construct(
  16. CallApiService $callApiService,
  17. DormantAccountEmailNotifier $dormantAccountEmailNotifier,
  18. MemberToDormantAccountMigrator $memberToDormantAccountMigrator,
  19. DormantAccountDeletionReminder $dormantAccountDeletionReminder,
  20. DormantDataRemover $dormantDataRemover
  21. )
  22. {
  23. $this->callApiService = $callApiService;
  24. $this->dormantAccountEmailNotifier = $dormantAccountEmailNotifier;
  25. $this->memberToDormantAccountMigrator = $memberToDormantAccountMigrator;
  26. $this->dormantAccountDeletionReminder = $dormantAccountDeletionReminder;
  27. $this->dormantDataRemover = $dormantDataRemover;
  28. }
  29. public function execute($gateToken)
  30. {
  31. $setup = $this->getSetup($gateToken);
  32. $this->dormantAccountEmailNotifier->sendNotificationEmail($gateToken, $setup);
  33. $this->memberToDormantAccountMigrator->migrateMemberToDormantAccount($gateToken);
  34. $this->dormantAccountDeletionReminder->sendNotificationEmail($gateToken, $setup);
  35. $this->dormantDataRemover->removeDormantData($gateToken);
  36. }
  37. public function getSetup($gateToken)
  38. {
  39. return $this->callApiService->callApi([
  40. 'url' => 'setup-get',
  41. 'data' => [
  42. 'SetupCode' => 'dormant-default',
  43. ],
  44. 'headers' => [
  45. 'GateToken' => $gateToken
  46. ]
  47. ]);
  48. }
  49. }