Commit 701084bb authored by hupantingxue's avatar hupantingxue

Modify tags device entity;

parent da9e1f05
...@@ -5,4 +5,5 @@ _jpush = jpush.JPush(app_key, master_secret) ...@@ -5,4 +5,5 @@ _jpush = jpush.JPush(app_key, master_secret)
device = _jpush.create_device() device = _jpush.create_device()
reg_id = '090c1f59f89' reg_id = '090c1f59f89'
entity = jpush.device_tag(jpush.add("ddd", "tageee")) entity = jpush.device_tag(jpush.add("ddd", "tageee"))
#entity = jpush.device_tag("")
device.set_deviceinfo(reg_id, entity) device.set_deviceinfo(reg_id, entity)
...@@ -31,22 +31,22 @@ def device_tag(*types): ...@@ -31,22 +31,22 @@ def device_tag(*types):
"""Get a tag object """Get a tag object
>>> device_tag("") >>> device_tag("")
{'tag': ''} {'tags': ''}
>>> device_tag("tag1") >>> device_tag("tag1")
{'tag': 'tag1'} {'tags': 'tag1'}
>>> device_tag(add("tag1", "tag2"), remove("tag3", "tag4")) >>> device_tag(add("tag1", "tag2"), remove("tag3", "tag4"))
{'tag': {'add': ['tag1', 'tag2'], 'remove': ['tag3', 'tag4']}} {'tags': {'add': ['tag1', 'tag2'], 'remove': ['tag3', 'tag4']}}
""" """
tag = {} tag = {}
if 1 == len(types) and isinstance(types[0], (str, unicode)): if 1 == len(types) and isinstance(types[0], (str, unicode)):
tag["tag"] = types[0] tag["tags"] = types[0]
return tag return tag
tag["tag"] = {} tag["tags"] = {}
for t in types: for t in types:
for key in t: for key in t:
if key not in ('add', 'remove'): if key not in ('add', 'remove'):
raise ValueError("Invalid tag '%s'" % t) raise ValueError("Invalid tag '%s'" % t)
tag["tag"][key] = t[key] tag["tags"][key] = t[key]
return tag return tag
def device_alias(*types): def device_alias(*types):
......
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