Skip to content
This repository has been archived by the owner on Jul 19, 2022. It is now read-only.

Add in bulk_delete to Items with test #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions pypodio2/areas.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class Item(Area):
def find(self, item_id, basic=False, **kwargs):
"""
Get item

:param item_id: Item ID
:type item_id: int
:return: Item info
Expand Down Expand Up @@ -131,7 +131,7 @@ def update(self, item_id, attributes, silent=False, hook=True):
"""
Updates the item using the supplied attributes. If 'silent' is true, Podio will send
no notifications to subscribed users and not post updates to the stream.

Important: webhooks will still be called.
"""
if not isinstance(attributes, dict):
Expand All @@ -148,6 +148,18 @@ def delete(self, item_id, silent=False, hook=True):
hook=hook)),
handler=lambda x, y: None)

def bulk_delete(self, app_id, attributes, silent=False):
if not isinstance(attributes, dict):
raise TypeError('Must be of type dict')
attributes = json.dumps(attributes)

return self.transport.POST(body=attributes,
type='application/json',
url='/item/app/%d/delete/%s' % (app_id,
self.get_options(silent=silent)))




class Application(Area):
def activate(self, app_id):
Expand Down Expand Up @@ -249,7 +261,7 @@ def get(self, **kwargs):
def delete(self, task_id):
"""
Deletes the app with the given id.

:param task_id: Task ID
:type task_id: str or int
"""
Expand Down Expand Up @@ -345,7 +357,7 @@ def find_all_for_org(self, org_id):
def create(self, attributes):
"""
Create a new space

:param attributes: Refer to API. Pass in argument as dictionary
:type attributes: dict
:return: Details of newly created space
Expand Down
12 changes: 12 additions & 0 deletions tests/test_areas_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,15 @@ def test_delete():
'DELETE',
body=None,
headers={})

def test_bulk_delete():
app_id = 1
attributes = { 'item_ids': [1,2,3] }

client, check_assertions = check_client_method()
result = client.Item.bulk_delete(app_id, attributes)
check_assertions(result,
'POST',
'/item/app/%s/delete/' % app_id,
json.dumps(attributes),
{'content-type': 'application/json'})