Skip to content

Commit

Permalink
add support for gov
Browse files Browse the repository at this point in the history
  • Loading branch information
apex2504 committed May 10, 2020
1 parent 5e25748 commit 2671937
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion corona_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
from .statistics import *
from .utils import *

__version__ = "0.8.2"
__version__ = "0.8.4"
__author__ = "Rob Wainwright // apex2504"
__license__ = "MIT"
25 changes: 25 additions & 0 deletions corona_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,3 +737,28 @@ async def apple_mobility_data(self, country, subregion):
subregion_string,
statistics
)


async def gov_supported_countries(self):
"""
Get a list of countries supported by Governmental data
"""
endpoint = GOV_ALL.format(self.api_url)
data = await self.request_client.make_request(endpoint)

return data


async def gov_country(self, country):
"""
Get the data from the Government of a specified country.
The data comes from the website of the government of each country so it is difficult to produce a standardised format.
As a result, we cannot create a unified class for such data. Therefore, returned data will be a list of dicts.
To get a list of attributes, you can use `list(data.keys())`
"""
endpoint = GOV_COUNTRY.format(self.api_url, country)
data = await self.request_client.make_request(endpoint)

return data
5 changes: 4 additions & 1 deletion corona_api/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@

APPLE_COUNTRIES = '{}/apple/countries'
APPLE_SUBREGIONS = APPLE_COUNTRIES + '/{}'
APPLE_SINGLE_SUBREGION = APPLE_SUBREGIONS + '/{}'
APPLE_SINGLE_SUBREGION = APPLE_SUBREGIONS + '/{}'

GOV_ALL = '{}/gov'
GOV_COUNTRY = GOV_ALL + '/{}'
2 changes: 1 addition & 1 deletion corona_api/request.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import aiohttp
from .exceptions import NotFound, APIError

ver = "0.8.2"
ver = "0.8.4"

class RequestClient:
def __init__(self):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
setup(
name = 'corona_api',
packages = ['corona_api'],
version = '0.8.2',
version = '0.8.4',
license='MIT',
description = 'An asynchronous wrapper for the corona.lmao.ninja API written in Python.',
long_description= long_desc,
Expand Down

0 comments on commit 2671937

Please sign in to comment.