MCPcopy Create free account
hub / github.com/LibraryOfCongress/api.congress.gov / _MethodWrapper

Class _MethodWrapper

api_client/python/cdg_client.py:17–32  ·  view source on GitHub ↗

Wrap request method to facilitate queries. Supports requests signature.

Source from the content-addressed store, hash-verified

15
16
17class _MethodWrapper:
18 """ Wrap request method to facilitate queries. Supports requests signature. """
19
20 def __init__(self, parent, http_method):
21 self._parent = parent
22 self._method = getattr(parent._session, http_method)
23
24 def __call__(self, endpoint, *args, **kwargs): # full signature passed here
25 response = self._method(
26 urljoin(self._parent.base_url, endpoint), *args, **kwargs
27 )
28 # unpack
29 if response.headers.get("content-type", "").startswith("application/json"):
30 return response.json(), response.status_code
31 else:
32 return response.content, response.status_code
33
34
35class CDGClient:

Callers 1

__getattr__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected