Skip to content
This repository has been archived by the owner on Jul 8, 2021. It is now read-only.

Commit

Permalink
Merge pull request #3 from hellofresh/feature-user-delete-endpoint
Browse files Browse the repository at this point in the history
New users delete endpoint
  • Loading branch information
c4pone authored Aug 3, 2016
2 parents b5e1b2c + f1e92ac commit 7da2d32
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
20 changes: 20 additions & 0 deletions appboy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class AppboyClient(object):
API_URL = 'https://api.appboy.com'

USER_TRACK_ENDPOINT = '/users/track'
USER_DELETE_ENDPOINT = '/users/delete'

REQUEST_POST = 'post'

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

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

def user_delete(self, external_ids, appboy_ids):
"""
Delete user from appboy.
:param external_ids: dict or list of user external ids
:param appboy_ids: dict or list of user appboy ids
:return: json dict response, for example: {"message": "success", "errors": [], "client_error": ""}
"""
self.request_url = self.API_URL + self.USER_DELETE_ENDPOINT

payload = {}

if external_ids:
payload['external_ids'] = external_ids

if appboy_ids:
payload['appboy_ids'] = appboy_ids

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

def __create_request(self, payload, request_type):
self.headers = {
'Content-Type': 'application/json',
Expand Down
14 changes: 14 additions & 0 deletions examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

client = AppboyClient(app_group_id='YOUR_GROUP_ID')

# For create - update users
r = client.user_track(
attributes=[{
'external_id': '1',
Expand All @@ -21,3 +22,16 @@
else:
print r['client_error']
print r['errors']

# For delete users by external_id or appboy_id
r = client.user_delete(
external_ids=['1'],
appboy_ids=None,
)
if r['success']:
# do our magic here
print 'Success!'
print r
else:
print r['client_error']
print r['errors']

0 comments on commit 7da2d32

Please sign in to comment.