summaryrefslogtreecommitdiff
path: root/matrix-specification/Responses/ClientSyncGetResponse.php
blob: ccdc5e651fbd643b032c9ef12970b74476df56a8 (plain)
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
<?php

namespace Matrix\Responses;

use Matrix\Data\AccountData;
use Matrix\Data\DeviceLists;
use Matrix\Data\Presence;
use Matrix\Data\Room\Rooms;
use Matrix\Data\ToDevice;

class ClientSyncGetResponse implements \JsonSerializable
{
  /**
   * @param array<string, int> $deviceOneTimeKeysCount
   */
  public function __construct(
    private string $nextBatch,
    private ?AccountData $accountData = null,
    private ?DeviceLists $deviceLists = null,
    private ?array $deviceOneTimeKeysCount = null,
    private ?Presence $presence = null,
    private ?Rooms $rooms = null,
    private ?ToDevice $toDevice = null,
  )
  {}

  public function jsonSerialize(): array
  {
    return array_filter([
      "account_data" => $this->accountData,
      "device_lists" => $this->deviceLists,
      "device_one_time_keys_count" => $this->deviceOneTimeKeysCount,
      "next_batch" => $this->nextBatch,
      "presence" => $this->presence,
      "rooms" => $this->rooms,
      "to_device" => $this->toDevice,
    ], "is_null");
  }
}