From 3040ab1ef996a4623dc901a62934353a37a232b7 Mon Sep 17 00:00:00 2001 From: Pavel Kalinichenko Date: Thu, 6 Apr 2017 17:50:12 +0300 Subject: [PATCH] add new properrty - plugin_data to cover https://developers.trello.com/advanced-reference/card#get-1-cards-card-id-or-shortlink-pluginData --- .gitignore | 3 ++- trello/card.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3ac32710..037ff86f 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ dist .pydevproject .idea/ .tox/ -.DS_Store \ No newline at end of file +.DS_Store +example \ No newline at end of file diff --git a/trello/card.py b/trello/card.py index cf937c34..335f6c81 100644 --- a/trello/card.py +++ b/trello/card.py @@ -88,6 +88,18 @@ def checklists(self): self._checklists = None return self._checklists + @property + def plugin_data(self): + """ + Lazily loads and returns the plugin data + """ + try: + if self._plugin_data is None: + self._plugin_data = self.fetch_plugin_data() + except AttributeError: + self._plugin_data = None + return self._plugin_data + @property def attachments(self): """ @@ -183,6 +195,7 @@ def fetch(self, eager=True): self.checked = json_obj['checkItemStates'] self.dateLastActivity = dateparser.parse(json_obj['dateLastActivity']) + self._plugin_data = self.fetch_plugin_data() if eager else None self._checklists = self.fetch_checklists() if eager else None self._comments = self.fetch_comments() if eager else None self._attachments = self.fetch_attachments() if eager else None @@ -226,6 +239,11 @@ def fetch_checklists(self): trello_card=self.id)) return checklists + def fetch_plugin_data(self): + items = self.client.fetch_json( + '/cards/' + self.id + '/pluginData') + return items + def fetch_attachments(self, force=False): if (force is True) or (self.badges['attachments'] > 0): items = self.client.fetch_json(