-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathApiKey.php
More file actions
68 lines (61 loc) · 2.35 KB
/
Copy pathApiKey.php
File metadata and controls
68 lines (61 loc) · 2.35 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
59
60
61
62
63
64
65
66
67
68
<?php
declare(strict_types=1);
// This file is auto-generated by oagen. Do not edit.
namespace WorkOS\Resource;
/** The API Key object if the value is valid, or `null` if invalid. */
readonly class ApiKey implements \JsonSerializable
{
use JsonSerializableTrait;
public function __construct(
/** Distinguishes the API Key object. */
public string $object,
/** Unique identifier of the API Key. */
public string $id,
/** The entity that owns the API Key. */
public ApiKeyOwner $owner,
/** A descriptive name for the API Key. */
public string $name,
/** An obfuscated representation of the API Key value. */
public string $obfuscatedValue,
/** Timestamp of when the API Key was last used. */
public ?\DateTimeImmutable $lastUsedAt,
/**
* The permission slugs assigned to the API Key.
* @var array<string>
*/
public array $permissions,
/** An ISO 8601 timestamp. */
public \DateTimeImmutable $createdAt,
/** An ISO 8601 timestamp. */
public \DateTimeImmutable $updatedAt,
) {
}
public static function fromArray(array $data): self
{
return new self(
object: $data['object'] ?? 'api_key',
id: $data['id'],
owner: ApiKeyOwner::fromArray($data['owner']),
name: $data['name'],
obfuscatedValue: $data['obfuscated_value'],
lastUsedAt: isset($data['last_used_at']) ? new \DateTimeImmutable($data['last_used_at']) : null,
permissions: $data['permissions'],
createdAt: new \DateTimeImmutable($data['created_at']),
updatedAt: new \DateTimeImmutable($data['updated_at']),
);
}
public function toArray(): array
{
return [
'object' => $this->object,
'id' => $this->id,
'owner' => $this->owner->toArray(),
'name' => $this->name,
'obfuscated_value' => $this->obfuscatedValue,
'last_used_at' => $this->lastUsedAt?->format(\DateTimeInterface::RFC3339_EXTENDED),
'permissions' => $this->permissions,
'created_at' => $this->createdAt->format(\DateTimeInterface::RFC3339_EXTENDED),
'updated_at' => $this->updatedAt->format(\DateTimeInterface::RFC3339_EXTENDED),
];
}
}