Commit 812a8b4b authored by Helperhaps's avatar Helperhaps

update new api

parent 14e03be7
...@@ -6,6 +6,8 @@ from .audience import ( ...@@ -6,6 +6,8 @@ from .audience import (
tag_not, tag_not,
alias, alias,
registration_id, registration_id,
segment,
abtest
) )
from .payload import ( from .payload import (
...@@ -13,6 +15,7 @@ from .payload import ( ...@@ -13,6 +15,7 @@ from .payload import (
ios, ios,
winphone, winphone,
platform, platform,
cid,
notification, notification,
message, message,
audience, audience,
...@@ -36,9 +39,12 @@ __all__ = [ ...@@ -36,9 +39,12 @@ __all__ = [
tag_not, tag_not,
alias, alias,
registration_id, registration_id,
segment,
abtest,
notification, notification,
message, message,
platform, platform,
cid,
audience, audience,
options, options,
smsmessage, smsmessage,
......
...@@ -26,3 +26,13 @@ def registration_id(*reg_ids): ...@@ -26,3 +26,13 @@ def registration_id(*reg_ids):
"""Select a (list of) registration_id(s).""" """Select a (list of) registration_id(s)."""
vregistration_id = [t for t in reg_ids] vregistration_id = [t for t in reg_ids]
return {"registration_id": vregistration_id} 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): ...@@ -13,6 +13,7 @@ class Push(object):
self.audience = None self.audience = None
self.notification = None self.notification = None
self.platform = None self.platform = None
self.cid = None
self.options = None self.options = None
self.message = None self.message = None
self.smsmessage=None self.smsmessage=None
...@@ -25,6 +26,8 @@ class Push(object): ...@@ -25,6 +26,8 @@ class Push(object):
} }
if (self.notification is None) and (self.message is None): if (self.notification is None) and (self.message is None):
raise ValueError("Notification and message cannot be both empty") 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: if self.notification is not None:
data['notification'] = self.notification data['notification'] = self.notification
if self.smsmessage is not None: if self.smsmessage is not None:
......
...@@ -166,6 +166,11 @@ def smsmessage(content,delay_time): ...@@ -166,6 +166,11 @@ def smsmessage(content,delay_time):
return payload return payload
def cid(cid):
payload = {}
payload["cid"]=cid
return payload
def platform(*types): def platform(*types):
"""Create a platform specifier. """Create a platform specifier.
...@@ -200,7 +205,7 @@ def audience(*types): ...@@ -200,7 +205,7 @@ def audience(*types):
audience = {} audience = {}
for t in types: for t in types:
for key in t: 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) raise ValueError("Invalid audience '%s'" % t)
audience[key] = t[key] audience[key] = t[key]
return audience 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