Change API Url getting method.

This commit is contained in:
Alex Root Junior 2017-07-11 23:16:08 +03:00
parent 14527ef2bf
commit 019bf06f71
2 changed files with 10 additions and 2 deletions

View file

@ -83,7 +83,7 @@ def _compose_data(params, files=None):
async def request(session, token, method, data=None, files=None):
log.debug(f"Make request: '{method}' with data: {data or {}} and files {files or {}}")
data = _compose_data(data, files)
url = API_URL.format(token=token, method=method)
url = Methods.api_url(token=token, method=method)
async with session.post(url, data=data) as response:
return await _check_result(method, response)
@ -137,3 +137,11 @@ class Methods:
SEND_GAME = 'sendGame'
SET_GAME_SCORE = 'setGameScore'
GET_GAME_HIGH_SCORES = 'getGameHighScores'
@staticmethod
def api_url(token, method):
return API_URL.format(token=token, method=method)
@staticmethod
def file_url(token, path):
return FILE_URL.format(token=token, path=path)

View file

@ -94,7 +94,7 @@ class BaseBot:
destination = io.BytesIO()
session = self.create_temp_session()
url = api.FILE_URL.format(token=self.__token, path=file_path)
url = api.Methods.file_url(token=self.__token, path=file_path)
dest = destination if isinstance(destination, io.IOBase) else open(destination, 'wb')
try: