-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebhookSetupReceived.php
More file actions
56 lines (50 loc) · 1.64 KB
/
Copy pathWebhookSetupReceived.php
File metadata and controls
56 lines (50 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
declare(strict_types=1);
namespace Vatly\API\Webhooks\Events;
use Vatly\API\Types\WebhookEventName;
/**
* Event representing a `webhook.setup` verification call from Vatly.
*
* Vatly sends this signed delivery when a webhook endpoint is registered or its
* URL changes, to confirm the endpoint is reachable. It uses the standard
* webhook envelope (same signature, same `Vatly-Event-Id` header); `entityType`
* is `webhook` and `object` is the (secret-free) endpoint config — which may be
* empty or minimal. There is no enriched resource to fetch: consumers simply
* acknowledge it with a `2xx` and take no event-specific action.
*
* Carries only the webhook envelope (mirroring {@see UnsupportedWebhookReceived}).
*
* @immutable
*/
class WebhookSetupReceived
{
public const VATLY_EVENT_NAME = WebhookEventName::WEBHOOK_SETUP;
/**
* @param array<string, mixed> $object
*/
public function __construct(
public string $id,
public string $resource,
public string $eventName,
public string $entityType,
public string $entityId,
public bool $testmode,
public string $createdAt,
public array $object,
) {
//
}
public static function fromWebhook(WebhookReceived $webhook): self
{
return new self(
id: $webhook->id,
resource: $webhook->resource,
eventName: $webhook->eventName,
entityType: $webhook->entityType,
entityId: $webhook->entityId,
testmode: $webhook->testmode,
createdAt: $webhook->createdAt,
object: $webhook->object,
);
}
}