Skip to content
This repository was archived by the owner on Sep 6, 2025. It is now read-only.

Commit 7da2d32

Browse files
authored
Merge pull request #3 from hellofresh/feature-user-delete-endpoint
New users delete endpoint
2 parents b5e1b2c + f1e92ac commit 7da2d32

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

appboy/client.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class AppboyClient(object):
3131
API_URL = 'https://api.appboy.com'
3232

3333
USER_TRACK_ENDPOINT = '/users/track'
34+
USER_DELETE_ENDPOINT = '/users/delete'
3435

3536
REQUEST_POST = 'post'
3637

@@ -63,6 +64,25 @@ def user_track(self, attributes, events, purchases):
6364

6465
return self.__create_request(payload=payload, request_type=self.REQUEST_POST)
6566

67+
def user_delete(self, external_ids, appboy_ids):
68+
"""
69+
Delete user from appboy.
70+
:param external_ids: dict or list of user external ids
71+
:param appboy_ids: dict or list of user appboy ids
72+
:return: json dict response, for example: {"message": "success", "errors": [], "client_error": ""}
73+
"""
74+
self.request_url = self.API_URL + self.USER_DELETE_ENDPOINT
75+
76+
payload = {}
77+
78+
if external_ids:
79+
payload['external_ids'] = external_ids
80+
81+
if appboy_ids:
82+
payload['appboy_ids'] = appboy_ids
83+
84+
return self.__create_request(payload=payload, request_type=self.REQUEST_POST)
85+
6686
def __create_request(self, payload, request_type):
6787
self.headers = {
6888
'Content-Type': 'application/json',

examples.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
client = AppboyClient(app_group_id='YOUR_GROUP_ID')
44

5+
# For create - update users
56
r = client.user_track(
67
attributes=[{
78
'external_id': '1',
@@ -21,3 +22,16 @@
2122
else:
2223
print r['client_error']
2324
print r['errors']
25+
26+
# For delete users by external_id or appboy_id
27+
r = client.user_delete(
28+
external_ids=['1'],
29+
appboy_ids=None,
30+
)
31+
if r['success']:
32+
# do our magic here
33+
print 'Success!'
34+
print r
35+
else:
36+
print r['client_error']
37+
print r['errors']

0 commit comments

Comments
 (0)