Article voting and endorsing

This commit is contained in:
Eriks Karls 2019-08-27 11:03:08 +03:00
parent bc4ba671d6
commit 95570b7c17
2 changed files with 15 additions and 0 deletions

View File

@ -1943,3 +1943,14 @@ class Citizen(classes.CitizenAPI):
elite = 1.1 if elite else 1
dmg = int(dmg * elite)
return dmg * (1.1 if ne else 1.)
def endorse_article(self, article_id: int, amount: int) -> bool:
if amount in (5, 50, 100):
resp = self._post_main_donate_article(article_id, amount).json()
return not bool(resp.get('error'))
else:
return False
def vote_article(self, article_id: int) -> bool:
resp = self._post_main_vote_article(article_id).json()
return not bool(resp.get('error'))

View File

@ -800,6 +800,10 @@ Class for unifying eRepublik known endpoints and their required/optional paramet
data = dict(_token=self.token, check=check, **kwargs)
return self.post("{}/main/travel".format(self.url), data=data)
def _post_main_vote_article(self, article_id: int) -> Response:
data = dict(_token=self.token, articleId=article_id)
return self.post("{}/main/vote-article".format(self.url), data=data)
def _post_main_travel_data(self, **kwargs) -> Response:
return self.post("{}/main/travelData".format(self.url), data=dict(_token=self.token, **kwargs))