Organisation account fetcher - UNSTABLE

This commit is contained in:
Eriks Karls 2019-08-12 12:54:58 +03:00
parent 416c391d21
commit 4f436292af
2 changed files with 13 additions and 0 deletions

View File

@ -1895,3 +1895,13 @@ class Citizen(classes.CitizenAPI):
def get_game_token_offers(self):
r = self._post_economy_game_tokens_market('retrieve').json()
return {v.get('id'): dict(amount=v.get('amount'), price=v.get('price')) for v in r.get("topOffers")}
def fetch_organisation_account(self, org_id: int):
r = self._get_economy_citizen_accounts(org_id)
table = re.search(r'(<table class="holder racc" .*</table>)', r.text, re.I | re.M | re.S)
if table:
account = re.findall(r'>(\d+.\d+)<', table.group(1))
if account:
return {"gold": account[0], "cc": account[1], 'ok': True}
return {"gold": 0, "cc": 0, 'ok': False}

View File

@ -480,6 +480,9 @@ Class for unifying eRepublik known endpoints and their required/optional paramet
def _get_country_military(self, country: str) -> Response:
return self.get("{}/country/military/{}".format(self.url, country))
def _get_economy_citizen_accounts(self, organisation_id: int) -> Response:
return self.get("{}/economy/citizen-accounts/{}".format(self.url, organisation_id))
def _get_economy_inventory_items(self) -> Response:
return self.get("{}/economy/inventory-items/".format(self.url))