def request(self, path, method='GET', **kwargs):
try:
url = ENDPOINT_URL + path
response = requests.request(
method=method,
url=url,
headers=self.headers,
timeout=self.timeout,
**kwargs
)
except requests.HTTPError as e:
response = json.loads(e.read())
except requests.ConnectionError as e:
raise VoucherifyError(e)
if response.headers.get('content-type') and 'json' in response.headers['content-type']:
result = response.json()
else:
result = response.text
if isinstance(result, dict) and result.get('error'):
raise VoucherifyError(result)
return result
评论列表
文章目录