@@ -7,9 +7,10 @@ class Device(object):
77 """Device info query/update..
88
99 """
10- def __init__ (self , jpush ):
10+ def __init__ (self , jpush , zone = None ):
1111 self ._jpush = jpush
1212 self .entity = None
13+ self .zone = zone or jpush .zone
1314
1415 def send (self , method , url , body , content_type = None , version = 3 ):
1516 """Send the request
@@ -21,39 +22,39 @@ def send(self, method, url, body, content_type=None, version=3):
2122 def get_taglist (self ):
2223 """Get deviceinfo with registration id.
2324 """
24- url = common .TAG_URL
25+ url = common .get_url ( 'tag' , self . zone )
2526 body = None
2627 info = self .send ("GET" , url , body )
2728 return info
2829
2930 def get_deviceinfo (self , registration_id ):
3031 """Get deviceinfo with registration id.
3132 """
32- url = common .DEVICE_URL + registration_id + "/"
33+ url = common .get_url ( 'device' , self . zone ) + registration_id
3334 body = None
3435 info = self .send ("GET" , url , body )
3536 return info
3637
3738 def set_deviceinfo (self , registration_id , entity ):
3839 """Update deviceinfo with registration id.
3940 """
40- url = common .DEVICE_URL + registration_id + "/"
41+ url = common .get_url ( 'device' , self . zone ) + registration_id
4142 body = json .dumps (entity )
4243 info = self .send ("POST" , url , body )
4344 return info
4445
4546 def set_devicemobile (self , registration_id , entity ):
4647 """Update deviceinfo with registration id.
4748 """
48- url = common .DEVICE_URL + registration_id + "/"
49+ url = common .get_url ( 'device' , self . zone ) + registration_id
4950 body = json .dumps (entity )
5051 info = self .send ("POST" , url , body )
5152 return info
5253
5354 def delete_tag (self , tag , platform = None ):
5455 """Delete registration id tag.
5556 """
56- url = common .TAG_URL + tag + "/"
57+ url = common .get_url ( ' tag' , self . zone ) + tag
5758 body = None
5859 if platform :
5960 body = platform
@@ -63,23 +64,23 @@ def delete_tag(self, tag, platform=None):
6364 def update_tagusers (self , tag , entity ):
6465 """Add/Remove specified tag users.
6566 """
66- url = common .TAG_URL + tag + "/"
67+ url = common .get_url ( ' tag' , self . zone ) + tag
6768 body = json .dumps (entity )
6869 info = self .send ("POST" , url , body )
6970 return info
7071
7172 def check_taguserexist (self , tag , registration_id ):
7273 """Check registration id whether in tag.
7374 """
74- url = common .TAG_URL + tag + "/registration_ids/" + registration_id
75+ url = common .get_url ( 'tag' , self . zone ) + tag + "/registration_ids/" + registration_id
7576 body = registration_id
7677 info = self .send ("GET" , url , body )
7778 return info
7879
7980 def delete_alias (self , alias , platform = None ):
8081 """Delete appkey alias.
8182 """
82- url = common .ALIAS_URL + alias + "/"
83+ url = common .get_url ( ' alias' , self . zone ) + alias
8384 body = None
8485 if platform :
8586 body = platform
@@ -89,7 +90,7 @@ def delete_alias(self, alias, platform=None):
8990 def get_aliasuser (self , alias , platform = None ):
9091 """Get appkey alias users.
9192 """
92- url = common .ALIAS_URL + alias + "/"
93+ url = common .get_url ( ' alias' , self . zone ) + alias
9394 body = None
9495 if platform :
9596 body = platform
0 commit comments