summaryrefslogtreecommitdiff
path: root/matrix-specification/Responses/ClientLoginPostResponse.php
blob: 4a0fa7d50ad621e36391ce88bba78894ceebd0c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php

namespace Matrix\Responses;

use Matrix\Data\DiscoveryInformation;
use Matrix\Response;

class ClientLoginPostResponse extends Response
{
  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 getBody(): 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,
    ], fn ($value) => ! is_null($value));
  }
}