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
f4e291c3
Commit
f4e291c3
authored
Dec 15, 2017
by
Helperhaps
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add admin api
parent
51e4cb1f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
3 deletions
+57
-3
__init__.py
examples/__init__.py
+4
-2
admin_example.py
examples/admin_example.py
+12
-0
__init__.py
jpush/__init__.py
+2
-1
core.py
jpush/core.py
+39
-0
No files found.
examples/__init__.py
View file @
f4e291c3
...
@@ -4,18 +4,20 @@ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')
...
@@ -4,18 +4,20 @@ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')
import
jpush
import
jpush
from
.conf
import
app_key
,
master_secret
from
.conf
import
app_key
,
master_secret
,
dev_key
,
dev_secret
from
.
import
device_example
from
.
import
device_example
from
.
import
push_example
from
.
import
push_example
from
.
import
report_example
from
.
import
report_example
from
.
import
schedule_example
from
.
import
schedule_example
from
.
import
group_push_example
from
.
import
group_push_example
from
.
import
admin_example
__all__
=
[
__all__
=
[
device_example
,
device_example
,
push_example
,
push_example
,
report_example
,
report_example
,
schedule_example
,
schedule_example
,
group_push_example
group_push_example
,
admin_example
]
]
examples/admin_example.py
0 → 100644
View file @
f4e291c3
from
.
import
jpush
,
dev_key
,
dev_secret
admin
=
jpush
.
Admin
(
dev_key
,
dev_secret
)
admin
.
set_logging
(
"DEBUG"
)
def
create_app
():
response
=
admin
.
create_app
(
'aaa'
,
'cn.jpush.app'
)
return
response
def
delete_app
(
app_key
):
response
=
admin
.
delete_app
(
app_key
)
return
response
jpush/__init__.py
View file @
f4e291c3
"""Python package for using the JPush API"""
"""Python package for using the JPush API"""
from
.core
import
JPush
,
GroupPush
from
.core
import
JPush
,
GroupPush
,
Admin
from
.common
import
JPushFailure
,
Unauthorized
from
.common
import
JPushFailure
,
Unauthorized
from
.push
import
(
from
.push
import
(
...
@@ -44,6 +44,7 @@ from .schedule import (
...
@@ -44,6 +44,7 @@ from .schedule import (
__all__
=
[
__all__
=
[
JPush
,
JPush
,
GroupPush
,
GroupPush
,
Admin
,
JPushFailure
,
JPushFailure
,
Unauthorized
,
Unauthorized
,
all_
,
all_
,
...
...
jpush/core.py
View file @
f4e291c3
...
@@ -100,3 +100,42 @@ class GroupPush(JPush):
...
@@ -100,3 +100,42 @@ class GroupPush(JPush):
def
create_push
(
self
):
def
create_push
(
self
):
"""Create a Group Push notification."""
"""Create a Group Push notification."""
return
Push
(
self
,
url
=
common
.
GROUP_PUSH_URL
)
return
Push
(
self
,
url
=
common
.
GROUP_PUSH_URL
)
class
Admin
(
JPush
):
def
__init__
(
self
,
key
,
secret
):
JPush
.
__init__
(
self
,
key
,
secret
)
def
create_app
(
self
,
app_name
,
android_package
,
group_name
=
None
):
url
=
'https://admin.jpush.cn/v1/app'
entity
=
{
'app_name'
:
app_name
,
'android_package'
:
android_package
,
'group_name'
:
group_name
}
body
=
json
.
dumps
(
entity
)
response
=
self
.
_request
(
'post'
,
body
,
url
,
content_type
=
None
,
version
=
3
)
return
AdminResponse
(
response
)
def
delete_app
(
self
,
app_key
):
url
=
'https://admin.jpush.cn/v1/app/'
+
app_key
+
'/delete'
response
=
self
.
_request
(
'post'
,
None
,
url
,
content_type
=
None
,
version
=
3
)
return
AdminResponse
(
response
)
class
AdminResponse
(
object
):
payload
=
None
status_code
=
None
def
__init__
(
self
,
response
):
self
.
status_code
=
response
.
status_code
if
0
!=
len
(
response
.
content
):
data
=
response
.
json
()
self
.
payload
=
data
elif
200
==
response
.
status_code
:
self
.
payload
=
"success"
def
get_status_code
(
self
):
return
self
.
status_code
def
__str__
(
self
):
return
"Admin response Payload: {0}"
.
format
(
self
.
payload
)
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