diff options
| author | Daniel Weipert <git@mail.dweipert.de> | 2025-12-13 16:27:53 +0100 |
|---|---|---|
| committer | Daniel Weipert <git@mail.dweipert.de> | 2025-12-13 16:27:53 +0100 |
| commit | 2386148b8f048ba40d9f26cc97898bdcdc778ea2 (patch) | |
| tree | 48ca45de3dc6133cb0225eba8c5917f813082b2b /matrix-specification/Requests/ClientRegisterPostRequest.php | |
| parent | b19a8f63ad727a3633885d3f2b81edf8181a53b9 (diff) | |
Diffstat (limited to 'matrix-specification/Requests/ClientRegisterPostRequest.php')
| -rw-r--r-- | matrix-specification/Requests/ClientRegisterPostRequest.php | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/matrix-specification/Requests/ClientRegisterPostRequest.php b/matrix-specification/Requests/ClientRegisterPostRequest.php new file mode 100644 index 0000000..74c0c1d --- /dev/null +++ b/matrix-specification/Requests/ClientRegisterPostRequest.php @@ -0,0 +1,57 @@ +<?php + +namespace Matrix\Requests; + +use Matrix\Data\AuthenticationData; +use Matrix\Enums\ApiPathVersion; +use Matrix\Enums\UserRegistrationKind; +use Matrix\Request; + +/** + * @see https://spec.matrix.org/v1.16/client-server-api/#post_matrixclientv3register + */ +class ClientRegisterPostRequest extends Request implements RateLimited +{ + public function __construct( + private AuthenticationData $authenticationData, + private string $password, + private ?UserRegistrationKind $kind = null, + private ?string $deviceId = null, + private ?bool $inhibitLogin = null, + private ?string $initialDeviceDisplayName = null, + private ?string $username = null, + private ?bool $refreshToken = null, + ) + {} + + public function setDefaults(): void + { + $this->kind ??= UserRegistrationKind::USER; + $this->inhibitLogin ??= false; + } + + public function getUri(string $scheme, string $serverName, ApiPathVersion $version): string + { + return "{$scheme}://{$serverName}/_matrix/client/{$version}/register"; + } + + public function getQueryParameters(): array + { + return array_filter([ + "kind" => $this->kind, + ], fn ($value) => ! is_null($value)); + } + + public function getBody(): array + { + return array_filter([ + "auth" => $this->authenticationData, + "device_id" => $this->deviceId, + "inhibit_login" => $this->inhibitLogin, + "initial_device_display_name" => $this->initialDeviceDisplayName, + "password" => $this->password, + "refresh_token" => $this->refreshToken, + "username" => $this->username, + ], fn ($value) => ! is_null($value)); + } +} |
