diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index b9f1624..4cd8e0e 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -36,7 +36,8 @@ 'concat_space' => [ 'spacing' => 'one', ], - 'self_accessor' => true, + // Disable self_accessor to allow self intersection return types. + // 'self_accessor' => true, 'nullable_type_declaration' => ['syntax' => 'union'], 'ordered_types' => [ 'null_adjustment' => 'always_last', diff --git a/examples/webhook_verification_PSR7.php b/examples/webhook_verification_PSR7.php index 9e25cd2..92a3010 100644 --- a/examples/webhook_verification_PSR7.php +++ b/examples/webhook_verification_PSR7.php @@ -11,6 +11,8 @@ */ use GuzzleHttp\Psr7\ServerRequest; +use Paddle\SDK\Entities\Event; +use Paddle\SDK\Notifications\Notification\TransactionUpdatedNotification; use Paddle\SDK\Notifications\Secret; use Paddle\SDK\Notifications\Verifier; @@ -21,6 +23,16 @@ if ($isVerified) { echo "Webhook is verified\n"; + + $notification = Event::notificationFromRequest($request); + $notification_id = $notification->getNotificationId(); + $eventId = $notification->eventId; + $eventType = $notification->eventType; + $occurredAt = $notification->occurredAt; + + if ($notification instanceof TransactionUpdatedNotification) { + $transactionId = $notification->transaction->id; + } } else { echo "Webhook is not verified\n"; } diff --git a/src/Entities/Event.php b/src/Entities/Event.php index 92bd3a1..ce630e1 100644 --- a/src/Entities/Event.php +++ b/src/Entities/Event.php @@ -6,52 +6,98 @@ use Paddle\SDK\Entities\Event\EventTypeName; use Paddle\SDK\Notifications\Entities\Entity as NotificationEntity; +use Paddle\SDK\Notifications\Notification\NotificationInterface; +use Psr\Http\Message\ServerRequestInterface; abstract class Event implements Entity { - /** - * @internal - */ protected function __construct( - public string $eventId, - public EventTypeName $eventType, - public \DateTimeInterface $occurredAt, - public NotificationEntity $data, + public readonly string $eventId, + public readonly EventTypeName $eventType, + public readonly \DateTimeInterface $occurredAt, + public readonly NotificationEntity $data, ) { } - public static function from(array $data): self + private static function entityFrom(array $data): NotificationEntity { $type = explode('.', (string) $data['event_type']); $entity = $type[0] ?? 'Unknown'; $identifier = str_replace('_', '', ucwords(implode('_', $type), '_')); - /** @var class-string $entity */ + /** @var class-string $entity */ + $entity = sprintf('\Paddle\SDK\Notifications\Entities\%s', ucfirst($entity)); + + if (! class_exists($entity) || ! in_array(NotificationEntity::class, class_implements($entity), true)) { + throw new \UnexpectedValueException("Event type '{$identifier}' cannot be mapped to an object"); + } + + return $entity::from($data['data']); + } + + public static function identifierFrom(array $data): string + { + $type = explode('.', (string) $data['event_type']); + + return str_replace('_', '', ucwords(implode('_', $type), '_')); + } + + public static function from(array $data): self + { + $identifier = self::identifierFrom($data); + + /** @var class-string $event */ $event = sprintf('\Paddle\SDK\Notifications\Events\%s', $identifier); if (! class_exists($event) || ! is_subclass_of($event, self::class)) { throw new \UnexpectedValueException("Event type '{$identifier}' cannot be mapped to an object"); } - /** @var class-string $entity */ - $entity = sprintf('\Paddle\SDK\Notifications\Entities\%s', ucfirst($entity)); + return $event::fromEvent( + $data['event_id'], + EventTypeName::from($data['event_type']), + DateTime::from($data['occurred_at']), + self::entityFrom($data), + ); + } - if (! class_exists($entity) || ! in_array(NotificationEntity::class, class_implements($entity), true)) { + public static function notificationFrom(array $data): Event&NotificationInterface + { + $identifier = self::identifierFrom($data); + + /** @var class-string $notification */ + $notification = sprintf('\Paddle\SDK\Notifications\Notification\%sNotification', $identifier); + + if ( + ! class_exists($notification) + || ! is_subclass_of($notification, self::class) + || ! is_subclass_of($notification, NotificationInterface::class) + ) { throw new \UnexpectedValueException("Event type '{$identifier}' cannot be mapped to an object"); } - return $event::fromEvent( + return $notification::fromNotification( $data['event_id'], EventTypeName::from($data['event_type']), DateTime::from($data['occurred_at']), - $entity::from($data['data']), + self::entityFrom($data), + $data['notification_id'], ); } + public static function notificationFromRequest(ServerRequestInterface $request): Event&NotificationInterface + { + return self::notificationFrom(json_decode( + (string) $request->getBody(), + true, + JSON_THROW_ON_ERROR, + )); + } + abstract public static function fromEvent( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, NotificationEntity $data, - ): static; + ): self; } diff --git a/src/Entities/Notification.php b/src/Entities/Notification.php index 50446b1..3ec7f29 100644 --- a/src/Entities/Notification.php +++ b/src/Entities/Notification.php @@ -7,6 +7,7 @@ use Paddle\SDK\Entities\Event\EventTypeName; use Paddle\SDK\Entities\Notification\NotificationOrigin; use Paddle\SDK\Entities\Notification\NotificationStatus; +use Paddle\SDK\Notifications\Notification\NotificationInterface; class Notification implements Entity { @@ -14,7 +15,7 @@ private function __construct( public string $id, public EventTypeName $type, public NotificationStatus $status, - public Event $payload, + public Event&NotificationInterface $payload, public \DateTimeInterface $occurredAt, public \DateTimeInterface|null $deliveredAt, public \DateTimeInterface|null $replayedAt, @@ -32,7 +33,7 @@ public static function from(array $data): self $data['id'], EventTypeName::from($data['type']), NotificationStatus::from($data['status']), - Event::from($data['payload']), + Event::notificationFrom($data['payload']), DateTime::from($data['occurred_at']), isset($data['delivered_at']) ? DateTime::from($data['delivered_at']) : null, isset($data['replayed_at']) ? DateTime::from($data['replayed_at']) : null, diff --git a/src/Notifications/Events/AddressCreated.php b/src/Notifications/Events/AddressCreated.php index aab43b4..8f61b4a 100644 --- a/src/Notifications/Events/AddressCreated.php +++ b/src/Notifications/Events/AddressCreated.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Address; use Paddle\SDK\Notifications\Entities\Entity; -final class AddressCreated extends Event +class AddressCreated extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Address $data, + public readonly Address $address, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $address); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/AddressUpdated.php b/src/Notifications/Events/AddressUpdated.php index 5f6eb9b..e778614 100644 --- a/src/Notifications/Events/AddressUpdated.php +++ b/src/Notifications/Events/AddressUpdated.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Address; use Paddle\SDK\Notifications\Entities\Entity; -final class AddressUpdated extends Event +class AddressUpdated extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Address $data, + public readonly Address $address, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $address); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/AdjustmentCreated.php b/src/Notifications/Events/AdjustmentCreated.php index a9cbb9b..acc0de9 100644 --- a/src/Notifications/Events/AdjustmentCreated.php +++ b/src/Notifications/Events/AdjustmentCreated.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Adjustment; use Paddle\SDK\Notifications\Entities\Entity; -final class AdjustmentCreated extends Event +class AdjustmentCreated extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Adjustment $data, + public readonly Adjustment $adjustment, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $adjustment); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/AdjustmentUpdated.php b/src/Notifications/Events/AdjustmentUpdated.php index 38de8bd..327547a 100644 --- a/src/Notifications/Events/AdjustmentUpdated.php +++ b/src/Notifications/Events/AdjustmentUpdated.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Adjustment; use Paddle\SDK\Notifications\Entities\Entity; -final class AdjustmentUpdated extends Event +class AdjustmentUpdated extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Adjustment $data, + public readonly Adjustment $adjustment, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $adjustment); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/BusinessCreated.php b/src/Notifications/Events/BusinessCreated.php index aaa3166..d940f5c 100644 --- a/src/Notifications/Events/BusinessCreated.php +++ b/src/Notifications/Events/BusinessCreated.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Business; use Paddle\SDK\Notifications\Entities\Entity; -final class BusinessCreated extends Event +class BusinessCreated extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Business $data, + public readonly Business $business, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $business); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/BusinessUpdated.php b/src/Notifications/Events/BusinessUpdated.php index c8cbf0c..9549033 100644 --- a/src/Notifications/Events/BusinessUpdated.php +++ b/src/Notifications/Events/BusinessUpdated.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Business; use Paddle\SDK\Notifications\Entities\Entity; -final class BusinessUpdated extends Event +class BusinessUpdated extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Business $data, + public readonly Business $business, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $business); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/CustomerCreated.php b/src/Notifications/Events/CustomerCreated.php index bcb366a..6767f39 100644 --- a/src/Notifications/Events/CustomerCreated.php +++ b/src/Notifications/Events/CustomerCreated.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Customer; use Paddle\SDK\Notifications\Entities\Entity; -final class CustomerCreated extends Event +class CustomerCreated extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Customer $data, + public readonly Customer $customer, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $customer); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/CustomerUpdated.php b/src/Notifications/Events/CustomerUpdated.php index 23d2749..304d417 100644 --- a/src/Notifications/Events/CustomerUpdated.php +++ b/src/Notifications/Events/CustomerUpdated.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Customer; use Paddle\SDK\Notifications\Entities\Entity; -final class CustomerUpdated extends Event +class CustomerUpdated extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Customer $data, + public readonly Customer $customer, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $customer); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/DiscountCreated.php b/src/Notifications/Events/DiscountCreated.php index eb982ca..5471710 100644 --- a/src/Notifications/Events/DiscountCreated.php +++ b/src/Notifications/Events/DiscountCreated.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Discount; use Paddle\SDK\Notifications\Entities\Entity; -final class DiscountCreated extends Event +class DiscountCreated extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Discount $data, + public readonly Discount $discount, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $discount); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/DiscountImported.php b/src/Notifications/Events/DiscountImported.php index 127450a..fa366c7 100644 --- a/src/Notifications/Events/DiscountImported.php +++ b/src/Notifications/Events/DiscountImported.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Discount; use Paddle\SDK\Notifications\Entities\Entity; -final class DiscountImported extends Event +class DiscountImported extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Discount $data, + public readonly Discount $discount, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $discount); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/DiscountUpdated.php b/src/Notifications/Events/DiscountUpdated.php index 9fb296b..f18f9e1 100644 --- a/src/Notifications/Events/DiscountUpdated.php +++ b/src/Notifications/Events/DiscountUpdated.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Discount; use Paddle\SDK\Notifications\Entities\Entity; -final class DiscountUpdated extends Event +class DiscountUpdated extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Discount $data, + public readonly Discount $discount, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $discount); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/PayoutCreated.php b/src/Notifications/Events/PayoutCreated.php index afa3bb4..f485748 100644 --- a/src/Notifications/Events/PayoutCreated.php +++ b/src/Notifications/Events/PayoutCreated.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Payout; -final class PayoutCreated extends Event +class PayoutCreated extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Payout $data, + public readonly Payout $payout, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $payout); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/PayoutPaid.php b/src/Notifications/Events/PayoutPaid.php index 82bd3dc..d04d5ce 100644 --- a/src/Notifications/Events/PayoutPaid.php +++ b/src/Notifications/Events/PayoutPaid.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Payout; -final class PayoutPaid extends Event +class PayoutPaid extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Payout $data, + public readonly Payout $payout, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $payout); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/PriceCreated.php b/src/Notifications/Events/PriceCreated.php index fa8f870..8acbf1a 100644 --- a/src/Notifications/Events/PriceCreated.php +++ b/src/Notifications/Events/PriceCreated.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Price; -final class PriceCreated extends Event +class PriceCreated extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Price $data, + public readonly Price $price, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $price); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/PriceUpdated.php b/src/Notifications/Events/PriceUpdated.php index a6e8350..ae3cd4b 100644 --- a/src/Notifications/Events/PriceUpdated.php +++ b/src/Notifications/Events/PriceUpdated.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Price; -final class PriceUpdated extends Event +class PriceUpdated extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Price $data, + public readonly Price $price, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $price); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/ProductCreated.php b/src/Notifications/Events/ProductCreated.php index 1be7ad2..166873b 100644 --- a/src/Notifications/Events/ProductCreated.php +++ b/src/Notifications/Events/ProductCreated.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Product; -final class ProductCreated extends Event +class ProductCreated extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Product $data, + public readonly Product $product, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $product); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/ProductUpdated.php b/src/Notifications/Events/ProductUpdated.php index 1b38299..de5a2ef 100644 --- a/src/Notifications/Events/ProductUpdated.php +++ b/src/Notifications/Events/ProductUpdated.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Product; -final class ProductUpdated extends Event +class ProductUpdated extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Product $data, + public readonly Product $product, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $product); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/ReportCreated.php b/src/Notifications/Events/ReportCreated.php index 063081b..637c37c 100644 --- a/src/Notifications/Events/ReportCreated.php +++ b/src/Notifications/Events/ReportCreated.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Report; -final class ReportCreated extends Event +class ReportCreated extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Report $data, + public readonly Report $report, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $report); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/ReportUpdated.php b/src/Notifications/Events/ReportUpdated.php index 15ae4f0..0692511 100644 --- a/src/Notifications/Events/ReportUpdated.php +++ b/src/Notifications/Events/ReportUpdated.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Report; -final class ReportUpdated extends Event +class ReportUpdated extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Report $data, + public readonly Report $report, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $report); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/SubscriptionActivated.php b/src/Notifications/Events/SubscriptionActivated.php index 39746ae..7677c17 100644 --- a/src/Notifications/Events/SubscriptionActivated.php +++ b/src/Notifications/Events/SubscriptionActivated.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Subscription; -final class SubscriptionActivated extends Event +class SubscriptionActivated extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Subscription $data, + public readonly Subscription $subscription, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $subscription); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/SubscriptionCanceled.php b/src/Notifications/Events/SubscriptionCanceled.php index 0d7ee51..5c51f7a 100644 --- a/src/Notifications/Events/SubscriptionCanceled.php +++ b/src/Notifications/Events/SubscriptionCanceled.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Subscription; -final class SubscriptionCanceled extends Event +class SubscriptionCanceled extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Subscription $data, + public readonly Subscription $subscription, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $subscription); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/SubscriptionCreated.php b/src/Notifications/Events/SubscriptionCreated.php index c47ca12..a2f8aa6 100644 --- a/src/Notifications/Events/SubscriptionCreated.php +++ b/src/Notifications/Events/SubscriptionCreated.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Subscription; -final class SubscriptionCreated extends Event +class SubscriptionCreated extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Subscription $data, + public readonly Subscription $subscription, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $subscription); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/SubscriptionImported.php b/src/Notifications/Events/SubscriptionImported.php index f228530..feb7f53 100644 --- a/src/Notifications/Events/SubscriptionImported.php +++ b/src/Notifications/Events/SubscriptionImported.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Subscription; -final class SubscriptionImported extends Event +class SubscriptionImported extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Subscription $data, + public readonly Subscription $subscription, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $subscription); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/SubscriptionPastDue.php b/src/Notifications/Events/SubscriptionPastDue.php index 8864405..1f80960 100644 --- a/src/Notifications/Events/SubscriptionPastDue.php +++ b/src/Notifications/Events/SubscriptionPastDue.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Subscription; -final class SubscriptionPastDue extends Event +class SubscriptionPastDue extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Subscription $data, + public readonly Subscription $subscription, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $subscription); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/SubscriptionPaused.php b/src/Notifications/Events/SubscriptionPaused.php index 78c3497..56d4f58 100644 --- a/src/Notifications/Events/SubscriptionPaused.php +++ b/src/Notifications/Events/SubscriptionPaused.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Subscription; -final class SubscriptionPaused extends Event +class SubscriptionPaused extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Subscription $data, + public readonly Subscription $subscription, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $subscription); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/SubscriptionResumed.php b/src/Notifications/Events/SubscriptionResumed.php index 9071fee..aeb5f25 100644 --- a/src/Notifications/Events/SubscriptionResumed.php +++ b/src/Notifications/Events/SubscriptionResumed.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Subscription; -final class SubscriptionResumed extends Event +class SubscriptionResumed extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Subscription $data, + public readonly Subscription $subscription, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $subscription); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/SubscriptionTrialing.php b/src/Notifications/Events/SubscriptionTrialing.php index 13519d2..c5fcd7b 100644 --- a/src/Notifications/Events/SubscriptionTrialing.php +++ b/src/Notifications/Events/SubscriptionTrialing.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Subscription; -final class SubscriptionTrialing extends Event +class SubscriptionTrialing extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Subscription $data, + public readonly Subscription $subscription, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $subscription); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/SubscriptionUpdated.php b/src/Notifications/Events/SubscriptionUpdated.php index bb5b526..3b87b15 100644 --- a/src/Notifications/Events/SubscriptionUpdated.php +++ b/src/Notifications/Events/SubscriptionUpdated.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Subscription; -final class SubscriptionUpdated extends Event +class SubscriptionUpdated extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Subscription $data, + public readonly Subscription $subscription, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $subscription); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/TransactionBilled.php b/src/Notifications/Events/TransactionBilled.php index 474e3a5..4c6721c 100644 --- a/src/Notifications/Events/TransactionBilled.php +++ b/src/Notifications/Events/TransactionBilled.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Transaction; -final class TransactionBilled extends Event +class TransactionBilled extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Transaction $data, + public readonly Transaction $transaction, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $transaction); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/TransactionCanceled.php b/src/Notifications/Events/TransactionCanceled.php index cb28a30..eb63977 100644 --- a/src/Notifications/Events/TransactionCanceled.php +++ b/src/Notifications/Events/TransactionCanceled.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Transaction; -final class TransactionCanceled extends Event +class TransactionCanceled extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Transaction $data, + public readonly Transaction $transaction, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $transaction); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/TransactionCompleted.php b/src/Notifications/Events/TransactionCompleted.php index 83d0271..a054c98 100644 --- a/src/Notifications/Events/TransactionCompleted.php +++ b/src/Notifications/Events/TransactionCompleted.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Transaction; -final class TransactionCompleted extends Event +class TransactionCompleted extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Transaction $data, + public readonly Transaction $transaction, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $transaction); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/TransactionCreated.php b/src/Notifications/Events/TransactionCreated.php index ded7eab..3c674a9 100644 --- a/src/Notifications/Events/TransactionCreated.php +++ b/src/Notifications/Events/TransactionCreated.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Transaction; -final class TransactionCreated extends Event +class TransactionCreated extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Transaction $data, + public readonly Transaction $transaction, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $transaction); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/TransactionPaid.php b/src/Notifications/Events/TransactionPaid.php index 1517279..b2f96a1 100644 --- a/src/Notifications/Events/TransactionPaid.php +++ b/src/Notifications/Events/TransactionPaid.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Transaction; -final class TransactionPaid extends Event +class TransactionPaid extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Transaction $data, + public readonly Transaction $transaction, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $transaction); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/TransactionPastDue.php b/src/Notifications/Events/TransactionPastDue.php index 5700484..ec6535f 100644 --- a/src/Notifications/Events/TransactionPastDue.php +++ b/src/Notifications/Events/TransactionPastDue.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Transaction; -final class TransactionPastDue extends Event +class TransactionPastDue extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Transaction $data, + public readonly Transaction $transaction, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $transaction); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/TransactionPaymentFailed.php b/src/Notifications/Events/TransactionPaymentFailed.php index 2eabd3a..b55d45b 100644 --- a/src/Notifications/Events/TransactionPaymentFailed.php +++ b/src/Notifications/Events/TransactionPaymentFailed.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Transaction; -final class TransactionPaymentFailed extends Event +class TransactionPaymentFailed extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Transaction $data, + public readonly Transaction $transaction, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $transaction); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/TransactionReady.php b/src/Notifications/Events/TransactionReady.php index 09fad11..81aae97 100644 --- a/src/Notifications/Events/TransactionReady.php +++ b/src/Notifications/Events/TransactionReady.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Transaction; -final class TransactionReady extends Event +class TransactionReady extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Transaction $data, + public readonly Transaction $transaction, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $transaction); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Events/TransactionUpdated.php b/src/Notifications/Events/TransactionUpdated.php index e2a2caa..70eb16c 100644 --- a/src/Notifications/Events/TransactionUpdated.php +++ b/src/Notifications/Events/TransactionUpdated.php @@ -9,15 +9,15 @@ use Paddle\SDK\Notifications\Entities\Entity; use Paddle\SDK\Notifications\Entities\Transaction; -final class TransactionUpdated extends Event +class TransactionUpdated extends Event { - private function __construct( + protected function __construct( string $eventId, EventTypeName $eventType, \DateTimeInterface $occurredAt, - Transaction $data, + public readonly Transaction $transaction, ) { - parent::__construct($eventId, $eventType, $occurredAt, $data); + parent::__construct($eventId, $eventType, $occurredAt, $transaction); } /** @@ -28,7 +28,7 @@ public static function fromEvent( EventTypeName $eventType, \DateTimeInterface $occurredAt, Entity $data, - ): static { + ): self { return new self($eventId, $eventType, $occurredAt, $data); } } diff --git a/src/Notifications/Notification.php b/src/Notifications/Notification.php new file mode 100644 index 0000000..984f431 --- /dev/null +++ b/src/Notifications/Notification.php @@ -0,0 +1,58 @@ +eventId = $event->eventId; + $this->eventType = $event->eventType; + $this->occurredAt = $event->occurredAt; + } + + public static function fromRequest(ServerRequestInterface $request): self + { + return self::from(json_decode( + (string) $request->getBody(), + true, + JSON_THROW_ON_ERROR, + )); + } + + public static function from(array $data): self + { + $type = explode('.', (string) $data['event_type']); + $identifier = str_replace('_', '', ucwords(implode('_', $type), '_')); + + /** @var class-string $notification */ + $notification = sprintf('\Paddle\SDK\Notifications\Notification\%sNotification', $identifier); + + if (! class_exists($notification) || ! is_subclass_of($notification, self::class)) { + throw new \UnexpectedValueException("Notification type '{$identifier}' cannot be mapped to an object"); + } + + return $notification::fromEvent( + $data['notification_id'], + Event::from($data), + ); + } + + abstract protected static function fromEvent( + string $id, + Event $event, + ): static; +} diff --git a/src/Notifications/Notification/AddressCreatedNotification.php b/src/Notifications/Notification/AddressCreatedNotification.php new file mode 100644 index 0000000..2e38c73 --- /dev/null +++ b/src/Notifications/Notification/AddressCreatedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param Address $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/AddressUpdatedNotification.php b/src/Notifications/Notification/AddressUpdatedNotification.php new file mode 100644 index 0000000..a9be81a --- /dev/null +++ b/src/Notifications/Notification/AddressUpdatedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Address) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/AdjustmentCreatedNotification.php b/src/Notifications/Notification/AdjustmentCreatedNotification.php new file mode 100644 index 0000000..dc60431 --- /dev/null +++ b/src/Notifications/Notification/AdjustmentCreatedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Adjustment) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/AdjustmentUpdatedNotification.php b/src/Notifications/Notification/AdjustmentUpdatedNotification.php new file mode 100644 index 0000000..40ce411 --- /dev/null +++ b/src/Notifications/Notification/AdjustmentUpdatedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Adjustment) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/BusinessCreatedNotification.php b/src/Notifications/Notification/BusinessCreatedNotification.php new file mode 100644 index 0000000..00d32be --- /dev/null +++ b/src/Notifications/Notification/BusinessCreatedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Business) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/BusinessUpdatedNotification.php b/src/Notifications/Notification/BusinessUpdatedNotification.php new file mode 100644 index 0000000..7fcd5cb --- /dev/null +++ b/src/Notifications/Notification/BusinessUpdatedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param Business $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/CustomerCreatedNotification.php b/src/Notifications/Notification/CustomerCreatedNotification.php new file mode 100644 index 0000000..d706033 --- /dev/null +++ b/src/Notifications/Notification/CustomerCreatedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Customer) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/CustomerUpdatedNotification.php b/src/Notifications/Notification/CustomerUpdatedNotification.php new file mode 100644 index 0000000..a42d58c --- /dev/null +++ b/src/Notifications/Notification/CustomerUpdatedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Customer) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/DiscountCreatedNotification.php b/src/Notifications/Notification/DiscountCreatedNotification.php new file mode 100644 index 0000000..74611c3 --- /dev/null +++ b/src/Notifications/Notification/DiscountCreatedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Discount) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/DiscountImportedNotification.php b/src/Notifications/Notification/DiscountImportedNotification.php new file mode 100644 index 0000000..c600154 --- /dev/null +++ b/src/Notifications/Notification/DiscountImportedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Discount) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/DiscountUpdatedNotification.php b/src/Notifications/Notification/DiscountUpdatedNotification.php new file mode 100644 index 0000000..dbd08b2 --- /dev/null +++ b/src/Notifications/Notification/DiscountUpdatedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Discount) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/NotificationInterface.php b/src/Notifications/Notification/NotificationInterface.php new file mode 100644 index 0000000..8191b04 --- /dev/null +++ b/src/Notifications/Notification/NotificationInterface.php @@ -0,0 +1,22 @@ +notification_id; + } + + /** + * @param (Payout) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/PayoutPaidNotification.php b/src/Notifications/Notification/PayoutPaidNotification.php new file mode 100644 index 0000000..cd353eb --- /dev/null +++ b/src/Notifications/Notification/PayoutPaidNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Payout) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/PriceCreatedNotification.php b/src/Notifications/Notification/PriceCreatedNotification.php new file mode 100644 index 0000000..f0ce9a6 --- /dev/null +++ b/src/Notifications/Notification/PriceCreatedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Price) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/PriceUpdatedNotification.php b/src/Notifications/Notification/PriceUpdatedNotification.php new file mode 100644 index 0000000..66e3d56 --- /dev/null +++ b/src/Notifications/Notification/PriceUpdatedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Price) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/ProductCreatedNotification.php b/src/Notifications/Notification/ProductCreatedNotification.php new file mode 100644 index 0000000..8d0a2d4 --- /dev/null +++ b/src/Notifications/Notification/ProductCreatedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Product) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/ProductUpdatedNotification.php b/src/Notifications/Notification/ProductUpdatedNotification.php new file mode 100644 index 0000000..cccb3c8 --- /dev/null +++ b/src/Notifications/Notification/ProductUpdatedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Product) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/ReportCreatedNotification.php b/src/Notifications/Notification/ReportCreatedNotification.php new file mode 100644 index 0000000..2d61860 --- /dev/null +++ b/src/Notifications/Notification/ReportCreatedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Report) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/ReportUpdatedNotification.php b/src/Notifications/Notification/ReportUpdatedNotification.php new file mode 100644 index 0000000..6b9fc89 --- /dev/null +++ b/src/Notifications/Notification/ReportUpdatedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Report) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/SubscriptionActivatedNotification.php b/src/Notifications/Notification/SubscriptionActivatedNotification.php new file mode 100644 index 0000000..3012749 --- /dev/null +++ b/src/Notifications/Notification/SubscriptionActivatedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Subscription) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/SubscriptionCanceledNotification.php b/src/Notifications/Notification/SubscriptionCanceledNotification.php new file mode 100644 index 0000000..b3497f9 --- /dev/null +++ b/src/Notifications/Notification/SubscriptionCanceledNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Subscription) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/SubscriptionCreatedNotification.php b/src/Notifications/Notification/SubscriptionCreatedNotification.php new file mode 100644 index 0000000..8752264 --- /dev/null +++ b/src/Notifications/Notification/SubscriptionCreatedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Subscription) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/SubscriptionImportedNotification.php b/src/Notifications/Notification/SubscriptionImportedNotification.php new file mode 100644 index 0000000..ce7a666 --- /dev/null +++ b/src/Notifications/Notification/SubscriptionImportedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Subscription) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/SubscriptionPastDueNotification.php b/src/Notifications/Notification/SubscriptionPastDueNotification.php new file mode 100644 index 0000000..a1932df --- /dev/null +++ b/src/Notifications/Notification/SubscriptionPastDueNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Subscription) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/SubscriptionPausedNotification.php b/src/Notifications/Notification/SubscriptionPausedNotification.php new file mode 100644 index 0000000..79e5e92 --- /dev/null +++ b/src/Notifications/Notification/SubscriptionPausedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Subscription) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/SubscriptionResumedNotification.php b/src/Notifications/Notification/SubscriptionResumedNotification.php new file mode 100644 index 0000000..be378b3 --- /dev/null +++ b/src/Notifications/Notification/SubscriptionResumedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Subscription) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/SubscriptionTrialingNotification.php b/src/Notifications/Notification/SubscriptionTrialingNotification.php new file mode 100644 index 0000000..61841cb --- /dev/null +++ b/src/Notifications/Notification/SubscriptionTrialingNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Subscription) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/SubscriptionUpdatedNotification.php b/src/Notifications/Notification/SubscriptionUpdatedNotification.php new file mode 100644 index 0000000..78d6bc1 --- /dev/null +++ b/src/Notifications/Notification/SubscriptionUpdatedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Subscription) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/TransactionBilledNotification.php b/src/Notifications/Notification/TransactionBilledNotification.php new file mode 100644 index 0000000..435d089 --- /dev/null +++ b/src/Notifications/Notification/TransactionBilledNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Transaction) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/TransactionCanceledNotification.php b/src/Notifications/Notification/TransactionCanceledNotification.php new file mode 100644 index 0000000..69b6a1c --- /dev/null +++ b/src/Notifications/Notification/TransactionCanceledNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Transaction) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/TransactionCompletedNotification.php b/src/Notifications/Notification/TransactionCompletedNotification.php new file mode 100644 index 0000000..140b0b5 --- /dev/null +++ b/src/Notifications/Notification/TransactionCompletedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Transaction) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/TransactionCreatedNotification.php b/src/Notifications/Notification/TransactionCreatedNotification.php new file mode 100644 index 0000000..226052e --- /dev/null +++ b/src/Notifications/Notification/TransactionCreatedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Transaction) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/TransactionPaidNotification.php b/src/Notifications/Notification/TransactionPaidNotification.php new file mode 100644 index 0000000..3725a59 --- /dev/null +++ b/src/Notifications/Notification/TransactionPaidNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Transaction) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/TransactionPastDueNotification.php b/src/Notifications/Notification/TransactionPastDueNotification.php new file mode 100644 index 0000000..e0058ea --- /dev/null +++ b/src/Notifications/Notification/TransactionPastDueNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Transaction) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/TransactionPaymentFailedNotification.php b/src/Notifications/Notification/TransactionPaymentFailedNotification.php new file mode 100644 index 0000000..5dc0687 --- /dev/null +++ b/src/Notifications/Notification/TransactionPaymentFailedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Transaction) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/TransactionReadyNotification.php b/src/Notifications/Notification/TransactionReadyNotification.php new file mode 100644 index 0000000..ee5c069 --- /dev/null +++ b/src/Notifications/Notification/TransactionReadyNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Transaction) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/src/Notifications/Notification/TransactionUpdatedNotification.php b/src/Notifications/Notification/TransactionUpdatedNotification.php new file mode 100644 index 0000000..a1ed710 --- /dev/null +++ b/src/Notifications/Notification/TransactionUpdatedNotification.php @@ -0,0 +1,41 @@ +notification_id; + } + + /** + * @param (Transaction) $data + */ + public static function fromNotification( + string $eventId, + EventTypeName $eventType, + \DateTimeInterface $occurredAt, + Entity $data, + string $notification_id, + ): self { + return new self($eventId, $eventType, $occurredAt, $data, $notification_id); + } +} diff --git a/tests/Functional/Resources/Events/EventsClientTest.php b/tests/Functional/Resources/Events/EventsClientTest.php index 489a010..9f1c45d 100644 --- a/tests/Functional/Resources/Events/EventsClientTest.php +++ b/tests/Functional/Resources/Events/EventsClientTest.php @@ -7,12 +7,14 @@ use GuzzleHttp\Psr7\Response; use Http\Mock\Client as MockClient; use Paddle\SDK\Client; +use Paddle\SDK\Entities\Event; use Paddle\SDK\Entities\Shared\Status; use Paddle\SDK\Entities\Shared\TaxMode; use Paddle\SDK\Environment; use Paddle\SDK\Notifications\Entities\Product; use Paddle\SDK\Notifications\Entities\Shared\Interval; use Paddle\SDK\Notifications\Entities\Subscription\SubscriptionPrice; +use Paddle\SDK\Notifications\Notification\NotificationInterface; use Paddle\SDK\Options; use Paddle\SDK\Resources\Events\Operations\ListEvents; use Paddle\SDK\Resources\Shared\Operations\List\Pager; @@ -83,6 +85,22 @@ public static function listOperationsProvider(): \Generator ]; } + /** @test */ + public function list_does_not_have_notification_id(): void + { + $this->mockClient->addResponse(new Response(200, body: self::readRawJsonFixture('response/list_default'))); + + /** @var Event[] $events */ + $events = array_values(iterator_to_array($this->client->events->list(new ListEvents()))); + + self::assertCount(10, $events); + + foreach ($events as $event) { + self::assertInstanceOf(Event::class, $event); + self::assertNotInstanceOf(NotificationInterface::class, $event); + } + } + /** * @test */ diff --git a/tests/Functional/Resources/Notifications/NotificationsClientTest.php b/tests/Functional/Resources/Notifications/NotificationsClientTest.php index 0e8dacc..8930e69 100644 --- a/tests/Functional/Resources/Notifications/NotificationsClientTest.php +++ b/tests/Functional/Resources/Notifications/NotificationsClientTest.php @@ -7,8 +7,12 @@ use GuzzleHttp\Psr7\Response; use Http\Mock\Client as MockClient; use Paddle\SDK\Client; +use Paddle\SDK\Entities\Event; +use Paddle\SDK\Entities\Notification; use Paddle\SDK\Entities\Notification\NotificationStatus; use Paddle\SDK\Environment; +use Paddle\SDK\Notifications\Notification\BusinessUpdatedNotification; +use Paddle\SDK\Notifications\Notification\NotificationInterface; use Paddle\SDK\Options; use Paddle\SDK\Resources\Notifications\Operations\ListNotifications; use Paddle\SDK\Resources\Shared\Operations\List\Pager; @@ -139,6 +143,28 @@ public static function listOperationsProvider(): \Generator ]; } + /** @test */ + public function list_payloads_have_notification_id(): void + { + $this->mockClient->addResponse(new Response(200, body: self::readRawJsonFixture('response/list_default'))); + + /** @var Notification[] $notifications */ + $notifications = array_values(iterator_to_array($this->client->notifications->list(new ListNotifications()))); + + self::assertCount(5, $notifications); + + foreach ($notifications as $notification) { + self::assertInstanceOf(Event::class, $notification->payload); + self::assertInstanceOf(NotificationInterface::class, $notification->payload); + self::assertNotEmpty($notification->payload->getNotificationId()); + } + + $notificationPayload = $notifications[0]->payload; + self::assertInstanceOf(BusinessUpdatedNotification::class, $notificationPayload); + self::assertEquals('ntf_01h8bzam1z32agrxjwhjgqk8w6', $notificationPayload->getNotificationId()); + self::assertEquals('ntf_01h8bzam1z32agrxjwhjgqk8w6', $notificationPayload->notification_id); + } + /** @test */ public function get_hits_expected_uri(): void { diff --git a/tests/Unit/Entities/EventTest.php b/tests/Unit/Entities/EventTest.php new file mode 100644 index 0000000..a62f37b --- /dev/null +++ b/tests/Unit/Entities/EventTest.php @@ -0,0 +1,60 @@ +notification_id); + + self::assertSame('evt_01h8bzakzx3hm2fmen703n5q45', $notification->eventId); + self::assertSame('2023-08-21T11:57:47.390+00:00', $notification->occurredAt->format(DATE_RFC3339_EXTENDED)); + self::assertSame('business.updated', $notification->eventType->getValue()); + + $business = $notification->business; + self::assertInstanceOf(Business::class, $business); + self::assertSame('biz_01h84a7hr4pzhsajkm8tev89ev', $business->id); + self::assertSame('ChatApp Inc.', $business->name); + self::assertSame('active', $business->status->getValue()); + } + + /** @test */ + public function it_creates_from_request(): void + { + $requestStream = $this->createMock(StreamInterface::class); + $requestStream + ->method('__toString') + ->willReturn(self::readRawJsonFixture('notification_business_updated')); + + $request = $this->createMock(ServerRequestInterface::class); + $request + ->method('getBody') + ->willReturn($requestStream); + + $notification = Event::notificationFromRequest($request); + + self::assertInstanceOf(BusinessUpdatedNotification::class, $notification); + + self::assertSame('ntf_01h8bzam1z32agrxjwhjgqk8w6', $notification->notification_id); + } +} diff --git a/tests/Unit/Entities/_fixtures/notification_business_updated.json b/tests/Unit/Entities/_fixtures/notification_business_updated.json new file mode 100644 index 0000000..c3c93c8 --- /dev/null +++ b/tests/Unit/Entities/_fixtures/notification_business_updated.json @@ -0,0 +1,29 @@ +{ + "data": { + "id": "biz_01h84a7hr4pzhsajkm8tev89ev", + "name": "ChatApp Inc.", + "status": "active", + "contacts": [ + { + "name": "Parker Jones", + "email": "parker@example.com" + }, + { + "name": "Jo Riley", + "email": "jo@example.com" + }, + { + "name": "Jesse Garcia", + "email": "jo@example.com" + } + ], + "created_at": "2023-08-18T12:34:25.668Z", + "updated_at": "2023-08-21T11:57:47.03542Z", + "company_number": "555775291485", + "tax_identifier": null + }, + "event_id": "evt_01h8bzakzx3hm2fmen703n5q45", + "event_type": "business.updated", + "occurred_at": "2023-08-21T11:57:47.390028Z", + "notification_id": "ntf_01h8bzam1z32agrxjwhjgqk8w6" +}