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
bd5b8772
Commit
bd5b8772
authored
Jan 29, 2018
by
Helperhaps
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get url all together
parent
f4e291c3
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
46 additions
and
50 deletions
+46
-50
schedule_example.py
examples/schedule_example.py
+1
-1
common.py
jpush/common.py
+8
-18
core.py
jpush/core.py
+2
-2
core.py
jpush/device/core.py
+3
-3
core.py
jpush/push/core.py
+7
-6
core.py
jpush/report/core.py
+15
-8
core.py
jpush/schedule/core.py
+10
-12
No files found.
examples/schedule_example.py
View file @
bd5b8772
...
@@ -10,7 +10,7 @@ def delete_schedule():
...
@@ -10,7 +10,7 @@ def delete_schedule():
def
get_schedule
():
def
get_schedule
():
schedule
.
get_schedule_by_id
(
"e9c553d0-0850-11e6-b6d4-0021f652c102"
)
schedule
.
get_schedule_by_id
(
"e9c553d0-0850-11e6-b6d4-0021f652c102"
)
def
get_schedule
():
def
get_schedule
_list
():
schedule
.
get_schedule_list
(
"1"
)
schedule
.
get_schedule_list
(
"1"
)
def
post_schedule
():
def
post_schedule
():
...
...
jpush/common.py
View file @
bd5b8772
...
@@ -2,24 +2,14 @@ import json
...
@@ -2,24 +2,14 @@ import json
import
logging
import
logging
import
requests
import
requests
BASE_URL
=
"https://api.jpush.cn/"
PUSH_URL
=
'https://api.jpush.cn/v3/'
PUSH_URL
=
BASE_URL
+
'v3/push'
REPORT_URL
=
'https://report.jpush.cn/v3/'
VALIDATE_PUSH_URL
=
BASE_URL
+
'v3/push/validate'
DEVICE_URL
=
'https://device.jpush.cn/v3/devices/'
GROUP_PUSH_URL
=
BASE_URL
+
'v3/grouppush'
ALIAS_URL
=
'https://device.jpush.cn/v3/aliases/'
TAG_URL
=
'https://device.jpush.cn/v3/tags/'
DEVICE_BASEURL
=
"https://device.jpush.cn/"
SCHEDULE_URL
=
'https://api.jpush.cn/v3/schedules/'
DEVICE_URL
=
DEVICE_BASEURL
+
"v3/devices/"
ADMIN_URL
=
'https://admin.jpush.cn/v1/'
TAG_URL
=
DEVICE_BASEURL
+
"v3/tags/"
TAGLIST_URL
=
TAG_URL
ALIAS_URL
=
DEVICE_BASEURL
+
"v3/aliases/"
REPORT_BASEURL
=
"https://report.jpush.cn/"
RECEIVED_URL
=
REPORT_BASEURL
+
"v3/received?msg_ids="
MESSAGES_URL
=
REPORT_BASEURL
+
"v3/messages?msg_ids="
USERS_URL
=
REPORT_BASEURL
+
"v3/users?"
BASE_SCHEDULEURL
=
"https://api.jpush.cn/v3/schedules/"
BASE_LISTURL
=
"https://api.jpush.cn/v3/schedules?page="
logger
=
logging
.
getLogger
(
'jpush'
)
logger
=
logging
.
getLogger
(
'jpush'
)
...
...
jpush/core.py
View file @
bd5b8772
...
@@ -56,7 +56,7 @@ class JPush(object):
...
@@ -56,7 +56,7 @@ class JPush(object):
"JPush.push() is deprecated. See documentation on upgrading."
,
"JPush.push() is deprecated. See documentation on upgrading."
,
DeprecationWarning
)
DeprecationWarning
)
body
=
json
.
dumps
(
payload
)
body
=
json
.
dumps
(
payload
)
self
.
_request
(
'POST'
,
body
,
common
.
PUSH_URL
,
'application/json'
,
version
=
1
)
self
.
_request
(
'POST'
,
body
,
common
.
PUSH_URL
+
'push'
,
'application/json'
,
version
=
1
)
def
set_logging
(
self
,
level
):
def
set_logging
(
self
,
level
):
level_list
=
[
"CRITICAL"
,
"ERROR"
,
"WARNING"
,
"INFO"
,
"DEBUG"
,
"NOTSET"
]
level_list
=
[
"CRITICAL"
,
"ERROR"
,
"WARNING"
,
"INFO"
,
"DEBUG"
,
"NOTSET"
]
...
@@ -99,7 +99,7 @@ class GroupPush(JPush):
...
@@ -99,7 +99,7 @@ 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
,
end_point
=
'grouppush'
)
class
Admin
(
JPush
):
class
Admin
(
JPush
):
def
__init__
(
self
,
key
,
secret
):
def
__init__
(
self
,
key
,
secret
):
...
...
jpush/device/core.py
View file @
bd5b8772
...
@@ -8,12 +8,12 @@ class Device(object):
...
@@ -8,12 +8,12 @@ class Device(object):
"""
"""
def
__init__
(
self
,
jpush
):
def
__init__
(
self
,
jpush
):
self
.
_jpush
=
jpush
self
.
_jpush
=
jpush
self
.
entity
=
None
self
.
entity
=
None
def
send
(
self
,
method
,
url
,
body
,
content_type
=
None
,
version
=
3
):
def
send
(
self
,
method
,
url
,
body
,
content_type
=
None
,
version
=
3
):
"""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
)
return
DeviceResponse
(
response
)
return
DeviceResponse
(
response
)
...
@@ -21,7 +21,7 @@ class Device(object):
...
@@ -21,7 +21,7 @@ class Device(object):
def
get_taglist
(
self
):
def
get_taglist
(
self
):
"""Get deviceinfo with registration id.
"""Get deviceinfo with registration id.
"""
"""
url
=
common
.
TAG
LIST
_URL
url
=
common
.
TAG_URL
body
=
None
body
=
None
info
=
self
.
send
(
"GET"
,
url
,
body
)
info
=
self
.
send
(
"GET"
,
url
,
body
)
return
info
return
info
...
...
jpush/push/core.py
View file @
bd5b8772
...
@@ -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
,
url
=
common
.
PUSH_URL
):
def
__init__
(
self
,
jpush
,
end_point
=
'push'
):
self
.
_jpush
=
jpush
self
.
_jpush
=
jpush
self
.
audience
=
None
self
.
audience
=
None
self
.
notification
=
None
self
.
notification
=
None
...
@@ -17,7 +17,7 @@ class Push(object):
...
@@ -17,7 +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
self
.
end_point
=
end_point
@property
@property
def
payload
(
self
):
def
payload
(
self
):
...
@@ -49,7 +49,7 @@ class Push(object):
...
@@ -49,7 +49,7 @@ class Push(object):
"""
"""
body
=
json
.
dumps
(
self
.
payload
)
body
=
json
.
dumps
(
self
.
payload
)
url
=
self
.
url
url
=
common
.
PUSH_URL
+
self
.
end_point
response
=
self
.
_jpush
.
_request
(
'POST'
,
body
,
url
,
'application/json'
,
version
=
3
)
response
=
self
.
_jpush
.
_request
(
'POST'
,
body
,
url
,
'application/json'
,
version
=
3
)
return
PushResponse
(
response
)
return
PushResponse
(
response
)
...
@@ -63,17 +63,18 @@ class Push(object):
...
@@ -63,17 +63,18 @@ class Push(object):
"""
"""
body
=
json
.
dumps
(
self
.
payload
)
body
=
json
.
dumps
(
self
.
payload
)
response
=
self
.
_jpush
.
_request
(
'POST'
,
body
,
common
.
VALIDATE_PUSH_URL
,
'application/json'
,
version
=
3
)
url
=
common
.
PUSH_URL
+
'push/validate'
response
=
self
.
_jpush
.
_request
(
'POST'
,
body
,
url
,
'application/json'
,
version
=
3
)
return
PushResponse
(
response
)
return
PushResponse
(
response
)
def
get_cid
(
self
,
count
,
type
=
None
):
def
get_cid
(
self
,
count
,
type
=
None
):
body
=
None
body
=
None
url
=
common
.
VALIDATE_PUSH_URL
+
'
/cid'
url
=
common
.
PUSH_URL
+
'push
/cid'
params
=
{
params
=
{
'count'
:
count
,
'count'
:
count
,
'type'
:
type
'type'
:
type
}
}
response
=
self
.
_jpush
.
_request
(
'GET'
,
body
,
common
.
VALIDATE_PUSH_URL
,
'application/json'
,
version
=
3
,
params
=
params
)
response
=
self
.
_jpush
.
_request
(
'GET'
,
body
,
url
,
'application/json'
,
version
=
3
,
params
=
params
)
return
PushResponse
(
response
)
return
PushResponse
(
response
)
...
...
jpush/report/core.py
View file @
bd5b8772
...
@@ -9,28 +9,35 @@ class Report(object):
...
@@ -9,28 +9,35 @@ class Report(object):
def
__init__
(
self
,
jpush
):
def
__init__
(
self
,
jpush
):
self
.
_jpush
=
jpush
self
.
_jpush
=
jpush
def
send
(
self
,
method
,
url
,
body
,
content_type
=
None
,
version
=
3
):
def
send
(
self
,
method
,
url
,
body
,
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
ReportResponse
(
response
)
return
ReportResponse
(
response
)
def
get_received
(
self
,
msg_ids
):
def
get_received
(
self
,
msg_ids
):
url
=
common
.
RECEIVED_URL
+
msg_ids
url
=
common
.
REPORT_URL
+
'received'
params
=
{
'msg_ids'
:
msg_ids
}
body
=
None
body
=
None
received
=
self
.
send
(
"GET"
,
url
,
body
)
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
.
MESSAGES_URL
+
msg_ids
url
=
common
.
REPORT_URL
+
'messages'
params
=
{
'msg_ids'
:
msg_ids
}
body
=
None
body
=
None
messages
=
self
.
send
(
"GET"
,
url
,
body
)
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
):
url
=
common
.
USERS_URL
+
"time_unit="
+
time_unit
+
"&start="
+
start
+
"&duration="
+
duration
url
=
common
.
REPORT_URL
+
'users'
params
=
{
'time_unit'
:
time_unit
,
'start'
:
start
,
'duration'
:
duration
}
body
=
None
body
=
None
users
=
self
.
send
(
"GET"
,
url
,
body
)
users
=
self
.
send
(
"GET"
,
url
,
body
,
params
=
params
)
return
users
return
users
...
...
jpush/schedule/core.py
View file @
bd5b8772
...
@@ -10,39 +10,37 @@ class Schedule(object):
...
@@ -10,39 +10,37 @@ class Schedule(object):
def
__init__
(
self
,
jpush
):
def
__init__
(
self
,
jpush
):
self
.
_jpush
=
jpush
self
.
_jpush
=
jpush
def
send
(
self
,
method
,
url
,
body
,
content_type
=
None
,
version
=
3
):
def
send
(
self
,
method
,
url
,
body
,
content_type
=
None
,
version
=
3
,
params
=
None
):
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
ScheduleResponse
(
response
)
return
ScheduleResponse
(
response
)
def
post_schedule
(
self
,
schedulepayload
):
def
post_schedule
(
self
,
schedulepayload
):
url
=
common
.
BASE_SCHEDULE
URL
url
=
common
.
SCHEDULE_
URL
body
=
json
.
dumps
(
schedulepayload
)
body
=
json
.
dumps
(
schedulepayload
)
result
=
self
.
send
(
"POST"
,
url
,
body
)
result
=
self
.
send
(
"POST"
,
url
,
body
)
return
result
return
result
def
get_schedule_by_id
(
self
,
schedule_id
):
def
get_schedule_by_id
(
self
,
schedule_id
):
url
=
common
.
BASE_SCHEDULE
URL
+
schedule_id
url
=
common
.
SCHEDULE_
URL
+
schedule_id
body
=
None
body
=
None
result
=
self
.
send
(
"GET"
,
url
,
body
)
result
=
self
.
send
(
"GET"
,
url
,
body
)
return
result
return
result
def
get_schedule_list
(
self
,
page_id
):
def
get_schedule_list
(
self
,
page
=
1
):
if
page_id
is
not
None
:
url
=
common
.
SCHEDULE_URL
url
=
common
.
BASE_LISTURL
+
page_id
params
=
{
'page'
:
page
}
else
:
url
=
common
.
BASE_LISTURL
body
=
None
body
=
None
result
=
self
.
send
(
"GET"
,
url
,
body
)
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
):
url
=
common
.
BASE_SCHEDULE
URL
+
schedule_id
url
=
common
.
SCHEDULE_
URL
+
schedule_id
body
=
json
.
dumps
(
schedulepayload
)
body
=
json
.
dumps
(
schedulepayload
)
result
=
self
.
send
(
"PUT"
,
url
,
body
)
result
=
self
.
send
(
"PUT"
,
url
,
body
)
return
result
return
result
def
delete_schedule
(
self
,
schedule_id
):
def
delete_schedule
(
self
,
schedule_id
):
url
=
common
.
BASE_SCHEDULE
URL
+
schedule_id
url
=
common
.
SCHEDULE_
URL
+
schedule_id
body
=
None
body
=
None
result
=
self
.
send
(
"DELETE"
,
url
,
body
)
result
=
self
.
send
(
"DELETE"
,
url
,
body
)
return
result
return
result
...
...
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