Parse and validate AT Protocol Lexicons with DTO generation for Laravel
at main 83 lines 2.5 kB view raw
1<?php 2 3namespace SocialDept\AtpSchema\Generated\App\Bsky\Notification\ListNotifications; 4 5use Carbon\Carbon; 6use SocialDept\AtpSchema\Data\Data; 7use SocialDept\AtpSchema\Generated\App\Bsky\Actor\Defs\ProfileView; 8use SocialDept\AtpSchema\Generated\Com\Atproto\Label\Defs\Label; 9 10/** 11 * GENERATED CODE - DO NOT EDIT 12 * 13 * Lexicon: app.bsky.notification.listNotifications.notification 14 * Type: object 15 * 16 * @property string $uri 17 * @property string $cid 18 * @property ProfileView $author 19 * @property string $reason The reason why this notification was delivered - e.g. your post was liked, or you received a new follower. 20 * @property string|null $reasonSubject 21 * @property mixed $record 22 * @property bool $isRead 23 * @property Carbon $indexedAt 24 * @property array<Label>|null $labels 25 * 26 * Constraints: 27 * - Required: uri, cid, author, reason, record, isRead, indexedAt 28 * - uri: Format: at-uri 29 * - cid: Format: cid 30 * - reasonSubject: Format: at-uri 31 * - indexedAt: Format: datetime 32 */ 33class Notification extends Data 34{ 35 /** 36 * @param string $reason The reason why this notification was delivered - e.g. your post was liked, or you received a new follower. 37 */ 38 public function __construct( 39 public readonly string $uri, 40 public readonly string $cid, 41 public readonly ProfileView $author, 42 public readonly string $reason, 43 public readonly mixed $record, 44 public readonly bool $isRead, 45 public readonly Carbon $indexedAt, 46 public readonly ?string $reasonSubject = null, 47 public readonly ?array $labels = null 48 ) { 49 } 50 51 /** 52 * Get the lexicon NSID for this data type. 53 * 54 * @return string 55 */ 56 public static function getLexicon(): string 57 { 58 return 'app.bsky.notification.listNotifications.notification'; 59 } 60 61 62 /** 63 * Create an instance from an array. 64 * 65 * @param array $data The data array 66 * @return static 67 */ 68 public static function fromArray(array $data): static 69 { 70 return new static( 71 uri: $data['uri'], 72 cid: $data['cid'], 73 author: ProfileView::fromArray($data['author']), 74 reason: $data['reason'], 75 record: $data['record'], 76 isRead: $data['isRead'], 77 indexedAt: Carbon::parse($data['indexedAt']), 78 reasonSubject: $data['reasonSubject'] ?? null, 79 labels: isset($data['labels']) ? array_map(fn ($item) => Label::fromArray($item), $data['labels']) : [] 80 ); 81 } 82 83}