Skip to content

Commit

Permalink
enh: implement JsonSerializable
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <chrng8@gmail.com>
  • Loading branch information
Pytal committed Aug 3, 2023
1 parent 4fabd77 commit 774e3e6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion apps/files_reminders/lib/Model/RichReminder.php
Expand Up @@ -26,12 +26,14 @@

namespace OCA\FilesReminders\Model;

use DateTimeInterface;
use JsonSerializable;
use OCA\FilesReminders\Db\Reminder;
use OCA\FilesReminders\Exception\NodeNotFoundException;
use OCP\Files\IRootFolder;
use OCP\Files\Node;

class RichReminder extends Reminder {
class RichReminder extends Reminder implements JsonSerializable {
public function __construct(
private Reminder $reminder,
private IRootFolder $root,
Expand Down Expand Up @@ -59,4 +61,14 @@ protected function getter(string $name): mixed {
public function __call(string $methodName, array $args) {
return $this->reminder->__call($methodName, $args);
}

public function jsonSerialize(): array {
return [
'userId' => $this->getUserId(),
'fileId' => $this->getFileId(),
'remindAt' => $this->getRemindAt()->format(DateTimeInterface::ATOM), // ISO 8601
'createdAt' => $this->getCreatedAt()->format(DateTimeInterface::ATOM), // ISO 8601
'notified' => $this->getNotified(),
];
}
}

0 comments on commit 774e3e6

Please sign in to comment.