summaryrefslogtreecommitdiff
path: root/matrix-specification/Requests/ClientSyncGetRequest.php
blob: 2ab7d9e308497130426e82529b4777d7e6509553 (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
<?php

namespace Matrix\Requests;

use Matrix\Enums\PresenceState;

class ClientSyncGetRequest implements RequiresAuthentication
{
  public function __construct(
    private ?string $filter = null,
    private ?bool $fullState = null,
    private ?PresenceState $setPresence = null,
    private ?string $since = null,
    private ?int $timeout = null,
    private ?bool $useStateAfter = null,
  )
  {}

  public function setDefaults(): void
  {
    $this->fullState ??= false;
    $this->setPresence ??= PresenceState::ONLINE;
    $this->timeout ??= 0;
    $this->useStateAfter ??= false;
  }

  public function getQueryParameters(): array
  {
    return array_filter([
      "filter" => $this->filter,
      "full_state" => $this->fullState,
      "set_presence" => $this->setPresence,
      "since" => $this->since,
      "timeout" => $this->timeout,
      "use_state_after" => $this->useStateAfter,
    ], "is_null");
  }
}