Skip to content

Commit 7c27171

Browse files
authored
Merge pull request #3 from GCDTech/feature/OnCustomerDeleted
Added on Customer Deleted
2 parents 597ddad + 2a5a876 commit 7c27171

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/Commands/PushDeletedToCyclopsCommand.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ abstract class PushDeletedToCyclopsCommand extends PushStateToCyclopsCommand
99
final function executeUseCase()
1010
{
1111
$pushUseCase = new PushDeletedToCyclopsUseCase($this->getService());
12-
$pushUseCase->execute($this->getList());
12+
$pushUseCase->execute($this->getList(), $this->onCustomerDeleted());
1313
}
14+
15+
abstract protected function onCustomerDeleted(): callable;
1416
}

src/UseCases/PushDeletedToCyclopsUseCase.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ public function __construct(CyclopsService $cyclopsService)
1818
$this->cyclopsService = $cyclopsService;
1919
}
2020

21-
public function execute(CyclopsCustomerListEntity $list)
21+
public function execute(CyclopsCustomerListEntity $list, callable $onCustomerDeleted)
2222
{
2323
foreach ($list->items as $item) {
2424
try {
2525
$this->cyclopsService->deleteCustomer($item->identity);
26+
$onCustomerDeleted($item);
2627
} catch (CyclopsException $exception) {
2728
}
2829
}

src/UseCases/PushStaleToCyclopsUseCase.php

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public function execute(CyclopsCustomerListEntity $list, callable $onCustomerCre
2323
foreach ($list->items as $item) {
2424
try {
2525
$this->cyclopsService->setBrandOptInStatus($item);
26+
27+
$onCustomerCreated($item);
2628
} catch (CustomerNotFoundException $exception) {
2729
$customer = $this->cyclopsService->loadCustomer($item->identity);
2830
$customer->brandOptIn = $item->brandOptIn;

0 commit comments

Comments
 (0)