Skip to content

Commit 538cbfe

Browse files
authored
[TOOLSLIBS-438] Adds message center delete (#178)
* adds message center delete * no really unicode when * adds request body
1 parent dd9e766 commit 538cbfe

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

urbanairship/core.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def __init__(self, location=None):
3434
self.lists_url = self.base_url + "lists/"
3535
self.location_url = self.base_url + "location/"
3636
self.attributes_url = self.channel_url + "attributes/"
37+
self.message_center_delete_url = self.base_url + "user/messages/"
3738

3839
self.templates_url = self.base_url + "templates/"
3940
self.schedule_template_url = self.templates_url + "schedules/"

urbanairship/push/core.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,34 @@ def send(self):
108108

109109
return PushResponse(response)
110110

111+
@classmethod
112+
def message_center_delete(cls, airship, push_id):
113+
"""
114+
Delete a Message Center message completely, removing it from every user's inbox.
115+
This is an asynchronous call; a success response means that the deletion has
116+
been queued for processing.
117+
This delete call will work with either the message_id or the push_id of the
118+
accompanying push notification.
119+
This endpoint will not work with a group_id from an automated message or a
120+
push to local time delivery. To delete a rich message that was part of an
121+
automated or local time delivery, you must use the relevant push_id from the
122+
operation.
123+
124+
:param airship: Required. Airship object instantiated with auth that corresponds
125+
to message to be deleted.
126+
:param push_id: Required. The message_id to delete or the push_id of the
127+
accompanying push notification.
128+
"""
129+
130+
response = airship._request(
131+
method="DELETE",
132+
url=airship.urls.get("message_center_delete_url") + push_id,
133+
body="",
134+
version=3,
135+
)
136+
137+
return response
138+
111139

112140
class ScheduledPush(object):
113141
"""A scheduled push notification. Set schedule, push, and send."""
@@ -162,6 +190,7 @@ def payload(self):
162190
data = {"schedule": self.schedule, "push": self.push.payload}
163191
else:
164192
data = {"schedule": self.schedule, "push": self.push.payload}
193+
165194
if self.recurring:
166195
data["schedule"].update(self.recurring)
167196

0 commit comments

Comments
 (0)