summaryrefslogtreecommitdiff
path: root/matrix-specification/Requests/ClientKeysUploadPostRequest.php
blob: 40d9eae68874501e992d32eddee2bd3deace7214 (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
<?php

namespace Matrix\Requests;

use Matrix\Data\DeviceKeys;
use Matrix\Data\KeyObject;

class ClientKeysUploadPostRequest implements RateLimited, RequiresAuthentication, \JsonSerializable
{
  /**
   * @param array<string, string|KeyObject> $fallbackKeys
   * @param array<string, string|KeyObject> $oneTimeKeys
   */
  public function __construct(
    private ?DeviceKeys $deviceKeys = null,
    private ?array $fallbackKeys = null,
    private ?array $oneTimeKeys = null,
  )
  {}

  public function jsonSerialize(): array
  {
    return array_filter([
      "device_keys" => $this->deviceKeys,
      "fallback_keys" => $this->fallbackKeys,
      "one_time_keys" => $this->oneTimeKeys,
    ], "is_null");
  }
}