diff options
Diffstat (limited to 'matrix-specification/Responses/ClientRegisterPostResponse.php')
| -rw-r--r-- | matrix-specification/Responses/ClientRegisterPostResponse.php | 39 |
1 files changed, 39 insertions, 0 deletions
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)); + } +} |
