]> source.dussan.org Git - nextcloud-server.git/commitdiff
enh: implement JsonSerializable
authorChristopher Ng <chrng8@gmail.com>
Mon, 31 Jul 2023 19:10:50 +0000 (12:10 -0700)
committerChristopher Ng <chrng8@gmail.com>
Thu, 3 Aug 2023 22:30:11 +0000 (15:30 -0700)
Signed-off-by: Christopher Ng <chrng8@gmail.com>
apps/files_reminders/lib/Model/RichReminder.php

index 21b42d9c2e78665f0532a31af0922e0e368bf86e..76c3d8dd22bc108de6322d264be2db0e752c7aab 100644 (file)
@@ -26,12 +26,14 @@ declare(strict_types=1);
 
 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,
@@ -59,4 +61,14 @@ class RichReminder extends Reminder {
        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(),
+               ];
+       }
 }