Skip to content

Commit

Permalink
Merge pull request #68 from resend/feat-domain-webhook-event
Browse files Browse the repository at this point in the history
  • Loading branch information
jayanratna authored Jan 13, 2025
2 parents 28cb0c4 + 40aee2a commit 94183d7
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Events/DomainCreated.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Resend\Laravel\Events;

use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class DomainCreated
{
use Dispatchable, SerializesModels;

/**
* Create a new domain created event instance.
*/
public function __construct(
public array $payload
) {
//
}
}
20 changes: 20 additions & 0 deletions src/Events/DomainDeleted.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Resend\Laravel\Events;

use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class DomainDeleted
{
use Dispatchable, SerializesModels;

/**
* Create a new domain deleted event instance.
*/
public function __construct(
public array $payload
) {
//
}
}
20 changes: 20 additions & 0 deletions src/Events/DomainUpdated.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Resend\Laravel\Events;

use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class DomainUpdated
{
use Dispatchable, SerializesModels;

/**
* Create a new domain updated event instance.
*/
public function __construct(
public array $payload
) {
//
}
}
33 changes: 33 additions & 0 deletions src/Http/Controllers/WebhookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Resend\Laravel\Events\ContactCreated;
use Resend\Laravel\Events\ContactDeleted;
use Resend\Laravel\Events\ContactUpdated;
use Resend\Laravel\Events\DomainCreated;
use Resend\Laravel\Events\DomainDeleted;
use Resend\Laravel\Events\DomainUpdated;
use Resend\Laravel\Events\EmailBounced;
use Resend\Laravel\Events\EmailClicked;
use Resend\Laravel\Events\EmailComplained;
Expand Down Expand Up @@ -82,6 +85,36 @@ protected function handleContactUpdated(array $payload): Response
return $this->successMethod();
}

/**
* Handle domain created event.
*/
protected function handleDomainCreated(array $payload): Response
{
DomainCreated::dispatch($payload);

return $this->successMethod();
}

/**
* Handle domain deleted event.
*/
protected function handleDomainDeleted(array $payload): Response
{
DomainDeleted::dispatch($payload);

return $this->successMethod();
}

/**
* Handle domain updated event.
*/
protected function handleDomainUpdated(array $payload): Response
{
DomainUpdated::dispatch($payload);

return $this->successMethod();
}

/**
* Handle email bounced event.
*/
Expand Down
6 changes: 6 additions & 0 deletions tests/Http/Controllers/WebhookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
use Resend\Laravel\Events\ContactCreated;
use Resend\Laravel\Events\ContactDeleted;
use Resend\Laravel\Events\ContactUpdated;
use Resend\Laravel\Events\DomainCreated;
use Resend\Laravel\Events\DomainDeleted;
use Resend\Laravel\Events\DomainUpdated;
use Resend\Laravel\Events\EmailBounced;
use Resend\Laravel\Events\EmailClicked;
use Resend\Laravel\Events\EmailComplained;
Expand Down Expand Up @@ -32,6 +35,9 @@
['contact.created', ContactCreated::class],
['contact.deleted', ContactDeleted::class],
['contact.updated', ContactUpdated::class],
['domain.created', DomainCreated::class],
['domain.deleted', DomainDeleted::class],
['domain.updated', DomainUpdated::class],
['email.bounced', EmailBounced::class],
['email.clicked', EmailClicked::class],
['email.complained', EmailComplained::class],
Expand Down

0 comments on commit 94183d7

Please sign in to comment.