summaryrefslogtreecommitdiffstats
path: root/lib/Model/Invitation.php
blob: 77456b25537eac49592459d929c41373dcff0a35 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php

declare(strict_types=1);
/**
 * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

namespace OCA\Talk\Model;

use OCP\AppFramework\Db\Entity;

/**
 * @method void setUserId(string $userId)
 * @method string getUserId()
 * @method void setState(int $state)
 * @method int getState()
 * @method void setLocalRoomId(int $localRoomId)
 * @method int getLocalRoomId()
 * @method void setAccessToken(string $accessToken)
 * @method string getAccessToken()
 * @method void setRemoteServerUrl(string $remoteServerUrl)
 * @method string getRemoteServerUrl()
 * @method void setRemoteToken(string $remoteToken)
 * @method string getRemoteToken()
 * @method void setRemoteAttendeeId(int $remoteAttendeeId)
 * @method int getRemoteAttendeeId()
 * @method void setInviterCloudId(string $inviterCloudId)
 * @method string getInviterCloudId()
 * @method void setInviterDisplayName(string $inviterDisplayName)
 * @method string getInviterDisplayName()
 * @method void setLocalCloudId(string $localCloudId)
 * @method string getLocalCloudId()
 */
class Invitation extends Entity implements \JsonSerializable {
	public const STATE_PENDING = 0;
	public const STATE_ACCEPTED = 1;

	protected string $userId = '';
	protected int $state = self::STATE_PENDING;
	protected int $localRoomId = 0;
	protected string $accessToken = '';
	protected string $remoteServerUrl = '';
	protected string $remoteToken = '';
	protected int $remoteAttendeeId = 0;
	protected string $inviterCloudId = '';
	protected string $inviterDisplayName = '';
	protected string $localCloudId = '';

	public function __construct() {
		$this->addType('userId', 'string');
		$this->addType('state', 'int');
		$this->addType('localRoomId', 'int');
		$this->addType('accessToken', 'string');
		$this->addType('remoteServerUrl', 'string');
		$this->addType('remoteToken', 'string');
		$this->addType('remoteAttendeeId', 'int');
		$this->addType('inviterCloudId', 'string');
		$this->addType('inviterDisplayName', 'string');
		$this->addType('localCloudId', 'string');
	}

	/**
	 * @return array{id: int, localCloudId: string, remoteAttendeeId: int, remoteServerUrl: string, remoteToken: string, state: int, userId: string, inviterCloudId: string, inviterDisplayName: string}
	 */
	public function jsonSerialize(): array {
		return [
			'id' => $this->getId(),
			'userId' => $this->getUserId(),
			'state' => $this->getState(),
			'localCloudId' => $this->getLocalCloudId(),
			'remoteServerUrl' => $this->getRemoteServerUrl(),
			'remoteToken' => $this->getRemoteToken(),
			'remoteAttendeeId' => $this->getRemoteAttendeeId(),
			'inviterCloudId' => $this->getInviterCloudId(),
			'inviterDisplayName' => $this->getInviterDisplayName() ?: $this->getInviterCloudId(),
		];
	}
}