api.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:upstox-python 作者: upstox 项目源码 文件源码
def api_call_helper(self, name, http_method, params, data):
        # helper formats the url and reads error codes nicely
        url = self.config['host'] + self.config['routes'][name]

        if params is not None:
            url = url.format(**params)

        response = self.api_call(url, http_method, data)

        if response.status_code != 200:
            raise requests.HTTPError(response.text)

        body = json.loads(response.text)

        if is_status_2xx(body['code']):
            # success
            return body['data']
        else:
            raise requests.HTTPError(response.text)

        return
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号