-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathAuthenticationMagicAuthSucceeded.php
More file actions
50 lines (43 loc) · 1.53 KB
/
Copy pathAuthenticationMagicAuthSucceeded.php
File metadata and controls
50 lines (43 loc) · 1.53 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
<?php
declare(strict_types=1);
// This file is auto-generated by oagen. Do not edit.
namespace WorkOS\Resource;
readonly class AuthenticationMagicAuthSucceeded implements \JsonSerializable
{
use JsonSerializableTrait;
public function __construct(
/** Unique identifier for the event. */
public string $id,
public string $event,
/** The event payload. */
public AuthenticationMagicAuthSucceededData $data,
/** An ISO 8601 timestamp. */
public \DateTimeImmutable $createdAt,
/** Distinguishes the Event object. */
public string $object,
public ?EventContext $context = null,
) {
}
public static function fromArray(array $data): self
{
return new self(
id: $data['id'],
event: $data['event'] ?? 'authentication.magic_auth_succeeded',
data: AuthenticationMagicAuthSucceededData::fromArray($data['data']),
createdAt: new \DateTimeImmutable($data['created_at']),
object: $data['object'] ?? 'event',
context: isset($data['context']) ? EventContext::fromArray($data['context']) : null,
);
}
public function toArray(): array
{
return [
'id' => $this->id,
'event' => $this->event,
'data' => $this->data->toArray(),
'created_at' => $this->createdAt->format(\DateTimeInterface::RFC3339_EXTENDED),
'object' => $this->object,
'context' => $this->context?->toArray(),
];
}
}