Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Event notification sub types #75

Closed

Conversation

davidgrayston-paddle
Copy link
Contributor

Added

  • Event notification sub types with notification_id

Usage

use Paddle\SDK\Entities\Event;
use Paddle\SDK\Notifications\Notification\TransactionUpdatedNotification;

$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;
}

@@ -36,7 +36,8 @@
'concat_space' => [
'spacing' => 'one',
],
'self_accessor' => true,
// Disable self_accessor to allow self intersection return types.
// 'self_accessor' => true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prevents

- public static function notificationFrom(array $data): Event&NotificationInterface
+ public static function notificationFrom(array $data): self&NotificationInterface

parent::__construct($eventId, $eventType, $occurredAt, $adjustment);
}

public function getNotificationId(): string
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot have public readonly string $notification_id on the interface, so have added a getter.

@davidgrayston-paddle
Copy link
Contributor Author

Superseded by #74

@vifer vifer deleted the feat/event-notification-id-sub-type branch October 2, 2024 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant