-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: nicolashimmelmann <nhimmelmann@mailbox.org>
- Loading branch information
1 parent
616af0c
commit 3caa656
Showing
3 changed files
with
243 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
<?php | ||
|
||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCA\Deck\Model\Public; | ||
|
||
use JsonSerializable; | ||
|
||
/** | ||
* A data transfer object representation of the card data to be used as a | ||
* public-facing event payload. | ||
* | ||
* @since 2.0.0 | ||
*/ | ||
final class CardEventData implements JsonSerializable { | ||
|
||
/** | ||
* @param string $title | ||
* @param string $description | ||
* @param int $boardId | ||
* @param int $stackId | ||
* @param \DateTime $lastModified | ||
* @param \DateTime $createdAt | ||
* @param array<int,string> $labels | ||
* @param array<int,string> $assignedUsers | ||
* @param int $order | ||
* @param bool $archived | ||
* @param int $commentsUnread | ||
* @param int $commentsCount | ||
* @param ?string $owner | ||
* @param ?string $lastEditor | ||
* @param ?\DateTime $duedate | ||
* @param ?\DateTime $doneAt | ||
* @param ?\DateTime $deletedAt | ||
* | ||
* @since 2.0.0 | ||
*/ | ||
public function __construct( | ||
/** @readonly */ | ||
public string $title, | ||
/** @readonly */ | ||
public string $description, | ||
/** @readonly */ | ||
public int $boardId, | ||
/** @readonly */ | ||
public int $stackId, | ||
/** @readonly */ | ||
public \DateTime $lastModified, | ||
/** @readonly */ | ||
public \DateTime $createdAt, | ||
/** @readonly */ | ||
public array $labels = [], | ||
/** @readonly */ | ||
public array $assignedUsers = [], | ||
/** @readonly */ | ||
public int $order = 0, | ||
/** @readonly */ | ||
public bool $archived = false, | ||
/** @readonly */ | ||
public int $commentsUnread = 0, | ||
/** @readonly */ | ||
public int $commentsCount = 0, | ||
/** @readonly */ | ||
public ?string $owner = null, | ||
/** @readonly */ | ||
public ?string $lastEditor, | ||
/** @readonly */ | ||
public ?\DateTime $duedate = null, | ||
/** @readonly */ | ||
public ?\DateTime $doneAt = null, | ||
/** @readonly */ | ||
public ?\DateTime $deletedAt = null, | ||
) { | ||
} | ||
|
||
|
||
/** | ||
* Serialize the object to a JSON-compatible array. | ||
* | ||
* @return array{ | ||
* title: string, | ||
* description: string, | ||
* boardId: int, | ||
* stackId: int, | ||
* lastModified: int, | ||
* createdAt: int, | ||
* labels: array<int,string>, | ||
* assignedUsers: array<int,string>, | ||
* order: int, | ||
* archived: bool, | ||
* commentsUnread: int, | ||
* commentsCount: int, | ||
* owner: ?string, | ||
* lastEditor: ?string, | ||
* duedate: ?string, | ||
* doneAt: ?string, | ||
* deletedAt: ?int, | ||
* } | ||
*/ | ||
public function jsonSerialize(): array | ||
{ | ||
return [ | ||
'title' => $this->title, | ||
'description' => $this->description, | ||
'boardId' => $this->boardId, | ||
'stackId' => $this->stackId, | ||
'lastModified' => $this->lastModified->format(DATE_ATOM), | ||
'createdAt' => $this->createdAt->format(DATE_ATOM), | ||
'labels' => $this->labels, | ||
'assignedUsers' => $this->assignedUsers, | ||
'order' => $this->order, | ||
'archived' => $this->archived, | ||
'commentsUnread' => $this->commentsUnread, | ||
'commentsCount' => $this->commentsCount, | ||
'owner' => $this->owner, | ||
'lastEditor' => $this->lastEditor, | ||
'duedate' => $this->duedate?->format(DATE_ATOM), | ||
'doneAt' => $this->doneAt?->format(DATE_ATOM), | ||
'deletedAt' => $this->deletedAt?->format(DATE_ATOM), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters