Commit d5315fc9 authored by Helperhaps's avatar Helperhaps

delete useless files in examples fold & and GroupPush

parent 598c479e
"""Python package for using the JPush API"""
from .conf import app_key, master_secret
__all__ = [
app_key,
master_secret,
]
# please put your app_key and master_secret here
app_key = u'6be9204c30b9473e87bad4dc'
master_secret = u'9349ad7c90292a603c512e92'
# please put your app_key and master_secret here
app_key = u'6be9204c30b9473e87bad4dc'
master_secret = u'a19bef7870c55d7e51f4c4f0'
# please put your app_key and master_secret here
app_key = u'6be9204c30b9473e87bad4dc'
master_secret = u'9349ad7c90292a603c512e92'
# please put your app_key and master_secret here
app_key = u'6be9204c30b9473e87bad4dc'
master_secret = u'9349ad7c90292a603c512e92'
"""Python package for using the JPush API""" """Python package for using the JPush API"""
from .core import JPush from .core import JPush, GroupPush
from .common import JPushFailure, Unauthorized from .common import JPushFailure, Unauthorized
from .push import ( from .push import (
...@@ -43,6 +43,7 @@ from .schedule import ( ...@@ -43,6 +43,7 @@ from .schedule import (
__all__ = [ __all__ = [
JPush, JPush,
GroupPush,
JPushFailure, JPushFailure,
Unauthorized, Unauthorized,
all_, all_,
......
...@@ -5,6 +5,7 @@ import requests ...@@ -5,6 +5,7 @@ import requests
BASE_URL = "https://api.jpush.cn/" BASE_URL = "https://api.jpush.cn/"
PUSH_URL = BASE_URL + 'v3/push' PUSH_URL = BASE_URL + 'v3/push'
VALIDATE_PUSH_URL = BASE_URL + 'v3/push/validate' VALIDATE_PUSH_URL = BASE_URL + 'v3/push/validate'
GROUP_PUSH_URL = BASE_URL + 'v3/grouppush'
DEVICE_BASEURL = "https://device.jpush.cn/" DEVICE_BASEURL = "https://device.jpush.cn/"
DEVICE_URL = DEVICE_BASEURL + "v3/devices/" DEVICE_URL = DEVICE_BASEURL + "v3/devices/"
......
...@@ -89,3 +89,12 @@ class JPush(object): ...@@ -89,3 +89,12 @@ class JPush(object):
def create_schedule(self): def create_schedule(self):
"""Create a Schedule.""" """Create a Schedule."""
return Schedule(self) return Schedule(self)
class GroupPush(JPush):
def __init__(self, key, secret):
super().__init__('group-' + key, secret)
def create_push(self):
"""Create a Group Push notification."""
return Push(self, url = common.GROUP_PUSH_URL)
...@@ -8,7 +8,7 @@ logger = logging.getLogger('jpush') ...@@ -8,7 +8,7 @@ logger = logging.getLogger('jpush')
class Push(object): class Push(object):
"""A push notification. Set audience, message, etc, and send.""" """A push notification. Set audience, message, etc, and send."""
def __init__(self, jpush): def __init__(self, jpush, url = common.PUSH_URL):
self._jpush = jpush self._jpush = jpush
self.audience = None self.audience = None
self.notification = None self.notification = None
...@@ -17,6 +17,7 @@ class Push(object): ...@@ -17,6 +17,7 @@ class Push(object):
self.options = None self.options = None
self.message = None self.message = None
self.smsmessage=None self.smsmessage=None
self.url = url
@property @property
def payload(self): def payload(self):
...@@ -48,7 +49,8 @@ class Push(object): ...@@ -48,7 +49,8 @@ class Push(object):
""" """
body = json.dumps(self.payload) body = json.dumps(self.payload)
response = self._jpush._request('POST', body, common.PUSH_URL, 'application/json', version=3) url = self.url
response = self._jpush._request('POST', body, url, 'application/json', version=3)
return PushResponse(response) return PushResponse(response)
def send_validate(self): def send_validate(self):
......
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