From 4a8bb0341e65afbdcce4e0289e56247edfdf0c4f Mon Sep 17 00:00:00 2001 From: Sergey G Date: Sat, 5 Nov 2016 13:07:39 +0500 Subject: [PATCH] Add `Attachments Preview` --- trello/attachments.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/trello/attachments.py b/trello/attachments.py index 8f15c84c..da90a31e 100644 --- a/trello/attachments.py +++ b/trello/attachments.py @@ -27,10 +27,32 @@ def from_json(json_obj): isUpload = json_obj.get("isUpload") mimeType = json_obj.get("mimeType") name = json_obj.get("name") - previews = json_obj.get("previews") + previews = [AttachmentsPreview.from_json(preview_json) for preview_json in json_obj.get("previews")] url = json_obj.get("url") return Attachments(id, bytes, date, edgeColor, idMember, isUpload, mimeType, name, previews, url) def __repr__(self): return u"".format(self.name) + + +class AttachmentsPreview(object): + def __init__(self, bytes, url, width, height, scaled): + self.bytes = bytes + self.url = url + self.width = width + self.height = height + self.is_scaled = scaled + + @staticmethod + def from_json(json_obj): + bytes = json_obj.get("bytes") + url = json_obj.get("url") + width = json_obj.get("width") + height = json_obj.get("height") + scaled = json_obj.get("scaled") + + return AttachmentsPreview(bytes, url, width, height, scaled) + + def __repr__(self): + return u"