Skip to content

Commit 91693e1

Browse files
committed
Fixed a bug which prevented User.delete() from working.
Intercom._call was not expecting the DELETE method when constructing request data parameters. Hence, the params were being skipped over and the request didn't correctly register with Intercom's API. Added in intergration test to check this is working as indetented. Before, The user returned would be the 'bob@example.com' not the email specificed ('to-delete@example.com' in the tests case). Now, The user info returned corresponds to the email specified ('to-delete@example.com') as we would expect, as Intercom API 'Returns the deleted user on success' (as according to their docs).
1 parent 35c6396 commit 91693e1

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

intercom/intercom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def _call(cls, method, url, params=None):
9090
'User-Agent': 'python-intercom/' + __version__,
9191
'Accept': 'application/json'
9292
}
93-
if method in ('POST', 'PUT'):
93+
if method in ('POST', 'PUT', 'DELETE'):
9494
headers['content-type'] = 'application/json'
9595
req_params['data'] = json.dumps(params)
9696
elif method == 'GET':

tests/integration/test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ def test_user(self):
2626
user = User.find(email='somebody@example.com')
2727
self.assertEqual('Somebody', user.name)
2828

29+
def test_delete_user(self):
30+
user = User.delete(email="to-delete@example.com")
31+
self.assertEqual("to-delete@example.com", user.email)
32+
2933
@raises(ResourceNotFound)
3034
def test_not_found(self):
3135
User.find(email='not-found@example.com')

0 commit comments

Comments
 (0)