-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathAuthenticationChallenge.php
More file actions
56 lines (49 loc) · 2.03 KB
/
Copy pathAuthenticationChallenge.php
File metadata and controls
56 lines (49 loc) · 2.03 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);
// This file is auto-generated by oagen. Do not edit.
namespace WorkOS\Resource;
readonly class AuthenticationChallenge implements \JsonSerializable
{
use JsonSerializableTrait;
public function __construct(
/** Distinguishes the authentication challenge object. */
public string $object,
/** The unique ID of the authentication challenge. */
public string $id,
/** The unique ID of the authentication factor the challenge belongs to. */
public string $authenticationFactorId,
/** An ISO 8601 timestamp. */
public \DateTimeImmutable $createdAt,
/** An ISO 8601 timestamp. */
public \DateTimeImmutable $updatedAt,
/** The timestamp when the challenge will expire. Does not apply to TOTP factors. */
public ?\DateTimeImmutable $expiresAt = null,
/** The one-time code for the challenge. */
public ?string $code = null,
) {
}
public static function fromArray(array $data): self
{
return new self(
object: $data['object'] ?? 'authentication_challenge',
id: $data['id'],
authenticationFactorId: $data['authentication_factor_id'],
createdAt: new \DateTimeImmutable($data['created_at']),
updatedAt: new \DateTimeImmutable($data['updated_at']),
expiresAt: isset($data['expires_at']) ? new \DateTimeImmutable($data['expires_at']) : null,
code: $data['code'] ?? null,
);
}
public function toArray(): array
{
return [
'object' => $this->object,
'id' => $this->id,
'authentication_factor_id' => $this->authenticationFactorId,
'created_at' => $this->createdAt->format(\DateTimeInterface::RFC3339_EXTENDED),
'updated_at' => $this->updatedAt->format(\DateTimeInterface::RFC3339_EXTENDED),
'expires_at' => $this->expiresAt?->format(\DateTimeInterface::RFC3339_EXTENDED),
'code' => $this->code,
];
}
}