From 982dd5069e9c41bdddb8d59f33f0006a5895798d Mon Sep 17 00:00:00 2001 From: Fsoky Date: Sun, 19 Sep 2021 13:37:52 +0600 Subject: [PATCH] update 2.0 --- .gitignore | 8 ++++++-- donationalerts_api/asyncio_api.py | 25 +++--------------------- donationalerts_api/donationalerts_api.py | 24 +++-------------------- 3 files changed, 12 insertions(+), 45 deletions(-) diff --git a/.gitignore b/.gitignore index e557799..fa752a4 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,10 @@ __pycache__ /dist -# Ignore pyproject +# Ignore pyproject.toml -pyproject.toml \ No newline at end of file +pyproject.toml + +# Ignore poetry.lock + +poetry.lock \ No newline at end of file diff --git a/donationalerts_api/asyncio_api.py b/donationalerts_api/asyncio_api.py index 3b05617..17c4f4a 100644 --- a/donationalerts_api/asyncio_api.py +++ b/donationalerts_api/asyncio_api.py @@ -12,7 +12,7 @@ DEFAULT_URL = "https://www.donationalerts.com/oauth/" DEFAULT_API_LINK = "https://www.donationalerts.com/api/v1/" -class DonationAlertsApi: +class DonationAlertsAPI: def __init__(self, client_id, client_secret, redirect_uri, scopes): symbols = [",", ", ", " ", "%20"] @@ -59,33 +59,14 @@ class DonationAlertsApi: obj ) if full_json else obj["access_token"] - async def donations_list(self, access_token, *, current_page: int=1, from_page: int=1, last_page: int=13, per_page: int=30, to: int=30, total: int=385): + async def donations_list(self, access_token, *, page: int=1): headers = { "Authorization": f"Bearer {access_token}", "Content-Type": "application/x-www-form-urlencoded" } - """Pagination in development""" - meta = { - "current_page": current_page, - "from": from_page, - "last_page": last_page, - "path": f"{DEFAULT_API_LINK}alerts/donations", - "per_page": per_page, - "to": to, - "total": total - } - links = { - "first": f"{DEFAULT_API_LINK}alerts/donations?page={from_page}", - "last": f"{DEFAULT_API_LINK}alerts/donations?page={last_page}", - "last": f"{DEFAULT_API_LINK}alerts/donations?page={last_page}", - "next": f"{DEFAULT_API_LINK}alerts/donations?page={current_page + 1}", - "prev": None - } - async with aiohttp.ClientSession() as session: - async with session.get(f"{DEFAULT_API_LINK}alerts/donations", headers=headers) as response: - print(response) + async with session.get(f"{DEFAULT_API_LINK}alerts/donations?page={page}", headers=headers) as response: objs = await response.json() donations = Donations(objects=objs) diff --git a/donationalerts_api/donationalerts_api.py b/donationalerts_api/donationalerts_api.py index 16cae22..14a6291 100644 --- a/donationalerts_api/donationalerts_api.py +++ b/donationalerts_api/donationalerts_api.py @@ -11,7 +11,7 @@ DEFAULT_URL = "https://www.donationalerts.com/oauth/" DEFAULT_API_LINK = "https://www.donationalerts.com/api/v1/" -class DonationAlertsApi: +class DonationAlertsAPI: """ This class describes work with Donation Alerts API """ @@ -60,31 +60,13 @@ class DonationAlertsApi: obj ) if full_json else obj["access_token"] - def donations_list(self, access_token, *, current_page: int=1, from_page: int=1, last_page: int=13, per_page: int=30, to: int=30, total: int=385): + def donations_list(self, access_token, *, page: int=1): headers = { "Authorization": f"Bearer {access_token}", "Content-Type": "application/x-www-form-urlencoded" } - """Pagination in development""" - meta = { - "current_page": current_page, - "from": from_page, - "last_page": last_page, - "path": f"{DEFAULT_API_LINK}alerts/donations", - "per_page": per_page, - "to": to, - "total": total - } - links = { - "first": f"{DEFAULT_API_LINK}alerts/donations?page={from_page}", - "last": f"{DEFAULT_API_LINK}alerts/donations?page={last_page}", - "last": f"{DEFAULT_API_LINK}alerts/donations?page={last_page}", - "next": f"{DEFAULT_API_LINK}alerts/donations?page={current_page + 1}", - "prev": None - } - - objs = requests.get(f"{DEFAULT_API_LINK}alerts/donations", headers=headers).json() + objs = requests.get(f"{DEFAULT_API_LINK}alerts/donations?page={page}", headers=headers).json() donations = Donations(objects=objs) for obj in objs["data"]: