Parse and validate AT Protocol Lexicons with DTO generation for Laravel
1<?php
2
3namespace SocialDept\AtpSchema\Generated\Com\Atproto\Server\Defs;
4
5use Carbon\Carbon;
6use SocialDept\AtpSchema\Data\Data;
7
8/**
9 * GENERATED CODE - DO NOT EDIT
10 *
11 * Lexicon: com.atproto.server.defs.inviteCode
12 * Type: object
13 *
14 * @property string $code
15 * @property int $available
16 * @property bool $disabled
17 * @property string $forAccount
18 * @property string $createdBy
19 * @property Carbon $createdAt
20 * @property array $uses
21 *
22 * Constraints:
23 * - Required: code, available, disabled, forAccount, createdBy, createdAt, uses
24 * - createdAt: Format: datetime
25 */
26class InviteCode extends Data
27{
28 public function __construct(
29 public readonly string $code,
30 public readonly int $available,
31 public readonly bool $disabled,
32 public readonly string $forAccount,
33 public readonly string $createdBy,
34 public readonly Carbon $createdAt,
35 public readonly array $uses
36 ) {
37 }
38
39 /**
40 * Get the lexicon NSID for this data type.
41 *
42 * @return string
43 */
44 public static function getLexicon(): string
45 {
46 return 'com.atproto.server.defs.inviteCode';
47 }
48
49
50 /**
51 * Create an instance from an array.
52 *
53 * @param array $data The data array
54 * @return static
55 */
56 public static function fromArray(array $data): static
57 {
58 return new static(
59 code: $data['code'],
60 available: $data['available'],
61 disabled: $data['disabled'],
62 forAccount: $data['forAccount'],
63 createdBy: $data['createdBy'],
64 createdAt: Carbon::parse($data['createdAt']),
65 uses: $data['uses'] ?? []
66 );
67 }
68
69}