Ejemplo n.º 1
0
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,
    }
Ejemplo n.º 2
0
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,
    }
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
 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