Commit ca179c93 authored by Helperhaps's avatar Helperhaps

format code

parent 689d0d08
...@@ -12,27 +12,25 @@ class Device(object): ...@@ -12,27 +12,25 @@ class Device(object):
self.entity = None self.entity = None
self.zone = zone or jpush.zone self.zone = zone or jpush.zone
def send(self, method, url, body, content_type=None, version=3): def send(self, method, url, body = None, content_type=None, version=3, params = None):
"""Send the request """Send the request
""" """
response = self._jpush._request(method, body, url, content_type, version=3) response = self._jpush._request(method, body, url, content_type, version=3, params = params)
return DeviceResponse(response) return DeviceResponse(response)
def get_taglist(self): def get_taglist(self):
"""Get deviceinfo with registration id. """Get deviceinfo with registration id.
""" """
url = common.get_url('tag', self.zone) url = common.get_url('tag', self.zone)
body = None info = self.send("GET", url)
info = self.send("GET", url, body)
return info return info
def get_deviceinfo(self, registration_id): def get_deviceinfo(self, registration_id):
"""Get deviceinfo with registration id. """Get deviceinfo with registration id.
""" """
url = common.get_url('device', self.zone) + registration_id url = common.get_url('device', self.zone) + registration_id
body = None info = self.send("GET", url)
info = self.send("GET", url, body)
return info return info
def set_deviceinfo(self, registration_id, entity): def set_deviceinfo(self, registration_id, entity):
...@@ -55,10 +53,8 @@ class Device(object): ...@@ -55,10 +53,8 @@ class Device(object):
"""Delete registration id tag. """Delete registration id tag.
""" """
url = common.get_url('tag', self.zone) + tag url = common.get_url('tag', self.zone) + tag
body = None params = { 'platform': platform } if platform else None
if platform: info = self.send("DELETE", url, params = params)
body = platform
info = self.send("DELETE", url, body)
return info return info
def update_tagusers(self, tag, entity): def update_tagusers(self, tag, entity):
...@@ -73,28 +69,23 @@ class Device(object): ...@@ -73,28 +69,23 @@ class Device(object):
"""Check registration id whether in tag. """Check registration id whether in tag.
""" """
url = common.get_url('tag', self.zone) + tag + "/registration_ids/" + registration_id url = common.get_url('tag', self.zone) + tag + "/registration_ids/" + registration_id
body = registration_id info = self.send("GET", url)
info = self.send("GET", url, body)
return info return info
def delete_alias(self, alias, platform=None): def delete_alias(self, alias, platform=None):
"""Delete appkey alias. """Delete appkey alias.
""" """
url = common.get_url('alias', self.zone) + alias url = common.get_url('alias', self.zone) + alias
body = None params = { 'platform': platform } if platform else None
if platform: info = self.send("DELETE", url, params = params)
body = platform
info = self.send("DELETE", url, body)
return info return info
def get_aliasuser(self, alias, platform=None): def get_aliasuser(self, alias, platform=None):
"""Get appkey alias users. """Get appkey alias users.
""" """
url = common.get_url('alias', self.zone) + alias url = common.get_url('alias', self.zone) + alias
body = None params = { 'platform': platform } if platform else None
if platform: info = self.send("GET", url, params = params)
body = platform
info = self.send("GET", url, body)
return info return info
......
...@@ -10,7 +10,7 @@ class Report(object): ...@@ -10,7 +10,7 @@ class Report(object):
self._jpush = jpush self._jpush = jpush
self.zone = zone or jpush.zone self.zone = zone or jpush.zone
def send(self, method, url, body, content_type=None, version=3, params = None): def send(self, method, url, body = None, content_type=None, version=3, params = None):
"""Send the request """Send the request
""" """
response = self._jpush._request(method, body,url,content_type,version=3, params = params) response = self._jpush._request(method, body,url,content_type,version=3, params = params)
...@@ -19,15 +19,13 @@ class Report(object): ...@@ -19,15 +19,13 @@ class Report(object):
def get_received(self,msg_ids): def get_received(self,msg_ids):
url = common.get_url('report', self.zone) + 'received' url = common.get_url('report', self.zone) + 'received'
params = { 'msg_ids': msg_ids } params = { 'msg_ids': msg_ids }
body = None received = self.send("GET", url, params = params)
received = self.send("GET", url, body, params = params)
return received return received
def get_messages(self, msg_ids): def get_messages(self, msg_ids):
url = common.get_url('report', self.zone) + 'messages' url = common.get_url('report', self.zone) + 'messages'
params = { 'msg_ids': msg_ids } params = { 'msg_ids': msg_ids }
body = None messages = self.send("GET", url, params = params)
messages = self.send("GET", url, body, params = params)
return messages return messages
def get_users(self, time_unit,start,duration): def get_users(self, time_unit,start,duration):
...@@ -37,8 +35,7 @@ class Report(object): ...@@ -37,8 +35,7 @@ class Report(object):
'start': start, 'start': start,
'duration': duration 'duration': duration
} }
body = None users = self.send("GET", url, params = params)
users = self.send("GET", url, body, params = params)
return users return users
......
...@@ -11,7 +11,7 @@ class Schedule(object): ...@@ -11,7 +11,7 @@ class Schedule(object):
self._jpush = jpush self._jpush = jpush
self.zone = zone or jpush.zone self.zone = zone or jpush.zone
def send(self, method, url, body, content_type=None, version=3, params = None): def send(self, method, url, body = None, content_type=None, version=3, params = None):
response = self._jpush._request(method, body, url, content_type, version=3, params = params) response = self._jpush._request(method, body, url, content_type, version=3, params = params)
return ScheduleResponse(response) return ScheduleResponse(response)
...@@ -23,15 +23,13 @@ class Schedule(object): ...@@ -23,15 +23,13 @@ class Schedule(object):
def get_schedule_by_id(self, schedule_id): def get_schedule_by_id(self, schedule_id):
url = common.get_url('schedule', self.zone) + schedule_id url = common.get_url('schedule', self.zone) + schedule_id
body = None result = self.send("GET", url)
result = self.send("GET", url, body)
return result return result
def get_schedule_list(self, page = 1): def get_schedule_list(self, page = 1):
url = common.get_url('schedule', self.zone) url = common.get_url('schedule', self.zone)
params = { 'page': page } params = { 'page': page }
body = None result = self.send("GET", url, params = params)
result = self.send("GET", url, body, params = params)
return result return result
def put_schedule(self, schedulepayload, schedule_id): def put_schedule(self, schedulepayload, schedule_id):
...@@ -42,8 +40,7 @@ class Schedule(object): ...@@ -42,8 +40,7 @@ class Schedule(object):
def delete_schedule(self,schedule_id): def delete_schedule(self,schedule_id):
url = common.get_url('schedule', self.zone) + schedule_id url = common.get_url('schedule', self.zone) + schedule_id
body = None result = self.send("DELETE", url)
result = self.send("DELETE", url, body)
return result return result
......
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