Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jpush-api-python-client
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
jpush-api-python-client
Commits
a0004990
Commit
a0004990
authored
Apr 20, 2016
by
fendouai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add report api
parent
f49e7514
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
85 additions
and
1 deletion
+85
-1
conf.py
examples/report/conf.py
+2
-0
example_received.py
examples/report/example_received.py
+7
-0
__init__.py
jpush/__init__.py
+5
-0
common.py
jpush/common.py
+5
-0
core.py
jpush/core.py
+5
-1
__init__.py
jpush/report/__init__.py
+6
-0
core.py
jpush/report/core.py
+55
-0
No files found.
examples/report/conf.py
0 → 100644
View file @
a0004990
app_key
=
u'6be9204c30b9473e87bad4dc'
master_secret
=
u'9349ad7c90292a603c512e92'
examples/report/example_received.py
0 → 100644
View file @
a0004990
import
jpush
as
jpush
from
conf
import
app_key
,
master_secret
_jpush
=
jpush
.
JPush
(
app_key
,
master_secret
)
report
=
_jpush
.
create_report
();
report
.
get_messages
(
"3289406737"
)
\ No newline at end of file
jpush/__init__.py
View file @
a0004990
...
@@ -33,6 +33,10 @@ from .device import (
...
@@ -33,6 +33,10 @@ from .device import (
device_mobile
,
device_mobile
,
)
)
from
.report
import
(
Report
,
)
__all__
=
[
__all__
=
[
JPush
,
JPush
,
JPushFailure
,
JPushFailure
,
...
@@ -58,6 +62,7 @@ __all__ = [
...
@@ -58,6 +62,7 @@ __all__ = [
device_tag
,
device_tag
,
device_alias
,
device_alias
,
device_regid
,
device_regid
,
Report
,
]
]
# Silence urllib3 INFO logging by default
# Silence urllib3 INFO logging by default
...
...
jpush/common.py
View file @
a0004990
...
@@ -12,6 +12,11 @@ TAG_URL = DEVICE_BASEURL + "v3/tags/"
...
@@ -12,6 +12,11 @@ TAG_URL = DEVICE_BASEURL + "v3/tags/"
TAGLIST_URL
=
TAG_URL
TAGLIST_URL
=
TAG_URL
ALIAS_URL
=
DEVICE_BASEURL
+
"v3/aliases/"
ALIAS_URL
=
DEVICE_BASEURL
+
"v3/aliases/"
REPORT_BASEURL
=
"https://report.jpush.cn/"
RECEIVED_URL
=
REPORT_BASEURL
+
"v3/received"
MESSAGES_URL
=
REPORT_BASEURL
+
"v3/messages?msg_ids="
USERS_URL
=
REPORT_BASEURL
+
"v3/users?"
logger
=
logging
.
getLogger
(
'jpush'
)
logger
=
logging
.
getLogger
(
'jpush'
)
class
Unauthorized
(
Exception
):
class
Unauthorized
(
Exception
):
...
...
jpush/core.py
View file @
a0004990
...
@@ -7,7 +7,7 @@ import requests
...
@@ -7,7 +7,7 @@ import requests
from
.
import
common
from
.
import
common
from
.push
import
Push
from
.push
import
Push
from
.device
import
Device
from
.device
import
Device
from
.report
import
Report
logger
=
logging
.
getLogger
(
'jpush'
)
logger
=
logging
.
getLogger
(
'jpush'
)
class
JPush
(
object
):
class
JPush
(
object
):
...
@@ -68,3 +68,7 @@ class JPush(object):
...
@@ -68,3 +68,7 @@ class JPush(object):
def
create_device
(
self
):
def
create_device
(
self
):
"""Create a Device information."""
"""Create a Device information."""
return
Device
(
self
)
return
Device
(
self
)
def
create_report
(
self
):
"""Create a Push notification."""
return
Report
(
self
)
jpush/report/__init__.py
0 → 100644
View file @
a0004990
from
.core
import
Report
__all__
=
[
Report
,
]
\ No newline at end of file
jpush/report/core.py
0 → 100644
View file @
a0004990
import
json
import
logging
from
jpush
import
common
logger
=
logging
.
getLogger
(
'jpush'
)
class
Report
(
object
):
"""JPush Report API V3"""
def
__init__
(
self
,
jpush
):
self
.
_jpush
=
jpush
def
send
(
self
,
method
,
url
,
body
,
content_type
=
None
,
version
=
3
):
"""Send the request
"""
response
=
self
.
_jpush
.
_request
(
method
,
body
,
url
,
content_type
,
version
=
3
)
return
ReportResponse
(
response
)
def
get_received
(
self
,
msg_ids
):
url
=
common
.
RECEIVED_URL
+
msg_ids
body
=
None
received
=
self
.
send
(
"GET"
,
url
,
body
)
print
(
received
)
return
received
def
get_messages
(
self
,
msg_ids
):
url
=
common
.
MESSAGES_URL
+
msg_ids
body
=
None
messages
=
self
.
send
(
"GET"
,
url
,
body
)
print
(
messages
)
return
messages
class
ReportResponse
(
object
):
"""Response to a successful device request send.
Right now this is a fairly simple wrapper around the json payload response,
but making it an object gives us some flexibility to add functionality
later.
"""
payload
=
None
def
__init__
(
self
,
response
):
if
0
!=
len
(
response
.
content
):
data
=
response
.
json
()
self
.
payload
=
data
elif
200
==
response
.
status_code
:
self
.
payload
=
"success"
def
__str__
(
self
):
return
"Device response Payload: {0}"
.
format
(
self
.
payload
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment