From 841c4163ec410ed8655076f1e2fdcc24870b7d67 Mon Sep 17 00:00:00 2001 From: Victor Fernandez Saborit Date: Tue, 8 Oct 2024 16:14:16 +0200 Subject: [PATCH] Updated single event type to EventTypeName --- src/Entities/Simulation.php | 6 +- .../Simulation/SimulationSingleEventType.php | 104 ------------------ src/Entities/SimulationRun.php | 6 +- .../Operations/CreateSimulation.php | 4 +- .../Operations/UpdateSimulation.php | 4 +- .../Simulations/SimulationsClientTest.php | 6 +- 6 files changed, 13 insertions(+), 117 deletions(-) delete mode 100644 src/Entities/Simulation/SimulationSingleEventType.php diff --git a/src/Entities/Simulation.php b/src/Entities/Simulation.php index 81427b6..e2c0001 100644 --- a/src/Entities/Simulation.php +++ b/src/Entities/Simulation.php @@ -4,8 +4,8 @@ namespace Paddle\SDK\Entities; +use Paddle\SDK\Entities\Event\EventTypeName; use Paddle\SDK\Entities\Simulation\SimulationScenarioType; -use Paddle\SDK\Entities\Simulation\SimulationSingleEventType; use Paddle\SDK\Entities\Simulation\SimulationStatus; use Paddle\SDK\Notifications\Entities\Entity as NotificationEntity; use Paddle\SDK\Notifications\Entities\EntityFactory; @@ -17,7 +17,7 @@ private function __construct( public SimulationStatus $status, public string $notificationSettingId, public string $name, - public SimulationSingleEventType|SimulationScenarioType $type, + public EventTypeName|SimulationScenarioType $type, public NotificationEntity|null $payload, public \DateTimeInterface|null $lastRunAt, public \DateTimeInterface $createdAt, @@ -32,7 +32,7 @@ public static function from(array $data): self status: SimulationStatus::from($data['status']), notificationSettingId: $data['notification_setting_id'], name: $data['name'], - type: SimulationSingleEventType::from($data['type'])->isKnown() ? SimulationSingleEventType::from($data['type']) : SimulationScenarioType::from($data['type']), + type: EventTypeName::from($data['type'])->isKnown() ? EventTypeName::from($data['type']) : SimulationScenarioType::from($data['type']), payload: $data['payload'] ? EntityFactory::create($data['type'], $data['payload']) : null, lastRunAt: isset($data['last_run_at']) ? DateTime::from($data['last_run_at']) : null, createdAt: DateTime::from($data['created_at']), diff --git a/src/Entities/Simulation/SimulationSingleEventType.php b/src/Entities/Simulation/SimulationSingleEventType.php deleted file mode 100644 index eb475ef..0000000 --- a/src/Entities/Simulation/SimulationSingleEventType.php +++ /dev/null @@ -1,104 +0,0 @@ -isKnown() ? SimulationSingleEventType::from($data['type']) : SimulationScenarioType::from($data['type']), + type: EventTypeName::from($data['type'])->isKnown() ? EventTypeName::from($data['type']) : SimulationScenarioType::from($data['type']), createdAt: DateTime::from($data['created_at']), updatedAt: DateTime::from($data['updated_at']), events: array_map(fn (array $event): SimulationRunEvent => SimulationRunEvent::from($event), $data['events'] ?? []), diff --git a/src/Resources/Simulations/Operations/CreateSimulation.php b/src/Resources/Simulations/Operations/CreateSimulation.php index aabd005..bccaf60 100644 --- a/src/Resources/Simulations/Operations/CreateSimulation.php +++ b/src/Resources/Simulations/Operations/CreateSimulation.php @@ -4,8 +4,8 @@ namespace Paddle\SDK\Resources\Simulations\Operations; +use Paddle\SDK\Entities\Event\EventTypeName; use Paddle\SDK\Entities\Simulation\SimulationScenarioType; -use Paddle\SDK\Entities\Simulation\SimulationSingleEventType; use Paddle\SDK\FiltersUndefined; use Paddle\SDK\Notifications\Entities\Entity as NotificationEntity; use Paddle\SDK\Undefined; @@ -16,7 +16,7 @@ class CreateSimulation implements \JsonSerializable public function __construct( public readonly string $notificationSettingId, - public readonly SimulationSingleEventType|SimulationScenarioType $type, + public readonly EventTypeName|SimulationScenarioType $type, public readonly string $name, public readonly NotificationEntity|Undefined $payload = new Undefined(), ) { diff --git a/src/Resources/Simulations/Operations/UpdateSimulation.php b/src/Resources/Simulations/Operations/UpdateSimulation.php index 13a0241..de2cc97 100644 --- a/src/Resources/Simulations/Operations/UpdateSimulation.php +++ b/src/Resources/Simulations/Operations/UpdateSimulation.php @@ -4,8 +4,8 @@ namespace Paddle\SDK\Resources\Simulations\Operations; +use Paddle\SDK\Entities\Event\EventTypeName; use Paddle\SDK\Entities\Simulation\SimulationScenarioType; -use Paddle\SDK\Entities\Simulation\SimulationSingleEventType; use Paddle\SDK\Entities\Simulation\SimulationStatus; use Paddle\SDK\FiltersUndefined; use Paddle\SDK\Notifications\Entities\Entity as NotificationEntity; @@ -17,7 +17,7 @@ class UpdateSimulation implements \JsonSerializable public function __construct( public readonly string|Undefined $notificationSettingId = new Undefined(), - public readonly SimulationSingleEventType|SimulationScenarioType|Undefined $type = new Undefined(), + public readonly EventTypeName|SimulationScenarioType|Undefined $type = new Undefined(), public readonly string|Undefined $name = new Undefined(), public readonly SimulationStatus|Undefined $status = new Undefined(), public readonly NotificationEntity|Undefined|null $payload = new Undefined(), diff --git a/tests/Functional/Resources/Simulations/SimulationsClientTest.php b/tests/Functional/Resources/Simulations/SimulationsClientTest.php index 1c61cc5..7477ac3 100644 --- a/tests/Functional/Resources/Simulations/SimulationsClientTest.php +++ b/tests/Functional/Resources/Simulations/SimulationsClientTest.php @@ -7,7 +7,7 @@ use GuzzleHttp\Psr7\Response; use Http\Mock\Client as MockClient; use Paddle\SDK\Client; -use Paddle\SDK\Entities\Simulation\SimulationSingleEventType; +use Paddle\SDK\Entities\Event\EventTypeName; use Paddle\SDK\Entities\Simulation\SimulationStatus; use Paddle\SDK\Environment; use Paddle\SDK\Notifications\Entities\EntityFactory; @@ -63,7 +63,7 @@ public static function createOperationsProvider(): \Generator yield 'Basic Create' => [ new CreateSimulation( notificationSettingId: 'ntfset_01j82d983j814ypzx7m1fw2jpz', - type: SimulationSingleEventType::AddressCreated(), + type: EventTypeName::AddressCreated(), name: 'New US address created for CRM', payload: EntityFactory::create('address.created', json_decode(self::readRawJsonFixture('request/address_created_payload'), true)), ), @@ -112,7 +112,7 @@ public static function updateOperationsProvider(): \Generator yield 'Update All' => [ new UpdateSimulation( notificationSettingId: 'ntfset_01j82d983j814ypzx7m1fw2jpz', - type: SimulationSingleEventType::AdjustmentUpdated(), + type: EventTypeName::AdjustmentUpdated(), name: 'Refund approved', status: SimulationStatus::Active(), payload: EntityFactory::create('adjustment.updated', json_decode(self::readRawJsonFixture('request/adjustment_updated_payload'), true)),