Skip to content

Commit 2f3acb0

Browse files
authored
Allowing for dynamic object_id for delete call
This is according to how intercoms official api supports this #158
1 parent 60b1413 commit 2f3acb0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

intercom/api_operations/delete.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
class Delete(object):
88
"""A mixin that provides `delete` functionality."""
99

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

0 commit comments

Comments
 (0)