Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
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
9 changes: 9 additions & 0 deletions intercom/service/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,12 @@ class User(BaseService, All, Find, FindAll, Delete, Save, Load, Submit, Tags, Sc
@property
def collection_class(self):
return user.User

def archive(self, obj):
"""Archive a user. This used to be called 'delete', but now is called 'archive'."""
return self.delete(obj)

def permanent_delete(self, intercom_user_id):
"""Request permanent deletion of a user."""
response = self.client.post('/user_delete_requests', {'intercom_user_id': intercom_user_id})
return response['id']
16 changes: 16 additions & 0 deletions tests/unit/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,22 @@ def it_deletes_a_user(self):
eq_(user.id, "1")
mock_method.assert_called_once_with('/users/1', {})

@istest
def it_archives_a_user(self):
user = User(id="1")
with patch.object(Client, 'delete', return_value={}) as mock_method:
user = self.client.users.archive(user)
eq_(user.id, "1")
mock_method.assert_called_once_with('/users/1', {})

@istest
def it_permanently_deletes_a_user(self):
user = User(id="1")
with patch.object(Client, 'post', return_value={'id': 1234}) as mock_method:
deletion_id = self.client.users.permanent_delete(user.id)
eq_(deletion_id, 1234)
mock_method.assert_called_once_with('/user_delete_requests', {'intercom_user_id': user.id})

@istest
def it_can_use_user_create_for_convenience(self):
payload = {
Expand Down