Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing for dynamic object_id for delete call #176

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 5 additions & 2 deletions intercom/api_operations/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
class Delete(object):
"""A mixin that provides `delete` functionality."""

def delete(self, obj):
def delete(self, obj=None, **kwargs):
"""Delete the specified instance of this resource."""
assert obj is not None or kwargs.keys()[0] == "%s_id" % (
utils.resource_class_to_name(self.collection_class))
obj_id = kwargs.values()[0] if obj is None else obj.id
collection = utils.resource_class_to_collection_name(
self.collection_class)
self.client.delete("/%s/%s" % (collection, obj.id), {})
self.client.delete("/%s/%s" % (collection, obj_id), {})
return obj