summaryrefslogtreecommitdiff
path: root/matrix-specification/Responses
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2025-09-25 13:38:24 +0200
committerDaniel Weipert <git@mail.dweipert.de>2025-09-25 13:38:24 +0200
commitb19a8f63ad727a3633885d3f2b81edf8181a53b9 (patch)
tree6b5fd70224a125a16010a291e5fd0df834e9436f /matrix-specification/Responses
parentb08047ba485f86038f33175162943c0a9878ab1a (diff)
matrix-specification split work in progress
Diffstat (limited to 'matrix-specification/Responses')
-rw-r--r--matrix-specification/Responses/ClientAccountWhoamiGetResponse.php22
-rw-r--r--matrix-specification/Responses/ClientDirectoryRoomAliasGetResponse.php23
-rw-r--r--matrix-specification/Responses/ClientKeysUploadPostResponse.php21
-rw-r--r--matrix-specification/Responses/ClientLoginGetResponse.php2
-rw-r--r--matrix-specification/Responses/ClientLoginPostResponse.php30
-rw-r--r--matrix-specification/Responses/ClientRefreshPostResponse.php22
-rw-r--r--matrix-specification/Responses/ClientSyncGetResponse.php35
-rw-r--r--matrix-specification/Responses/ClientUserIdFilterPostResponse.php22
-rw-r--r--matrix-specification/Responses/ClientVersionsGetResponse.php24
-rw-r--r--matrix-specification/Responses/LoginFlow.php31
-rw-r--r--matrix-specification/Responses/WellKnownMatrixClientGetResponse.php18
-rw-r--r--matrix-specification/Responses/WellKnownMatrixSupportGetResponse.php33
12 files changed, 250 insertions, 33 deletions
diff --git a/matrix-specification/Responses/ClientAccountWhoamiGetResponse.php b/matrix-specification/Responses/ClientAccountWhoamiGetResponse.php
new file mode 100644
index 0000000..48fbbde
--- /dev/null
+++ b/matrix-specification/Responses/ClientAccountWhoamiGetResponse.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace Matrix\Responses;
+
+class ClientAccountWhoamiGetResponse implements \JsonSerializable
+{
+ public function __construct(
+ private string $userId,
+ private ?string $deviceId = null,
+ private ?bool $isGuest = null,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return array_filter([
+ "device_id" => $this->deviceId,
+ "is_guest" => $this->isGuest,
+ "user_id" => $this->userId,
+ ], "is_null");
+ }
+}
diff --git a/matrix-specification/Responses/ClientDirectoryRoomAliasGetResponse.php b/matrix-specification/Responses/ClientDirectoryRoomAliasGetResponse.php
new file mode 100644
index 0000000..a2a6346
--- /dev/null
+++ b/matrix-specification/Responses/ClientDirectoryRoomAliasGetResponse.php
@@ -0,0 +1,23 @@
+<?php
+
+namespace Matrix\Responses;
+
+class ClientDirectoryRoomAliasGetResponse implements \JsonSerializable
+{
+ /**
+ * @param string[] $servers
+ */
+ public function __construct(
+ private string $roomId,
+ private array $servers,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return [
+ "room_id" => $this->roomId,
+ "servers" => $this->servers,
+ ];
+ }
+}
diff --git a/matrix-specification/Responses/ClientKeysUploadPostResponse.php b/matrix-specification/Responses/ClientKeysUploadPostResponse.php
new file mode 100644
index 0000000..ff81734
--- /dev/null
+++ b/matrix-specification/Responses/ClientKeysUploadPostResponse.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace Matrix\Responses;
+
+class ClientKeysUploadPostResponse implements \JsonSerializable
+{
+ /**
+ * @param array<string, integer> $oneTimeKeyCounts
+ */
+ public function __construct(
+ private array $oneTimeKeyCounts,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return [
+ "one_time_keys_counts" => $this->oneTimeKeyCounts,
+ ];
+ }
+}
diff --git a/matrix-specification/Responses/ClientLoginGetResponse.php b/matrix-specification/Responses/ClientLoginGetResponse.php
index e0ccc26..b3b65c3 100644
--- a/matrix-specification/Responses/ClientLoginGetResponse.php
+++ b/matrix-specification/Responses/ClientLoginGetResponse.php
@@ -2,6 +2,8 @@
namespace Matrix\Responses;
+use Matrix\Data\LoginFlow;
+
class ClientLoginGetResponse implements \JsonSerializable
{
/**
diff --git a/matrix-specification/Responses/ClientLoginPostResponse.php b/matrix-specification/Responses/ClientLoginPostResponse.php
new file mode 100644
index 0000000..4bb893d
--- /dev/null
+++ b/matrix-specification/Responses/ClientLoginPostResponse.php
@@ -0,0 +1,30 @@
+<?php
+
+namespace Matrix\Responses;
+
+use Matrix\Data\DiscoveryInformation;
+
+class ClientLoginPostResponse implements \JsonSerializable
+{
+ public function __construct(
+ private string $accessToken,
+ private string $deviceId,
+ private string $userId,
+ private ?int $expiresInMilliseconds = null,
+ private ?string $refreshToken = null,
+ private ?DiscoveryInformation $wellKnown = null,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return array_filter([
+ "access_token" => $this->accessToken,
+ "device_id" => $this->deviceId,
+ "expires_in_ms" => $this->expiresInMilliseconds,
+ "refresh_token" => $this->refreshToken,
+ "user_id" => $this->userId,
+ "well_known" => $this->wellKnown,
+ ], "is_null");
+ }
+}
diff --git a/matrix-specification/Responses/ClientRefreshPostResponse.php b/matrix-specification/Responses/ClientRefreshPostResponse.php
new file mode 100644
index 0000000..b1e1154
--- /dev/null
+++ b/matrix-specification/Responses/ClientRefreshPostResponse.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace Matrix\Responses;
+
+class ClientRefreshPostResponse implements \JsonSerializable
+{
+ public function __construct(
+ private string $accessToken,
+ private ?int $expiresInMilliseconds = null,
+ private ?string $refreshToken = null,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return array_filter([
+ "access_token" => $this->accessToken,
+ "expires_in_ms" => $this->expiresInMilliseconds,
+ "refresh_token" => $this->refreshToken,
+ ], "is_null");
+ }
+}
diff --git a/matrix-specification/Responses/ClientSyncGetResponse.php b/matrix-specification/Responses/ClientSyncGetResponse.php
index 27464c1..ccdc5e6 100644
--- a/matrix-specification/Responses/ClientSyncGetResponse.php
+++ b/matrix-specification/Responses/ClientSyncGetResponse.php
@@ -2,7 +2,38 @@
namespace Matrix\Responses;
-class ClientSyncGetResponse
+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
{
- # TODO
+ /**
+ * @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");
+ }
}
diff --git a/matrix-specification/Responses/ClientUserIdFilterPostResponse.php b/matrix-specification/Responses/ClientUserIdFilterPostResponse.php
new file mode 100644
index 0000000..ed7ba37
--- /dev/null
+++ b/matrix-specification/Responses/ClientUserIdFilterPostResponse.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace Matrix\Responses;
+
+class ClientUserIdFilterPostResponse implements \JsonSerializable
+{
+ public function __construct(
+ private string $filterId,
+ )
+ {
+ if (str_starts_with($filterId, "{")) {
+ throw new \InvalidArgumentException("filterId cannot start with a { as this character is used to determine if the filter provided is inline JSON or a previously declared filter by homeservers on some APIs");
+ }
+ }
+
+ public function jsonSerialize(): array
+ {
+ return [
+ "filter_id" => $this->filterId,
+ ];
+ }
+}
diff --git a/matrix-specification/Responses/ClientVersionsGetResponse.php b/matrix-specification/Responses/ClientVersionsGetResponse.php
new file mode 100644
index 0000000..9ec701d
--- /dev/null
+++ b/matrix-specification/Responses/ClientVersionsGetResponse.php
@@ -0,0 +1,24 @@
+<?php
+
+namespace Matrix\Responses;
+
+class ClientVersionsGetResponse implements \JsonSerializable
+{
+ /**
+ * @param string[] $versions
+ * @param array<string, bool> $unstableFeatures
+ */
+ public function __construct(
+ private array $versions,
+ private ?array $unstableFeatures = null,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return array_filter([
+ "unstable_features" => $this->unstableFeatures,
+ "versions" => $this->versions,
+ ], "is_null");
+ }
+}
diff --git a/matrix-specification/Responses/LoginFlow.php b/matrix-specification/Responses/LoginFlow.php
deleted file mode 100644
index 6ddb703..0000000
--- a/matrix-specification/Responses/LoginFlow.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-
-namespace Matrix\Responses;
-
-use Matrix\Enums\LoginType;
-
-class LoginFlow implements \JsonSerializable
-{
- public function __construct(
- private LoginType $type,
- private ?bool $getLoginToken = null,
- )
- {}
-
- public function jsonSerialize(): array
- {
- $loginFlow = [
- "type" => $this->type,
- ];
-
- $loginFlow += match ($this->type) {
- LoginType::TOKEN => [
- "get_login_token" => $this->getLoginToken,
- ],
-
- default => [],
- };
-
- return $loginFlow;
- }
-}
diff --git a/matrix-specification/Responses/WellKnownMatrixClientGetResponse.php b/matrix-specification/Responses/WellKnownMatrixClientGetResponse.php
new file mode 100644
index 0000000..769268f
--- /dev/null
+++ b/matrix-specification/Responses/WellKnownMatrixClientGetResponse.php
@@ -0,0 +1,18 @@
+<?php
+
+namespace Matrix\Responses;
+
+use Matrix\Data\DiscoveryInformation;
+
+class WellKnownMatrixClientGetResponse implements \JsonSerializable
+{
+ public function __construct(
+ private DiscoveryInformation $discoveryInformation,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return $this->discoveryInformation;
+ }
+}
diff --git a/matrix-specification/Responses/WellKnownMatrixSupportGetResponse.php b/matrix-specification/Responses/WellKnownMatrixSupportGetResponse.php
new file mode 100644
index 0000000..f38e2b0
--- /dev/null
+++ b/matrix-specification/Responses/WellKnownMatrixSupportGetResponse.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace Matrix\Responses;
+
+use Matrix\Data\Contact;
+
+class WellKnownMatrixSupportGetResponse implements \JsonSerializable
+{
+ /**
+ * @param Contact[] $contacts
+ */
+ public function __construct(
+ private ?array $contacts = null,
+ private ?string $supportPage = null,
+ )
+ {
+ if (is_null($contacts) && is_null($supportPage)) {
+ throw new \InvalidArgumentException("at least one of contacts or supportPage is required");
+ }
+
+ if (! is_null($contacts) && is_null($supportPage) && empty($contacts)) {
+ throw new \InvalidArgumentException("if only contacts is set, it must contain at least one item");
+ }
+ }
+
+ public function jsonSerialize(): array
+ {
+ return array_filter([
+ "contacts" => $this->contacts,
+ "support_page" => $this->supportPage,
+ ], "is_null");
+ }
+}