Skip to content

Commit

Permalink
Clean log in jnclabs
Browse files Browse the repository at this point in the history
  • Loading branch information
gvellut committed Jul 1, 2023
1 parent 99d9078 commit a24fea0
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions jncep/jnclabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,14 @@ async def fetch_events(self, skip=None, **params):

@with_cache
async def fetch_follows(self, skip=None):
logger.debug(f"LABS /series only_follows skip={skip}")
path = f"{LABS_API_PATH_BASE}/series"
body = json.dumps({"only_follows": True})
return await self._fetch_resource(path, body=body, skip=skip)
return await self._fetch_resource(path, "POST", body=body, skip=skip)

async def _fetch_resource(self, path, *, params=None, body=None, skip=None):
logger.debug(f"LABS {path} params={params} skip={skip}")
async def _fetch_resource(
self, path, verb="GET", *, params=None, body=None, skip=None
):
logger.debug(f"LABS {verb} {path} params={params} body={body} skip={skip}")

if not params:
params = {}
Expand All @@ -198,9 +199,6 @@ async def _fetch_resource(self, path, *, params=None, body=None, skip=None):
if skip is not None:
params.update(skip=skip)

# POST used for follows filtering
verb = "POST" if body else "GET"

r = await self._call_labs_api_authenticated(
verb, path, params=params, body=body
)
Expand All @@ -210,14 +208,14 @@ async def _fetch_resource(self, path, *, params=None, body=None, skip=None):
return d

async def _call_labs_api_authenticated(
self, method, path, *, headers=None, params=None, body=None, **kwargs
self, verb, path, *, headers=None, params=None, body=None, **kwargs
):
# ~common base path + params set in caller: some calls (embed) to the Labs API
# do not have them
auth = {"Authorization": f"Bearer {self.token}"}
r = await self._call_authenticated(
self.labs_api_session,
method,
verb,
path,
auth,
headers=headers,
Expand All @@ -233,7 +231,7 @@ async def _call_labs_api_authenticated(
async def _call_authenticated(
self,
session,
method,
verb,
path,
auth,
*,
Expand All @@ -248,7 +246,7 @@ async def _call_authenticated(
headers = {**auth, **headers}

r = await session.request(
method, path=path, headers=headers, params=params, data=body, **kwargs
verb, path=path, headers=headers, params=params, data=body, **kwargs
)
r.raise_for_status()

Expand Down

0 comments on commit a24fea0

Please sign in to comment.