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

Create HasWebhookParams interface #3281

Merged
merged 13 commits into from
Apr 10, 2023
Merged

Conversation

tadhgboyle
Copy link
Member

@tadhgboyle tadhgboyle commented Mar 21, 2023

Alongside #3226

Allows events to set specific params to send when being transformed into a JSON object for webhooks.
This is useful for when events contain some params which are objects/classes, since they cannot be nicely formatted into JSON.

For example, if we want to be able to pass the users ID to a webhook when the userRegistered event is fired:

class UserRegisteredEvent implements HasWebhookParams {
  public User $user;

  function __construct(User $user) {
    $this->user = $user;
  }

  function webhookParams(): array {
    return [
      'user_id' => $this->user->data()->id
    ];
  }
}

When previously this would have instead returned something like:

['user' => User object]

@tadhgboyle tadhgboyle added the bug label Mar 21, 2023
@tadhgboyle tadhgboyle modified the milestones: 2.2.0, 2.1.0 Mar 21, 2023
@partydragen

This comment was marked as outdated.

@tadhgboyle tadhgboyle force-pushed the fix/event-system-webhook branch from 7cf00ad to 7147e07 Compare March 24, 2023 23:22
Copy link
Member

@samerton samerton left a comment

Choose a reason for hiding this comment

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

To confirm, is this for 2.1.0 or 2.2.0?

@tadhgboyle tadhgboyle marked this pull request as draft April 2, 2023 01:08
@partydragen
Copy link
Member

Closes #3275

@partydragen partydragen linked an issue Apr 2, 2023 that may be closed by this pull request
@tadhgboyle tadhgboyle force-pushed the fix/event-system-webhook branch from b175993 to 971db2e Compare April 2, 2023 19:55
@tadhgboyle tadhgboyle requested a review from samerton April 2, 2023 20:51
@tadhgboyle tadhgboyle marked this pull request as ready for review April 4, 2023 04:21
@tadhgboyle tadhgboyle requested a review from partydragen April 4, 2023 04:21
partydragen
partydragen previously approved these changes Apr 4, 2023
@tadhgboyle
Copy link
Member Author

To confirm, is this for 2.1.0 or 2.2.0?

2.1.0, as it has no more breaking changes than already existed in the main event revamp PR

@tadhgboyle tadhgboyle force-pushed the fix/event-system-webhook branch from 29878ab to c169c9e Compare April 5, 2023 20:19
@tadhgboyle tadhgboyle merged commit 3966a8c into develop Apr 10, 2023
@tadhgboyle tadhgboyle deleted the fix/event-system-webhook branch April 10, 2023 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

available_hooks for events no longer working
3 participants