From 9b0f462300a243e00168d9d4c706850904732227 Mon Sep 17 00:00:00 2001 From: Rick van Hattem Date: Thu, 21 May 2015 15:28:00 +0200 Subject: [PATCH] improved docs slightly --- trello/__init__.py | 100 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 90 insertions(+), 10 deletions(-) diff --git a/trello/__init__.py b/trello/__init__.py index e6f3c203..a4b90401 100644 --- a/trello/__init__.py +++ b/trello/__init__.py @@ -76,6 +76,7 @@ def list_boards(self): Returns all boards for your Trello user :return: a list of Python objects representing the Trello boards. + :rtype: Board Each board has the following noteworthy attributes: - id: the board's identifier @@ -93,6 +94,7 @@ def list_organizations(self): Returns all organizations for your Trello user :return: a list of Python objects representing the Trello organizations. + :rtype: Organization Each organization has the following noteworthy attributes: - id: the organization's identifier @@ -106,23 +108,43 @@ def list_organizations(self): return [Organization.from_json(self, obj) for obj in json_obj] def get_organization(self, organization_id): + '''Get organization + + :rtype: Organization + ''' obj = self.fetch_json('/organizations/' + organization_id) return Organization.from_json(self, obj) def get_board(self, board_id): + '''Get board + + :rtype: Board + ''' obj = self.fetch_json('/boards/' + board_id) return Board.from_json(self, json_obj=obj) def add_board(self, board_name): + '''Create board + + :rtype: Board + ''' obj = self.fetch_json('/boards', http_method='POST', post_args={'name': board_name}) return Board.from_json(self, json_obj=obj) def get_member(self, member_id): + '''Get member + + :rtype: Member + ''' return Member(self, member_id).fetch() def get_card(self, card_id): + '''Get card + + :rtype: Card + ''' card_json = self.fetch_json('/cards/' + card_id) list_json = self.fetch_json('/lists/' + card_json['idList']) board = self.get_board(card_json['idBoard']) @@ -265,6 +287,10 @@ def all_boards(self): return self.get_boards('all') def get_boards(self, list_filter): + '''Get boards using filter + + :rtype: Board + ''' # error checking json_obj = self.client.fetch_json( '/organizations/' + self.id + '/boards', @@ -272,6 +298,10 @@ def get_boards(self, list_filter): return [Board.from_json(organization=self, json_obj=obj) for obj in json_obj] def get_board(self, field_name): + '''Get board + + :rtype: Board + ''' # error checking json_obj = self.client.fetch_json( '/organizations/' + self.id + '/boards', @@ -358,22 +388,39 @@ def close(self): self.closed = True def get_list(self, list_id): + '''Get list + + :rtype: List + ''' obj = self.client.fetch_json('/lists/' + list_id) return List.from_json(board=self, json_obj=obj) def all_lists(self): - """Returns all lists on this board""" + """Returns all lists on this board + + :rtype: List + """ return self.get_lists('all') def open_lists(self): - """Returns all open lists on this board""" + """Returns all open lists on this board + + :rtype: List + """ return self.get_lists('open') def closed_lists(self): - """Returns all closed lists on this board""" + """Returns all closed lists on this board + + :rtype: List + """ return self.get_lists('closed') def get_lists(self, list_filter): + '''Get lists from filter + + :rtype: List + ''' # error checking json_obj = self.client.fetch_json( '/boards/' + self.id + '/lists', @@ -381,6 +428,10 @@ def get_lists(self, list_filter): return [List.from_json(board=self, json_obj=obj) for obj in json_obj] def get_labels(self, fields='all', limit=50): + '''Get label + + :rtype: Label + ''' json_obj = self.client.fetch_json( '/boards/' + self.id + '/labels', query_params={'fields': fields, 'limit': limit}) @@ -391,6 +442,7 @@ def add_list(self, name): :name: name for the list :return: the list + :rtype: List """ obj = self.client.fetch_json( '/lists', @@ -405,6 +457,7 @@ def add_label(self, name, color): :color: the color, either green, yellow, orange red, purple, blue, sky, lime, pink, or black :return: the label + :rtype: Label """ obj = self.client.fetch_json( '/labels', @@ -413,7 +466,10 @@ def add_label(self, name, color): return Label.from_json(board=self, json_obj=obj) def all_cards(self): - """Returns all cards on this board""" + """Returns all cards on this board + + :rtype: Card + """ filters = { 'filter': 'all', 'fields': 'all' @@ -421,7 +477,10 @@ def all_cards(self): return self.get_cards(filters) def open_cards(self): - """Returns all open cards on this board""" + """Returns all open cards on this board + + :rtype: Card + """ filters = { 'filter': 'open', 'fields': 'all' @@ -429,7 +488,10 @@ def open_cards(self): return self.get_cards(filters) def closed_cards(self): - """Returns all closed cards on this board""" + """Returns all closed cards on this board + + :rtype: Card + """ filters = { 'filter': 'closed', 'fields': 'all' @@ -443,6 +505,8 @@ def get_cards(self, filters=None): More info on card queries: https://trello.com/docs/api/board/index.html#get-1-boards-board-id-cards + + :rtype: Card """ json_obj = self.client.fetch_json( '/boards/' + self.id + '/cards', @@ -452,7 +516,10 @@ def get_cards(self, filters=None): return list([Card.from_json(self, json) for json in json_obj]) def all_members(self): - """Returns all members on this board""" + """Returns all members on this board + + :rtype: Member + """ filters = { 'filter': 'all', 'fields': 'all' @@ -460,7 +527,10 @@ def all_members(self): return self.get_members(filters) def normal_members(self): - """Returns all normal members on this board""" + """Returns all normal members on this board + + :rtype: Member + """ filters = { 'filter': 'normal', 'fields': 'all' @@ -468,7 +538,10 @@ def normal_members(self): return self.get_members(filters) def admin_members(self): - """Returns all admin members on this board""" + """Returns all admin members on this board + + :rtype: Member + """ filters = { 'filter': 'admins', 'fields': 'all' @@ -476,7 +549,10 @@ def admin_members(self): return self.get_members(filters) def owner_members(self): - """Returns all owner members on this board""" + """Returns all owner members on this board + + :rtype: Member + """ filters = { 'filter': 'owners', 'fields': 'all' @@ -484,6 +560,10 @@ def owner_members(self): return self.get_members(filters) def get_members(self, filters=None): + """Get members with filter + + :rtype: Member + """ json_obj = self.client.fetch_json( '/boards/' + self.id + '/members', query_params=filters)