@@ -72,8 +72,8 @@ def make_json_request(self, method_name, params=None, files=None, method='post',
7272 if not response ['ok' ]:
7373 raise ApiException ('Error code: {error_code} Description: {description}' .format (** response ), method )
7474
75- if hasattr (return_type , 'de_json' ):
76- return return_type .de_json (response ['result' ])
75+ if issubclass (return_type , types . JsonDeserializable ):
76+ return types .de_json (return_type , response ['result' ])
7777 return response ['result' ]
7878
7979 def get_updates (self , ** kwargs ):
@@ -85,7 +85,7 @@ def get_updates(self, **kwargs):
8585 :return: list of Updates
8686 """
8787 json_updates = self .make_json_request ('getUpdates' , params = util .xmerge (kwargs ))
88- return [types .Update . de_json (update ) for update in json_updates ]
88+ return [types .de_json (types . Update , update ) for update in json_updates ]
8989
9090 def get_me (self ):
9191 return self .make_json_request ('getMe' , return_type = types .User )
@@ -342,7 +342,7 @@ def get_chat_administrators(self, chat_id):
342342 :return: Array of ChatMember objects
343343 """
344344 response = self .make_json_request ('getChatAdministrators' , params = {'chat_id' : chat_id })
345- return [ types .ChatMember . de_json ( e ) for e in response ]
345+ return types .de_json_array ( types . ChatMember , response )
346346
347347 def get_chat_members_count (self , chat_id ):
348348 """
@@ -369,7 +369,7 @@ def get_chat_member(self, chat_id, user_id):
369369 def edit_message_text (self , text , ** kwargs ):
370370 params = util .xmerge ({'text' : text }, kwargs )
371371 response = self .make_json_request ('editMessageText' , params = params )
372- return response if type (response ) == bool else types .Message . de_json (response )
372+ return response if type (response ) == bool else types .de_json (types . Message , response )
373373
374374 def edit_message_caption (self , caption , ** kwargs ):
375375 params = util .xmerge ({'caption' : caption }, kwargs )
0 commit comments