2015-07-08 15:10:08 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
|
2015-07-09 16:40:44 +02:00
|
|
|
import json
|
|
|
|
|
|
|
|
|
2015-07-08 15:10:08 +02:00
|
|
|
class UserProfilePhotos(object):
|
2015-07-09 02:58:13 +02:00
|
|
|
def __init__(self,
|
|
|
|
total_count,
|
|
|
|
photos):
|
|
|
|
self.total_count = total_count
|
|
|
|
self.photos = photos
|
2015-07-08 15:10:08 +02:00
|
|
|
|
|
|
|
@staticmethod
|
2015-07-09 02:15:46 +02:00
|
|
|
def de_json(data):
|
2015-07-08 15:10:08 +02:00
|
|
|
if 'photos' in data:
|
|
|
|
from telegram import PhotoSize
|
|
|
|
photos = []
|
|
|
|
for photo in data['photos']:
|
2015-07-09 02:15:46 +02:00
|
|
|
photos.append([PhotoSize.de_json(x) for x in photo])
|
2015-07-08 15:10:08 +02:00
|
|
|
else:
|
2015-07-08 15:14:07 +02:00
|
|
|
photos = None
|
2015-07-08 15:10:08 +02:00
|
|
|
|
|
|
|
return UserProfilePhotos(total_count=data.get('total_count', None),
|
|
|
|
photos=photos)
|
2015-07-09 16:40:44 +02:00
|
|
|
|
|
|
|
def to_json(self):
|
|
|
|
json_data = {}
|
|
|
|
if self.total_count:
|
|
|
|
json_data['total_count'] = self.total_count
|
|
|
|
if self.photos:
|
|
|
|
json_data['photos'] = []
|
|
|
|
for photo in self.photos:
|
|
|
|
json_data['photos'].append([x.to_json() for x in photo])
|
|
|
|
return json.dumps(json_data)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.to_json()
|