Commit 812a8b4b authored by Helperhaps's avatar Helperhaps

update new api

parent 14e03be7
......@@ -6,6 +6,8 @@ from .audience import (
tag_not,
alias,
registration_id,
segment,
abtest
)
from .payload import (
......@@ -13,6 +15,7 @@ from .payload import (
ios,
winphone,
platform,
cid,
notification,
message,
audience,
......@@ -36,9 +39,12 @@ __all__ = [
tag_not,
alias,
registration_id,
segment,
abtest,
notification,
message,
platform,
cid,
audience,
options,
smsmessage,
......
......@@ -26,3 +26,13 @@ def registration_id(*reg_ids):
"""Select a (list of) registration_id(s)."""
vregistration_id = [t for t in reg_ids]
return {"registration_id": vregistration_id}
def segment(*segments):
"""Select a (list of) segment(s)."""
vsegment = [t for t in segments]
return {"segment": vsegment}
def abtest(*abtests):
"""Select a (list of) abtest(s)."""
vabtest = [t for t in reg_ids]
return {"abtest": vabtest}
......@@ -13,6 +13,7 @@ class Push(object):
self.audience = None
self.notification = None
self.platform = None
self.cid = None
self.options = None
self.message = None
self.smsmessage=None
......@@ -25,6 +26,8 @@ class Push(object):
}
if (self.notification is None) and (self.message is None):
raise ValueError("Notification and message cannot be both empty")
if self.cid is not None:
data['cid'] = self.cid
if self.notification is not None:
data['notification'] = self.notification
if self.smsmessage is not None:
......
......@@ -166,6 +166,11 @@ def smsmessage(content,delay_time):
return payload
def cid(cid):
payload = {}
payload["cid"]=cid
return payload
def platform(*types):
"""Create a platform specifier.
......@@ -200,7 +205,7 @@ def audience(*types):
audience = {}
for t in types:
for key in t:
if key not in ('tag', 'tag_and', 'tag_not', 'alias', 'registration_id'):
if key not in ('tag', 'tag_and', 'tag_not', 'alias', 'registration_id', 'segment', 'abtest'):
raise ValueError("Invalid audience '%s'" % t)
audience[key] = t[key]
return audience
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment