Skip to content

Commit

Permalink
Updated single event type to EventTypeName
Browse files Browse the repository at this point in the history
  • Loading branch information
vifer committed Oct 8, 2024
1 parent c8e4011 commit 841c416
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 117 deletions.
6 changes: 3 additions & 3 deletions src/Entities/Simulation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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']),
Expand Down
104 changes: 0 additions & 104 deletions src/Entities/Simulation/SimulationSingleEventType.php

This file was deleted.

6 changes: 3 additions & 3 deletions src/Entities/SimulationRun.php
Original file line number Diff line number Diff line change
Expand Up @@ -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\SimulationRun\SimulationRunStatus;

class SimulationRun implements Entity
Expand All @@ -16,7 +16,7 @@ class SimulationRun implements Entity
private function __construct(
public string $id,
public SimulationRunStatus $status,
public SimulationSingleEventType|SimulationScenarioType $type,
public EventTypeName|SimulationScenarioType $type,
public \DateTimeInterface $createdAt,
public \DateTimeInterface $updatedAt,
public array $events,
Expand All @@ -28,7 +28,7 @@ public static function from(array $data): self
return new self(
id: $data['id'],
status: SimulationRunStatus::from($data['status']),
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']),
createdAt: DateTime::from($data['created_at']),
updatedAt: DateTime::from($data['updated_at']),
events: array_map(fn (array $event): SimulationRunEvent => SimulationRunEvent::from($event), $data['events'] ?? []),
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/Simulations/Operations/CreateSimulation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(),
) {
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/Simulations/Operations/UpdateSimulation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)),
),
Expand Down Expand Up @@ -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)),
Expand Down

0 comments on commit 841c416

Please sign in to comment.