Use Response parameters.

This commit is contained in:
Alex Root Junior 2017-07-25 02:52:20 +03:00
parent 03c5bfca5f
commit 8dbd4a2a73
2 changed files with 21 additions and 0 deletions

View file

@ -1,3 +1,7 @@
from aiogram import types
from .utils import json
class ValidationError(Exception):
pass
@ -9,3 +13,18 @@ class TelegramAPIError(Exception):
self.method = method
self.status = status
self.body = body
def json(self):
if not self.body:
return None
try:
data = json.dumps(self.body)
except Exception:
data = None
return data
@property
def parameters(self):
data = self.json()
if data and 'parameters' in data:
return types.ResponseParameters.deserialize(data['parameters'])