Skip to content

Commit

Permalink
Merge pull request nextcloud#32 from DriverXX/master
Browse files Browse the repository at this point in the history
Add REST API support for News v15
  • Loading branch information
BernhardPosselt authored Feb 6, 2021
2 parents e060f00 + e7f5144 commit 11680b5
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions nextcloud_news_updater/api/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,32 @@ def _parse_feeds_json(self, feeds: dict, userID: str) -> List[Feed]:
return [Feed(info['feedId'], info['userId']) for info in feeds]


class WebApiV15(WebApi):
"""REST API for Nextcloud News v15+"""

def __init__(self, config: Config) -> None:
super().__init__(config)
base_url = self._generify_base_url(config.url)
self.base_url = '%sindex.php/apps/news/api/v1-2' % base_url
self.before_cleanup_url = '%s/cleanup/before-update' % self.base_url
self.after_cleanup_url = '%s/cleanup/after-update' % self.base_url
self.all_feeds_url = '%s/feeds/all' % self.base_url
self.update_url = '%s/feeds/update' % self.base_url

def _parse_feeds_json(self, feeds_json: Any, userID: str) -> List[Feed]:
if not feeds_json:
return []
feeds_json = feeds_json['feeds']
return [Feed(info['id'], info['userId']) for info in feeds_json]


def create_web_api(config: Config) -> WebApi:
if config.apilevel == 'v1-2':
return WebApi(config)
if config.apilevel == 'v2':
return WebApiV2(config)
if config.apilevel == 'v15':
return WebApiV15(config)


class HttpClient:
Expand Down

0 comments on commit 11680b5

Please sign in to comment.