Laravel AT Protocol Client (alpha & unstable)
1<?php
2
3namespace SocialDept\AtpClient\Data\Responses\Chat\Convo;
4
5use Illuminate\Contracts\Support\Arrayable;
6use Illuminate\Support\Collection;
7use SocialDept\AtpSchema\Generated\Chat\Bsky\Convo\Defs\ConvoView;
8
9/**
10 * @implements Arrayable<string, mixed>
11 */
12class ListConvosResponse implements Arrayable
13{
14 /**
15 * @param Collection<int, ConvoView> $convos
16 */
17 public function __construct(
18 public readonly Collection $convos,
19 public readonly ?string $cursor = null,
20 ) {}
21
22 public static function fromArray(array $data): self
23 {
24 return new self(
25 convos: collect($data['convos'] ?? [])->map(
26 fn (array $convo) => ConvoView::fromArray($convo)
27 ),
28 cursor: $data['cursor'] ?? null,
29 );
30 }
31
32 public function toArray(): array
33 {
34 return [
35 'convos' => $this->convos->map(fn (ConvoView $c) => $c->toArray())->all(),
36 'cursor' => $this->cursor,
37 ];
38 }
39}