Skip to content

Commit

Permalink
improved docs slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
wolph committed May 21, 2015
1 parent a389301 commit 9b0f462
Showing 1 changed file with 90 additions and 10 deletions.
100 changes: 90 additions & 10 deletions trello/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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'])
Expand Down Expand Up @@ -265,13 +287,21 @@ 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',
query_params={'lists': 'none', 'filter': 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',
Expand Down Expand Up @@ -358,29 +388,50 @@ 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',
query_params={'cards': 'none', 'filter': 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})
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -413,23 +466,32 @@ 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'
}
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'
}
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'
Expand 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',
Expand All @@ -452,38 +516,54 @@ 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'
}
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'
}
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'
}
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'
}
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)
Expand Down

0 comments on commit 9b0f462

Please sign in to comment.