def test_make_payload(): result = make_payload('Sports', 'listMarketBook', {'someParam': 123}) assert result == { 'jsonrpc': '2.0', 'method': 'SportsAPING/v1.0/listMarketBook', 'params': {'someParam': 123}, 'id': 1, }
def test_make_payload(): result = make_payload('Sports', 'listMarketBook', {'someParam': 123}) assert result == { 'jsonrpc': '2.0', 'method': 'SportsAPING/v1.0/listMarketBook', 'params': { 'someParam': 123 }, 'id': 1, }
def make_api_request(self, base, method, params, codes=None, model=None): payload = utils.make_payload(base, method, params) response = self.session.post( self.api_url, data=json.dumps(payload, cls=utils.BetfairEncoder), headers=self.headers, timeout=self.timeout, ) utils.check_status_code(response, codes=codes) result = utils.result_or_error(response) return utils.process_result(result, model)
def make_api_request(self, base, method, params, codes=None, model=None, url=None): payload = utils.make_payload(base, method, params) response = self.session.post( url if url else self.api_url, data=json.dumps(payload, cls=utils.BetfairEncoder), headers=self.headers, timeout=self.timeout, ) utils.check_status_code(response, codes=codes) result = utils.result_or_error(response) return utils.process_result(result, model)
def make_api_request(self, base, method, params, codes=None, model=None, url=None): payload = utils.make_payload(base, method, params) # print utils.model_to_dict(payload) response = self.session.post( url if url else self.api_url, data=json.dumps(payload, cls=utils.BetfairEncoder), headers=self.headers, timeout=self.timeout, ) utils.check_status_code(response, codes=codes) result = utils.result_or_error(response) # print json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(',', ': ')) return utils.process_result(result, model)
def make_api_request(self, base, method, params, codes=None, model=None): payload = utils.make_payload(base, method, params) if base=="Sports": api_url = self.betting_api_url else: api_url = self.account_api_url data = json.dumps(payload, cls=utils.BetfairEncoder) print("Data: {}".format(data)) response = self.session.post( api_url, data=data, headers=self.headers, timeout=self.timeout, ) # print(response.json()) utils.check_status_code(response, codes=codes) result = utils.result_or_error(response) processed_result = utils.process_result(result, model) return processed_result