summaryrefslogtreecommitdiff
path: root/matrix-specification/Requests
diff options
context:
space:
mode:
Diffstat (limited to 'matrix-specification/Requests')
-rw-r--r--matrix-specification/Requests/ClientDirectoryRoomAliasGetRequest.php29
-rw-r--r--matrix-specification/Requests/ClientKeysUploadPostRequest.php29
-rw-r--r--matrix-specification/Requests/ClientLoginGetRequest.php6
-rw-r--r--matrix-specification/Requests/ClientLoginPostRequest.php2
-rw-r--r--matrix-specification/Requests/ClientRefreshPostRequest.php18
-rw-r--r--matrix-specification/Requests/ClientSyncGetRequest.php34
-rw-r--r--matrix-specification/Requests/ClientUserIdFilterPostRequest.php34
-rw-r--r--matrix-specification/Requests/RequiresAuthentication.php2
8 files changed, 144 insertions, 10 deletions
diff --git a/matrix-specification/Requests/ClientDirectoryRoomAliasGetRequest.php b/matrix-specification/Requests/ClientDirectoryRoomAliasGetRequest.php
new file mode 100644
index 0000000..174a5c2
--- /dev/null
+++ b/matrix-specification/Requests/ClientDirectoryRoomAliasGetRequest.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace Matrix\Requests;
+
+use Matrix\Enums\ApiPathVersion;
+use Matrix\Request;
+
+class ClientDirectoryRoomAliasGetRequest extends Request
+{
+ public function __construct(
+ private string $roomAlias,
+ )
+ {}
+
+ public function getUri(string $serverName, ApiPathVersion $version): string
+ {
+ return "https://$serverName/_matrix/client/{$version}/directory/room/{$this->roomAlias}";
+ }
+
+ public function getQueryParameters(): array
+ {
+ return [];
+ }
+
+ public function getBody(): array
+ {
+ return [];
+ }
+}
diff --git a/matrix-specification/Requests/ClientKeysUploadPostRequest.php b/matrix-specification/Requests/ClientKeysUploadPostRequest.php
new file mode 100644
index 0000000..40d9eae
--- /dev/null
+++ b/matrix-specification/Requests/ClientKeysUploadPostRequest.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace Matrix\Requests;
+
+use Matrix\Data\DeviceKeys;
+use Matrix\Data\KeyObject;
+
+class ClientKeysUploadPostRequest implements RateLimited, RequiresAuthentication, \JsonSerializable
+{
+ /**
+ * @param array<string, string|KeyObject> $fallbackKeys
+ * @param array<string, string|KeyObject> $oneTimeKeys
+ */
+ public function __construct(
+ private ?DeviceKeys $deviceKeys = null,
+ private ?array $fallbackKeys = null,
+ private ?array $oneTimeKeys = null,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return array_filter([
+ "device_keys" => $this->deviceKeys,
+ "fallback_keys" => $this->fallbackKeys,
+ "one_time_keys" => $this->oneTimeKeys,
+ ], "is_null");
+ }
+}
diff --git a/matrix-specification/Requests/ClientLoginGetRequest.php b/matrix-specification/Requests/ClientLoginGetRequest.php
deleted file mode 100644
index 73cc24c..0000000
--- a/matrix-specification/Requests/ClientLoginGetRequest.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-
-namespace Matrix\Requests;
-
-class ClientLoginGetRequest implements RateLimited
-{}
diff --git a/matrix-specification/Requests/ClientLoginPostRequest.php b/matrix-specification/Requests/ClientLoginPostRequest.php
index d17c558..44497e7 100644
--- a/matrix-specification/Requests/ClientLoginPostRequest.php
+++ b/matrix-specification/Requests/ClientLoginPostRequest.php
@@ -2,8 +2,8 @@
namespace Matrix\Requests;
+use Matrix\Data\UserIdentifier;
use Matrix\Enums\LoginType;
-use Matrix\UserIdentifier;
class ClientLoginPostRequest implements RateLimited, \JsonSerializable
{
diff --git a/matrix-specification/Requests/ClientRefreshPostRequest.php b/matrix-specification/Requests/ClientRefreshPostRequest.php
new file mode 100644
index 0000000..733ca75
--- /dev/null
+++ b/matrix-specification/Requests/ClientRefreshPostRequest.php
@@ -0,0 +1,18 @@
+<?php
+
+namespace Matrix\Requests;
+
+class ClientRefreshPostRequest implements RateLimited, \JsonSerializable
+{
+ public function __construct(
+ private string $refreshToken,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return [
+ "refresh_token" => $this->refreshToken,
+ ];
+ }
+}
diff --git a/matrix-specification/Requests/ClientSyncGetRequest.php b/matrix-specification/Requests/ClientSyncGetRequest.php
index 2921fcf..2ab7d9e 100644
--- a/matrix-specification/Requests/ClientSyncGetRequest.php
+++ b/matrix-specification/Requests/ClientSyncGetRequest.php
@@ -2,7 +2,37 @@
namespace Matrix\Requests;
-class ClientSyncGetRequest
+use Matrix\Enums\PresenceState;
+
+class ClientSyncGetRequest implements RequiresAuthentication
{
- # TODO
+ 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");
+ }
}
diff --git a/matrix-specification/Requests/ClientUserIdFilterPostRequest.php b/matrix-specification/Requests/ClientUserIdFilterPostRequest.php
new file mode 100644
index 0000000..2edc4c5
--- /dev/null
+++ b/matrix-specification/Requests/ClientUserIdFilterPostRequest.php
@@ -0,0 +1,34 @@
+<?php
+
+namespace Matrix\Requests;
+
+use Matrix\Data\Filters\EventFilter;
+use Matrix\Data\Filters\RoomFilter;
+
+ # ClientUserUserIdFilterPostRequest?
+class ClientUserIdFilterPostRequest implements RequiresAuthentication, \JsonSerializable
+{
+ /**
+ * @param string[] $eventFields
+ */
+ public function __construct(
+ private string $userId,
+ private ?EventFilter $accountData = null,
+ private ?array $eventFields = null,
+ private ?string $eventFormat = null,
+ private ?EventFilter $presence = null,
+ private ?RoomFilter $room = null,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return [
+ "account_data" => $this->accountData,
+ "event_fields" => $this->eventFields,
+ "event_format" => $this->eventFormat,
+ "presence" => $this->presence,
+ "room" => $this->room,
+ ];
+ }
+}
diff --git a/matrix-specification/Requests/RequiresAuthentication.php b/matrix-specification/Requests/RequiresAuthentication.php
index c494f13..a762405 100644
--- a/matrix-specification/Requests/RequiresAuthentication.php
+++ b/matrix-specification/Requests/RequiresAuthentication.php
@@ -4,5 +4,5 @@ namespace Matrix\Requests;
interface RequiresAuthentication
{
- public function authenticateUser(): bool;
+ //public function authenticateUser(): bool;
}