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
41
42
43
44
45
46
47
48
49
50
|
<?php
namespace Matrix\Requests;
use Matrix\Enums\ApiPathVersion;
use Matrix\Enums\PresenceState;
use Matrix\Request;
class ClientSyncGetRequest extends Request 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 getUri(string $scheme, string $serverName, ApiPathVersion $version): string
{
return "{$scheme}://{$serverName}/_matrix/client/{$version}/sync";
}
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,
], fn ($value) => ! is_null($value));
}
public function getBody(): array
{
return [];
}
}
|