Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@classmethod
def de_json(cls, json_type):
obj = cls.check_json(json_type)
location = Location.de_json(obj['location'])
title = obj['title']
address = obj['address']
foursquare_id = obj.get('foursquare_id')
return cls(location, title, address, foursquare_id)
if 'video' in obj:
opts['video'] = Video.de_json(obj['video'])
content_type = 'video'
if 'video_note' in obj:
opts['video_note'] = VideoNote.de_json(obj['video_note'])
content_type = 'video_note'
if 'voice' in obj:
opts['voice'] = Audio.de_json(obj['voice'])
content_type = 'voice'
if 'caption' in obj:
opts['caption'] = obj['caption']
if 'contact' in obj:
opts['contact'] = Contact.de_json(json.dumps(obj['contact']))
content_type = 'contact'
if 'location' in obj:
opts['location'] = Location.de_json(obj['location'])
content_type = 'location'
if 'venue' in obj:
opts['venue'] = Venue.de_json(obj['venue'])
content_type = 'venue'
if 'new_chat_member' in obj:
opts['new_chat_member'] = User.de_json(obj['new_chat_member'])
content_type = 'new_chat_member'
if 'new_chat_members' in obj:
chat_members = obj['new_chat_members']
nms = []
for m in chat_members:
nms.append(User.de_json(m))
opts['new_chat_members'] = nms
content_type = 'new_chat_members'
if 'left_chat_member' in obj:
opts['left_chat_member'] = User.de_json(obj['left_chat_member'])
@classmethod
def de_json(cls, json_type):
obj = cls.check_json(json_type)
id = obj['id']
from_user = User.de_json(obj['from'])
location = None
if 'location' in obj:
location = Location.de_json(obj['location'])
query = obj['query']
offset = obj['offset']
return cls(id, from_user, location, query, offset)
@classmethod
def de_json(cls, json_type):
obj = cls.check_json(json_type)
result_id = obj['result_id']
from_user = User.de_json(obj['from'])
query = obj['query']
location = None
if 'location' in obj:
location = Location.de_json(obj['location'])
inline_message_id = obj.get('inline_message_id')
return cls(result_id, from_user, query, location, inline_message_id)