sc-common-interface 2.2.6__tar.gz → 2.2.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sc-common-interface-2.2.6 → sc-common-interface-2.2.7}/PKG-INFO +1 -1
- sc-common-interface-2.2.7/sc_common_interface/LiveCommonInterface.py +142 -0
- {sc-common-interface-2.2.6 → sc-common-interface-2.2.7}/sc_common_interface/PostCommonInterface.py +0 -1
- {sc-common-interface-2.2.6 → sc-common-interface-2.2.7}/sc_common_interface.egg-info/PKG-INFO +1 -1
- {sc-common-interface-2.2.6 → sc-common-interface-2.2.7}/sc_common_interface.egg-info/SOURCES.txt +1 -0
- {sc-common-interface-2.2.6 → sc-common-interface-2.2.7}/setup.py +1 -1
- {sc-common-interface-2.2.6 → sc-common-interface-2.2.7}/sc_common_interface/Platform.py +0 -0
- {sc-common-interface-2.2.6 → sc-common-interface-2.2.7}/sc_common_interface/__init__.py +0 -0
- {sc-common-interface-2.2.6 → sc-common-interface-2.2.7}/sc_common_interface.egg-info/dependency_links.txt +0 -0
- {sc-common-interface-2.2.6 → sc-common-interface-2.2.7}/sc_common_interface.egg-info/requires.txt +0 -0
- {sc-common-interface-2.2.6 → sc-common-interface-2.2.7}/sc_common_interface.egg-info/top_level.txt +0 -0
- {sc-common-interface-2.2.6 → sc-common-interface-2.2.7}/setup.cfg +0 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
import requests
|
|
3
|
+
import json
|
|
4
|
+
from jsonpath import jsonpath
|
|
5
|
+
import time
|
|
6
|
+
import random
|
|
7
|
+
import hmac
|
|
8
|
+
from hashlib import sha1
|
|
9
|
+
import random
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def create_activity(data):
|
|
13
|
+
env = data["env"]
|
|
14
|
+
headers = data["headers"]
|
|
15
|
+
body = data["body"]
|
|
16
|
+
sales_id = data["sales_id"]
|
|
17
|
+
url = "%s/api/posts/activity/%s"%(env,sales_id)
|
|
18
|
+
platform = "FACEBOOK"
|
|
19
|
+
if "platform" in data:
|
|
20
|
+
platform = data["platform"].upper()
|
|
21
|
+
response = requests.post(url,headers=headers,json=body)
|
|
22
|
+
if response.status_code==200:
|
|
23
|
+
activity_id = response.json()["data"]
|
|
24
|
+
return activity_id
|
|
25
|
+
else:
|
|
26
|
+
return response
|
|
27
|
+
|
|
28
|
+
def delate_activity(data):
|
|
29
|
+
env = data["env"]
|
|
30
|
+
headers = data["headers"]
|
|
31
|
+
activity_id = data["activity_id"]
|
|
32
|
+
url = "%s/api/activity/%s" % (env, activity_id)
|
|
33
|
+
response = requests.delete(url,headers=headers).json()
|
|
34
|
+
return response
|
|
35
|
+
|
|
36
|
+
def start_activity(data):
|
|
37
|
+
env = data["env"]
|
|
38
|
+
headers = data["headers"]
|
|
39
|
+
activity_id = data["activity_id"]
|
|
40
|
+
url = "%s/api/activity/%s/start" % (env, activity_id)
|
|
41
|
+
response = requests.post(url,headers=headers).json()
|
|
42
|
+
return response
|
|
43
|
+
|
|
44
|
+
def end_activity(data):
|
|
45
|
+
env = data["env"]
|
|
46
|
+
headers = data["headers"]
|
|
47
|
+
activity_id = data["activity_id"]
|
|
48
|
+
url = "%s/api/activity/%s/end" % (env, activity_id)
|
|
49
|
+
response = requests.post(url, headers=headers).json()
|
|
50
|
+
return response
|
|
51
|
+
|
|
52
|
+
def send__live_comment(data):
|
|
53
|
+
env = data["env"]
|
|
54
|
+
key = data["key"]
|
|
55
|
+
info = get_live_info(data)
|
|
56
|
+
related_post_list = info["data"]["relatedPostList"][0]
|
|
57
|
+
page_id = related_post_list["page_id"]
|
|
58
|
+
post_id = related_post_list["post_id"]
|
|
59
|
+
platform = related_post_list["platform"]
|
|
60
|
+
stamp = int(time.time())
|
|
61
|
+
num = random.randint(100000, 999999)
|
|
62
|
+
user_id = "488864%d" % int(time.time())
|
|
63
|
+
if "user_id" in data:
|
|
64
|
+
user_id = data['user_id']
|
|
65
|
+
name = "test live%d" % int(time.time())
|
|
66
|
+
if "name" in data:
|
|
67
|
+
name = data['name']
|
|
68
|
+
comment_id = "%s_%d%d" % (page_id, stamp, num)
|
|
69
|
+
if "comment_id" in data:
|
|
70
|
+
comment_id = data['comment_id']
|
|
71
|
+
keyword = "接口测试普通留言"
|
|
72
|
+
if "keyword" in data:
|
|
73
|
+
keyword = data['keyword']
|
|
74
|
+
body = {}
|
|
75
|
+
if platform == "FACEBOOK":
|
|
76
|
+
body = {"object": "page", "entry": [{"id": page_id, "time": stamp, "changes": [{"field": "feed", "value": {
|
|
77
|
+
"from": {"id": user_id, "name": name},
|
|
78
|
+
"post": {"status_type": "added_video", "is_published": True, "updated_time": "2022-11-18T09:57:26+0000",
|
|
79
|
+
"permalink_url": "https://www.facebook.com/permalink.php?story_fbid=pfbid02jLK3e6YdFSXp2DmD7j7vtStLXoBzTi8rxKrp6jFhVMUTTEgz6qvZA8soR9Uwydd8l&id=107977035056574",
|
|
80
|
+
"promotion_status": "inactive", "id": post_id}, "message": keyword, "item": "comment",
|
|
81
|
+
"verb": "add", "post_id": post_id, "comment_id": comment_id,
|
|
82
|
+
"created_time": stamp, "parent_id": post_id}}]}]}
|
|
83
|
+
elif platform == "INSTAGRAM":
|
|
84
|
+
body = {"entry": [{"id": page_id, "time": stamp, "changes": [{"value": {"from": {"id": user_id,
|
|
85
|
+
"username": name},
|
|
86
|
+
"media": {"id": post_id,
|
|
87
|
+
"media_product_type": "FEED"},
|
|
88
|
+
"id": comment_id, "text": keyword},
|
|
89
|
+
"field": "comments"}]}], "object": "instagram"}
|
|
90
|
+
|
|
91
|
+
url = "%s/facebook/webhook" % env
|
|
92
|
+
sign_text = hmac.new(key.encode("utf-8"), json.dumps(body).encode("utf-8"), sha1)
|
|
93
|
+
signData = sign_text.hexdigest()
|
|
94
|
+
# print("body", json.dumps(body))
|
|
95
|
+
header = {"Content-Type": "application/json", "x-hub-signature": "sha1=%s" % signData}
|
|
96
|
+
response = requests.post(url, headers=header, data=json.dumps(body))
|
|
97
|
+
return user_id, name, comment_id
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def get_live_info(data):
|
|
101
|
+
env = data["env"]
|
|
102
|
+
headers = data["headers"]
|
|
103
|
+
sales_id = data["sales_id"]
|
|
104
|
+
url = "%s/api/posts/live/sales/%s" % (env, sales_id)
|
|
105
|
+
response = requests.get(url,headers=headers).json()
|
|
106
|
+
return response
|
|
107
|
+
|
|
108
|
+
def get_activity_detail(data):
|
|
109
|
+
"""
|
|
110
|
+
type:
|
|
111
|
+
luckyDraw,抽奖活动
|
|
112
|
+
voucher--留言抢优惠
|
|
113
|
+
answerFirst--抢答
|
|
114
|
+
bidding--竞标
|
|
115
|
+
vote:投票
|
|
116
|
+
:param data:
|
|
117
|
+
:return:
|
|
118
|
+
"""
|
|
119
|
+
env = data["env"]
|
|
120
|
+
headers = data["headers"]
|
|
121
|
+
activity_id = data["activity_id"]
|
|
122
|
+
type = data["type"]
|
|
123
|
+
url = ""
|
|
124
|
+
if type in "luckyDraw":
|
|
125
|
+
url = "%s/api/activity/luckyDraw/%s"% (env, activity_id)
|
|
126
|
+
elif type in "voucher":
|
|
127
|
+
url = "%s/api/activity/voucher/%s" % (env, activity_id)
|
|
128
|
+
elif type in "answerFirst":
|
|
129
|
+
url = "%s/api/activity/answerFirst/%s" % (env, activity_id)
|
|
130
|
+
elif type in "bidding":
|
|
131
|
+
url = "%s/api/activity/bidding/%s" % (env, activity_id)
|
|
132
|
+
elif type in "vote":
|
|
133
|
+
url = "%s/api/activity/vote/%s" % (env, activity_id)
|
|
134
|
+
response = requests.get(url,headers=headers).json()
|
|
135
|
+
return response
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
if __name__=="__main__":
|
|
142
|
+
pass
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sc-common-interface-2.2.6 → sc-common-interface-2.2.7}/sc_common_interface.egg-info/requires.txt
RENAMED
|
File without changes
|
{sc-common-interface-2.2.6 → sc-common-interface-2.2.7}/sc_common_interface.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|