diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Db/Feed.php | 24 | ||||
-rw-r--r-- | lib/Db/Folder.php | 6 | ||||
-rw-r--r-- | lib/Db/IAPI.php | 1 | ||||
-rw-r--r-- | lib/Db/Item.php | 22 |
4 files changed, 53 insertions, 0 deletions
diff --git a/lib/Db/Feed.php b/lib/Db/Feed.php index c468f8272..008390e2b 100644 --- a/lib/Db/Feed.php +++ b/lib/Db/Feed.php @@ -660,4 +660,28 @@ class Feed extends Entity implements IAPI, \JsonSerializable ] ); } + + public function toAPI2(): array + { + $result = [ + 'id' => $this->getId(), + 'name' => $this->getTitle(), + 'faviconLink' => $this->getFaviconLink(), + 'folderId' => $this->getFolderId(), + 'ordering' => $this->getOrdering(), + 'fullTextEnabled' => $this->getFullTextEnabled(), + 'updateMode' => $this->getUpdateMode(), + 'isPinned' => $this->getPinned() + ]; + + if (!empty($this->getLastUpdateError())) { + $result['error'] = [ + 'code' => 1, + 'message' => $this->getLastUpdateError() + ]; + } + + return $result; + } + } diff --git a/lib/Db/Folder.php b/lib/Db/Folder.php index 6f208309b..1845d8e82 100644 --- a/lib/Db/Folder.php +++ b/lib/Db/Folder.php @@ -172,4 +172,10 @@ class Folder extends Entity implements IAPI, \JsonSerializable ] ); } + + public function toAPI2(): array + { + return $this->toAPI(); + } + } diff --git a/lib/Db/IAPI.php b/lib/Db/IAPI.php index c6f844147..58897e9d3 100644 --- a/lib/Db/IAPI.php +++ b/lib/Db/IAPI.php @@ -16,4 +16,5 @@ namespace OCA\News\Db; interface IAPI { public function toAPI(); + public function toAPI2(); } diff --git a/lib/Db/Item.php b/lib/Db/Item.php index 2d87babf7..6e09fde31 100644 --- a/lib/Db/Item.php +++ b/lib/Db/Item.php @@ -574,6 +574,28 @@ class Item extends Entity implements IAPI, \JsonSerializable ]; } + public function toAPI2(): array + { + return [ + 'id' => $this->getId(), + 'url' => $this->getUrl(), + 'title' => $this->getTitle(), + 'author' => $this->getAuthor(), + 'publishedAt' => date('c', $this->getPubDate()), + 'updatedAt' => date('c', $this->getUpdatedDate()), + 'enclosure' => [ + 'mimeType' => $this->getEnclosureMime(), + 'url' => $this->getEnclosureLink() + ], + 'body' => $this->getBody(), + 'feedId' => $this->getFeedId(), + 'isUnread' => $this->isUnread(), + 'isStarred' => $this->isStarred(), + 'fingerprint' => $this->getFingerprint(), + 'contentHash' => $this->getContentHash() + ]; + } + /** * Format for exporting. * |