Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def batch_push_by_regid(self, single_payload_list):
cid_response = self.get_cid(len(single_payload_list), 'push')
cidlist = cid_response.payload['cidlist']
batch_payload = {}
for index in range(len(single_payload_list)):
batch_payload[cidlist[index]] = single_payload_list[index]
body = json.dumps(batch_payload)
url = common.get_url('push', self.zone) + 'push/batch/regid/single'
response = self._jpush._request('POST', body, url, 'application/json', version=3)
return PushResponse(response)
def get_cid(self, count, type = None):
body = None
url = common.get_url('push', self.zone) + 'push/cid'
params = {
'count': count,
'type': type
}
response = self._jpush._request('GET', body, url, 'application/json', version=3, params = params)
return PushResponse(response)
def send(self):
"""Send the notification.
:returns: :py:class:`PushResponse` object with ``push_ids`` and
other response data.
:raises JPushFailure: Request failed.
:raises Unauthorized: Authentication failed.
"""
body = json.dumps(self.payload)
url = common.get_url('push', self.zone) + self.end_point
response = self._jpush._request('POST', body, url, 'application/json', version=3)
return PushResponse(response)
def send_validate(self):
"""Send the notification to validate.
:returns: :py:class:`PushResponse` object with ``push_ids`` and
other response data.
:raises JPushFailure: Request failed.
:raises Unauthorized: Authentication failed.
"""
body = json.dumps(self.payload)
url = common.get_url('push', self.zone) + 'push/validate'
response = self._jpush._request('POST', body, url, 'application/json', version=3)
return PushResponse(response)
def batch_push_by_alias(self, single_payload_list):
cid_response = self.get_cid(len(single_payload_list), 'push')
cidlist = cid_response.payload['cidlist']
batch_payload = {}
for index in range(len(single_payload_list)):
batch_payload[cidlist[index]] = single_payload_list[index]
body = json.dumps(batch_payload)
url = common.get_url('push', self.zone) + 'push/batch/alias/single'
response = self._jpush._request('POST', body, url, 'application/json', version=3)
return PushResponse(response)