summaryrefslogtreecommitdiff
path: root/matrix-specification/Responses/ClientSyncGetResponse.php
blob: dbe2a2977f28cea25d2a43b7dee4491c256ae373 (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
40
<?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;
use Matrix\Response;

class ClientSyncGetResponse extends Response
{
  /**
   * @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 getBody(): 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,
    ], fn ($value) => ! is_null($value));
  }
}