-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathAuditLogSchemaJson.php
More file actions
58 lines (51 loc) · 1.89 KB
/
Copy pathAuditLogSchemaJson.php
File metadata and controls
58 lines (51 loc) · 1.89 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
57
58
<?php
declare(strict_types=1);
// This file is auto-generated by oagen. Do not edit.
namespace WorkOS\Resource;
readonly class AuditLogSchemaJson implements \JsonSerializable
{
use JsonSerializableTrait;
public function __construct(
/** Distinguishes the Audit Log Schema object. */
public string $object,
/** The version of the schema. */
public int $version,
/**
* The list of targets for the schema.
* @var array<\WorkOS\Resource\AuditLogSchemaJsonTarget>
*/
public array $targets,
/** The timestamp when the Audit Log Schema was created. */
public \DateTimeImmutable $createdAt,
/** The metadata schema for the actor. */
public ?AuditLogSchemaJsonActor $actor = null,
/**
* Additional data associated with the event or entity.
* @var array<string, mixed>|null
*/
public ?array $metadata = null,
) {
}
public static function fromArray(array $data): self
{
return new self(
object: $data['object'] ?? 'audit_log_schema',
version: $data['version'],
targets: array_map(fn ($item) => AuditLogSchemaJsonTarget::fromArray($item), $data['targets']),
createdAt: new \DateTimeImmutable($data['created_at']),
actor: isset($data['actor']) ? AuditLogSchemaJsonActor::fromArray($data['actor']) : null,
metadata: $data['metadata'] ?? null,
);
}
public function toArray(): array
{
return [
'object' => $this->object,
'version' => $this->version,
'targets' => array_map(fn ($item) => $item->toArray(), $this->targets),
'created_at' => $this->createdAt->format(\DateTimeInterface::RFC3339_EXTENDED),
'actor' => $this->actor?->toArray(),
'metadata' => $this->metadata,
];
}
}