Parse and validate AT Protocol Lexicons with DTO generation for Laravel
1<?php
2
3namespace SocialDept\AtpSchema\Generated\Tools\Ozone\Communication\Defs;
4
5use Carbon\Carbon;
6use SocialDept\AtpSchema\Data\Data;
7
8/**
9 * GENERATED CODE - DO NOT EDIT
10 *
11 * Lexicon: tools.ozone.communication.defs.templateView
12 * Type: object
13 *
14 * @property string $id
15 * @property string $name Name of the template.
16 * @property string|null $subject Content of the template, can contain markdown and variable placeholders.
17 * @property string $contentMarkdown Subject of the message, used in emails.
18 * @property bool $disabled
19 * @property string|null $lang Message language.
20 * @property string $lastUpdatedBy DID of the user who last updated the template.
21 * @property Carbon $createdAt
22 * @property Carbon $updatedAt
23 *
24 * Constraints:
25 * - Required: id, name, contentMarkdown, disabled, lastUpdatedBy, createdAt, updatedAt
26 * - lang: Format: language
27 * - lastUpdatedBy: Format: did
28 * - createdAt: Format: datetime
29 * - updatedAt: Format: datetime
30 */
31class TemplateView extends Data
32{
33 /**
34 * @param string $name Name of the template.
35 * @param string $contentMarkdown Subject of the message, used in emails.
36 * @param string $lastUpdatedBy DID of the user who last updated the template.
37 * @param string|null $subject Content of the template, can contain markdown and variable placeholders.
38 * @param string|null $lang Message language.
39 */
40 public function __construct(
41 public readonly string $id,
42 public readonly string $name,
43 public readonly string $contentMarkdown,
44 public readonly bool $disabled,
45 public readonly string $lastUpdatedBy,
46 public readonly Carbon $createdAt,
47 public readonly Carbon $updatedAt,
48 public readonly ?string $subject = null,
49 public readonly ?string $lang = null
50 ) {
51 }
52
53 /**
54 * Get the lexicon NSID for this data type.
55 *
56 * @return string
57 */
58 public static function getLexicon(): string
59 {
60 return 'tools.ozone.communication.defs.templateView';
61 }
62
63
64 /**
65 * Create an instance from an array.
66 *
67 * @param array $data The data array
68 * @return static
69 */
70 public static function fromArray(array $data): static
71 {
72 return new static(
73 id: $data['id'],
74 name: $data['name'],
75 contentMarkdown: $data['contentMarkdown'],
76 disabled: $data['disabled'],
77 lastUpdatedBy: $data['lastUpdatedBy'],
78 createdAt: Carbon::parse($data['createdAt']),
79 updatedAt: Carbon::parse($data['updatedAt']),
80 subject: $data['subject'] ?? null,
81 lang: $data['lang'] ?? null
82 );
83 }
84
85}