summaryrefslogtreecommitdiff
path: root/matrix-specification/Responses
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2025-12-13 16:27:53 +0100
committerDaniel Weipert <git@mail.dweipert.de>2025-12-13 16:27:53 +0100
commit2386148b8f048ba40d9f26cc97898bdcdc778ea2 (patch)
tree48ca45de3dc6133cb0225eba8c5917f813082b2b /matrix-specification/Responses
parentb19a8f63ad727a3633885d3f2b81edf8181a53b9 (diff)
matrix specification splitHEADmain
Diffstat (limited to 'matrix-specification/Responses')
-rw-r--r--matrix-specification/Responses/ClientAccountWhoamiGetResponse.php8
-rw-r--r--matrix-specification/Responses/ClientDirectoryRoomAliasGetResponse.php6
-rw-r--r--matrix-specification/Responses/ClientKeysUploadPostResponse.php9
-rw-r--r--matrix-specification/Responses/ClientLoginGetResponse.php5
-rw-r--r--matrix-specification/Responses/ClientLoginPostResponse.php7
-rw-r--r--matrix-specification/Responses/ClientRefreshPostResponse.php8
-rw-r--r--matrix-specification/Responses/ClientRegisterPostResponse.php39
-rw-r--r--matrix-specification/Responses/ClientSyncGetResponse.php7
-rw-r--r--matrix-specification/Responses/ClientUserIdFilterPostResponse.php11
-rw-r--r--matrix-specification/Responses/ClientVersionsGetResponse.php8
-rw-r--r--matrix-specification/Responses/WellKnownMatrixClientGetResponse.php7
-rw-r--r--matrix-specification/Responses/WellKnownMatrixSupportGetResponse.php7
12 files changed, 92 insertions, 30 deletions
diff --git a/matrix-specification/Responses/ClientAccountWhoamiGetResponse.php b/matrix-specification/Responses/ClientAccountWhoamiGetResponse.php
index 48fbbde..2f7ff81 100644
--- a/matrix-specification/Responses/ClientAccountWhoamiGetResponse.php
+++ b/matrix-specification/Responses/ClientAccountWhoamiGetResponse.php
@@ -2,7 +2,9 @@
namespace Matrix\Responses;
-class ClientAccountWhoamiGetResponse implements \JsonSerializable
+use Matrix\Response;
+
+class ClientAccountWhoamiGetResponse extends Response
{
public function __construct(
private string $userId,
@@ -11,12 +13,12 @@ class ClientAccountWhoamiGetResponse implements \JsonSerializable
)
{}
- public function jsonSerialize(): array
+ public function getBody(): array
{
return array_filter([
"device_id" => $this->deviceId,
"is_guest" => $this->isGuest,
"user_id" => $this->userId,
- ], "is_null");
+ ], fn ($value) => ! is_null($value));
}
}
diff --git a/matrix-specification/Responses/ClientDirectoryRoomAliasGetResponse.php b/matrix-specification/Responses/ClientDirectoryRoomAliasGetResponse.php
index a2a6346..4a5977a 100644
--- a/matrix-specification/Responses/ClientDirectoryRoomAliasGetResponse.php
+++ b/matrix-specification/Responses/ClientDirectoryRoomAliasGetResponse.php
@@ -2,7 +2,9 @@
namespace Matrix\Responses;
-class ClientDirectoryRoomAliasGetResponse implements \JsonSerializable
+use Matrix\Response;
+
+class ClientDirectoryRoomAliasGetResponse extends Response
{
/**
* @param string[] $servers
@@ -13,7 +15,7 @@ class ClientDirectoryRoomAliasGetResponse implements \JsonSerializable
)
{}
- public function jsonSerialize(): array
+ public function getBody(): array
{
return [
"room_id" => $this->roomId,
diff --git a/matrix-specification/Responses/ClientKeysUploadPostResponse.php b/matrix-specification/Responses/ClientKeysUploadPostResponse.php
index ff81734..3d335e4 100644
--- a/matrix-specification/Responses/ClientKeysUploadPostResponse.php
+++ b/matrix-specification/Responses/ClientKeysUploadPostResponse.php
@@ -2,7 +2,12 @@
namespace Matrix\Responses;
-class ClientKeysUploadPostResponse implements \JsonSerializable
+use Matrix\Response;
+
+/**
+ * @see https://spec.matrix.org/v1.16/client-server-api/#post_matrixclientv3keysupload
+ */
+class ClientKeysUploadPostResponse extends Response
{
/**
* @param array<string, integer> $oneTimeKeyCounts
@@ -12,7 +17,7 @@ class ClientKeysUploadPostResponse implements \JsonSerializable
)
{}
- public function jsonSerialize(): array
+ public function getBody(): array
{
return [
"one_time_keys_counts" => $this->oneTimeKeyCounts,
diff --git a/matrix-specification/Responses/ClientLoginGetResponse.php b/matrix-specification/Responses/ClientLoginGetResponse.php
index b3b65c3..b8badbd 100644
--- a/matrix-specification/Responses/ClientLoginGetResponse.php
+++ b/matrix-specification/Responses/ClientLoginGetResponse.php
@@ -3,8 +3,9 @@
namespace Matrix\Responses;
use Matrix\Data\LoginFlow;
+use Matrix\Response;
-class ClientLoginGetResponse implements \JsonSerializable
+class ClientLoginGetResponse extends Response
{
/**
* @param LoginFlow[] $loginFlows
@@ -14,7 +15,7 @@ class ClientLoginGetResponse implements \JsonSerializable
)
{}
- public function jsonSerialize(): array
+ public function getBody(): array
{
return [
"flows" => $this->loginFlows,
diff --git a/matrix-specification/Responses/ClientLoginPostResponse.php b/matrix-specification/Responses/ClientLoginPostResponse.php
index 4bb893d..4a0fa7d 100644
--- a/matrix-specification/Responses/ClientLoginPostResponse.php
+++ b/matrix-specification/Responses/ClientLoginPostResponse.php
@@ -3,8 +3,9 @@
namespace Matrix\Responses;
use Matrix\Data\DiscoveryInformation;
+use Matrix\Response;
-class ClientLoginPostResponse implements \JsonSerializable
+class ClientLoginPostResponse extends Response
{
public function __construct(
private string $accessToken,
@@ -16,7 +17,7 @@ class ClientLoginPostResponse implements \JsonSerializable
)
{}
- public function jsonSerialize(): array
+ public function getBody(): array
{
return array_filter([
"access_token" => $this->accessToken,
@@ -25,6 +26,6 @@ class ClientLoginPostResponse implements \JsonSerializable
"refresh_token" => $this->refreshToken,
"user_id" => $this->userId,
"well_known" => $this->wellKnown,
- ], "is_null");
+ ], fn ($value) => ! is_null($value));
}
}
diff --git a/matrix-specification/Responses/ClientRefreshPostResponse.php b/matrix-specification/Responses/ClientRefreshPostResponse.php
index b1e1154..38519a3 100644
--- a/matrix-specification/Responses/ClientRefreshPostResponse.php
+++ b/matrix-specification/Responses/ClientRefreshPostResponse.php
@@ -2,7 +2,9 @@
namespace Matrix\Responses;
-class ClientRefreshPostResponse implements \JsonSerializable
+use Matrix\Response;
+
+class ClientRefreshPostResponse extends Response
{
public function __construct(
private string $accessToken,
@@ -11,12 +13,12 @@ class ClientRefreshPostResponse implements \JsonSerializable
)
{}
- public function jsonSerialize(): array
+ public function getBody(): array
{
return array_filter([
"access_token" => $this->accessToken,
"expires_in_ms" => $this->expiresInMilliseconds,
"refresh_token" => $this->refreshToken,
- ], "is_null");
+ ], fn ($value) => ! is_null($value));
}
}
diff --git a/matrix-specification/Responses/ClientRegisterPostResponse.php b/matrix-specification/Responses/ClientRegisterPostResponse.php
new file mode 100644
index 0000000..6ed65ce
--- /dev/null
+++ b/matrix-specification/Responses/ClientRegisterPostResponse.php
@@ -0,0 +1,39 @@
+<?php
+
+namespace Matrix\Responses;
+
+use Matrix\Requests\ClientRegisterPostRequest;
+use Matrix\Response;
+
+class ClientRegisterPostResponse extends Response
+{
+ public function __construct(
+ private string $userId,
+ private ?string $accessToken = null,
+ private ?string $deviceId = null,
+ private ?int $expiresInMilliseconds = null,
+ private ?string $homeServer = null,
+ private ?string $refreshToken = null,
+ )
+ {}
+
+ public function validateRequired(ClientRegisterPostRequest $request): void
+ {
+ $requestBody = $request->getBody();
+ if ($requestBody["inhibit_login"] === false) {
+ # TODO: validate
+ }
+ }
+
+ public function getBody(): array
+ {
+ return array_filter([
+ "access_token" => $this->accessToken,
+ "device_id" => $this->deviceId,
+ "expires_in_ms" => $this->expiresInMilliseconds,
+ "home_server" => $this->homeServer,
+ "refresh_token" => $this->refreshToken,
+ "user_id" => $this->userId,
+ ], fn ($value) => ! is_null($value));
+ }
+}
diff --git a/matrix-specification/Responses/ClientSyncGetResponse.php b/matrix-specification/Responses/ClientSyncGetResponse.php
index ccdc5e6..dbe2a29 100644
--- a/matrix-specification/Responses/ClientSyncGetResponse.php
+++ b/matrix-specification/Responses/ClientSyncGetResponse.php
@@ -7,8 +7,9 @@ use Matrix\Data\DeviceLists;
use Matrix\Data\Presence;
use Matrix\Data\Room\Rooms;
use Matrix\Data\ToDevice;
+use Matrix\Response;
-class ClientSyncGetResponse implements \JsonSerializable
+class ClientSyncGetResponse extends Response
{
/**
* @param array<string, int> $deviceOneTimeKeysCount
@@ -24,7 +25,7 @@ class ClientSyncGetResponse implements \JsonSerializable
)
{}
- public function jsonSerialize(): array
+ public function getBody(): array
{
return array_filter([
"account_data" => $this->accountData,
@@ -34,6 +35,6 @@ class ClientSyncGetResponse implements \JsonSerializable
"presence" => $this->presence,
"rooms" => $this->rooms,
"to_device" => $this->toDevice,
- ], "is_null");
+ ], fn ($value) => ! is_null($value));
}
}
diff --git a/matrix-specification/Responses/ClientUserIdFilterPostResponse.php b/matrix-specification/Responses/ClientUserIdFilterPostResponse.php
index ed7ba37..0a5d062 100644
--- a/matrix-specification/Responses/ClientUserIdFilterPostResponse.php
+++ b/matrix-specification/Responses/ClientUserIdFilterPostResponse.php
@@ -2,18 +2,23 @@
namespace Matrix\Responses;
-class ClientUserIdFilterPostResponse implements \JsonSerializable
+use Matrix\Response;
+
+class ClientUserIdFilterPostResponse extends Response
{
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");
+ 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
+ public function getBody(): array
{
return [
"filter_id" => $this->filterId,
diff --git a/matrix-specification/Responses/ClientVersionsGetResponse.php b/matrix-specification/Responses/ClientVersionsGetResponse.php
index 9ec701d..44d2cd0 100644
--- a/matrix-specification/Responses/ClientVersionsGetResponse.php
+++ b/matrix-specification/Responses/ClientVersionsGetResponse.php
@@ -2,7 +2,9 @@
namespace Matrix\Responses;
-class ClientVersionsGetResponse implements \JsonSerializable
+use Matrix\Response;
+
+class ClientVersionsGetResponse extends Response
{
/**
* @param string[] $versions
@@ -14,11 +16,11 @@ class ClientVersionsGetResponse implements \JsonSerializable
)
{}
- public function jsonSerialize(): array
+ public function getBody(): array
{
return array_filter([
"unstable_features" => $this->unstableFeatures,
"versions" => $this->versions,
- ], "is_null");
+ ], fn ($value) => ! is_null($value));
}
}
diff --git a/matrix-specification/Responses/WellKnownMatrixClientGetResponse.php b/matrix-specification/Responses/WellKnownMatrixClientGetResponse.php
index 769268f..2a0c6d1 100644
--- a/matrix-specification/Responses/WellKnownMatrixClientGetResponse.php
+++ b/matrix-specification/Responses/WellKnownMatrixClientGetResponse.php
@@ -3,16 +3,17 @@
namespace Matrix\Responses;
use Matrix\Data\DiscoveryInformation;
+use Matrix\Response;
-class WellKnownMatrixClientGetResponse implements \JsonSerializable
+class WellKnownMatrixClientGetResponse extends Response
{
public function __construct(
private DiscoveryInformation $discoveryInformation,
)
{}
- public function jsonSerialize(): array
+ public function getBody(): array
{
- return $this->discoveryInformation;
+ return $this->discoveryInformation->jsonSerialize();
}
}
diff --git a/matrix-specification/Responses/WellKnownMatrixSupportGetResponse.php b/matrix-specification/Responses/WellKnownMatrixSupportGetResponse.php
index f38e2b0..bdd971a 100644
--- a/matrix-specification/Responses/WellKnownMatrixSupportGetResponse.php
+++ b/matrix-specification/Responses/WellKnownMatrixSupportGetResponse.php
@@ -3,8 +3,9 @@
namespace Matrix\Responses;
use Matrix\Data\Contact;
+use Matrix\Response;
-class WellKnownMatrixSupportGetResponse implements \JsonSerializable
+class WellKnownMatrixSupportGetResponse extends Response
{
/**
* @param Contact[] $contacts
@@ -23,11 +24,11 @@ class WellKnownMatrixSupportGetResponse implements \JsonSerializable
}
}
- public function jsonSerialize(): array
+ public function getBody(): array
{
return array_filter([
"contacts" => $this->contacts,
"support_page" => $this->supportPage,
- ], "is_null");
+ ], fn ($value) => ! is_null($value));
}
}