sc-common-interface 2.2.6__tar.gz → 2.2.8__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.8}/PKG-INFO +1 -1
- sc-common-interface-2.2.8/sc_common_interface/LiveCommonInterface.py +191 -0
- {sc-common-interface-2.2.6 → sc-common-interface-2.2.8}/sc_common_interface/PostCommonInterface.py +8 -3
- {sc-common-interface-2.2.6 → sc-common-interface-2.2.8}/sc_common_interface.egg-info/PKG-INFO +1 -1
- {sc-common-interface-2.2.6 → sc-common-interface-2.2.8}/sc_common_interface.egg-info/SOURCES.txt +1 -0
- {sc-common-interface-2.2.6 → sc-common-interface-2.2.8}/setup.py +1 -1
- {sc-common-interface-2.2.6 → sc-common-interface-2.2.8}/sc_common_interface/Platform.py +0 -0
- {sc-common-interface-2.2.6 → sc-common-interface-2.2.8}/sc_common_interface/__init__.py +0 -0
- {sc-common-interface-2.2.6 → sc-common-interface-2.2.8}/sc_common_interface.egg-info/dependency_links.txt +0 -0
- {sc-common-interface-2.2.6 → sc-common-interface-2.2.8}/sc_common_interface.egg-info/requires.txt +0 -0
- {sc-common-interface-2.2.6 → sc-common-interface-2.2.8}/sc_common_interface.egg-info/top_level.txt +0 -0
- {sc-common-interface-2.2.6 → sc-common-interface-2.2.8}/setup.cfg +0 -0
|
@@ -0,0 +1,191 @@
|
|
|
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
|
+
def live_search_oa_gift(data):
|
|
138
|
+
"""
|
|
139
|
+
查询oa赠品,命名转为驼峰和返回第一个赠品的信息
|
|
140
|
+
:param data:
|
|
141
|
+
:return:
|
|
142
|
+
"""
|
|
143
|
+
env = data["env"]
|
|
144
|
+
headers = data["headers"]
|
|
145
|
+
url = "%s/openApi/proxy/v1/gifts"%env
|
|
146
|
+
params = {"page":1}
|
|
147
|
+
response = requests.get(url,headers=headers,params=params).json()
|
|
148
|
+
items = response["data"]["items"]
|
|
149
|
+
|
|
150
|
+
if items == []:
|
|
151
|
+
# 新增赠品
|
|
152
|
+
body = {"unlimited_quantity": True, "title_translations": {"zh-cn": "接口自动化新增的赠品%s" % int(time.time())},
|
|
153
|
+
"media_ids": "610d2865ca92cf00264c563c"}
|
|
154
|
+
requests.post(url, headers=headers, json=body).json()
|
|
155
|
+
time.sleep(5)
|
|
156
|
+
#新增后去查询
|
|
157
|
+
response = requests.get(url, headers=headers, params=params).json()
|
|
158
|
+
items = response["data"]["items"]
|
|
159
|
+
|
|
160
|
+
# 返回数量不是0的赠品和spu_id
|
|
161
|
+
# print(json.dumps(items))
|
|
162
|
+
quantityList = jsonpath(items,"$..quantity")
|
|
163
|
+
gift_info = items[0]
|
|
164
|
+
for a,b in enumerate(quantityList):
|
|
165
|
+
if b!=0:
|
|
166
|
+
gift_info = items[a]
|
|
167
|
+
spu_id = gift_info["id"]
|
|
168
|
+
return spu_id,gift_info,response
|
|
169
|
+
|
|
170
|
+
def get_merchant_info(data):
|
|
171
|
+
env = data["env"]
|
|
172
|
+
headers = data["headers"]
|
|
173
|
+
merchant_id = data["merchant_id"]
|
|
174
|
+
url = "%s/openApi/proxy/v1/merchants/%s" % (env,merchant_id)
|
|
175
|
+
response = requests.get(url, headers=headers).json()
|
|
176
|
+
base_country_code = response["data"]["base_country_code"]
|
|
177
|
+
currency = ""
|
|
178
|
+
if base_country_code=="TW":
|
|
179
|
+
currency="NT$"
|
|
180
|
+
elif base_country_code=="TH":
|
|
181
|
+
currency = "฿"
|
|
182
|
+
elif base_country_code == "VN":
|
|
183
|
+
#放金额后面
|
|
184
|
+
currency = "₫"
|
|
185
|
+
return base_country_code,currency,response
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
if __name__=="__main__":
|
|
191
|
+
pass
|
{sc-common-interface-2.2.6 → sc-common-interface-2.2.8}/sc_common_interface/PostCommonInterface.py
RENAMED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import datetime
|
|
2
|
-
|
|
3
2
|
import requests
|
|
4
3
|
import json
|
|
5
4
|
from jsonpath import jsonpath
|
|
@@ -160,8 +159,13 @@ def search_oa_gift(data):
|
|
|
160
159
|
response = requests.get(url, headers=headers, params=params).json()
|
|
161
160
|
items = response["data"]["items"]
|
|
162
161
|
|
|
163
|
-
#
|
|
162
|
+
# 返回赠品数量不是0
|
|
163
|
+
# print(json.dumps(items))
|
|
164
|
+
quantityList = jsonpath(items,"$..quantity")
|
|
164
165
|
gift_info = items[0]
|
|
166
|
+
for a,b in enumerate(quantityList):
|
|
167
|
+
if b!=0:
|
|
168
|
+
gift_info = items[a]
|
|
165
169
|
# 下划线命名转变为驼峰命名
|
|
166
170
|
change_dict_into_hump(gift_info)
|
|
167
171
|
|
|
@@ -939,7 +943,7 @@ def get_user_conversation_id(data):
|
|
|
939
943
|
url = "%s/mc/conversation/id?type=%s&user_id=%s&party_channel_id=%s" % (env, platform, user_id, page_id)
|
|
940
944
|
# param = {"type":"facebook","user_id":vars["user_id"],"party_channel_id":vars["platform_channel_id"]}
|
|
941
945
|
response = requests.get(url, headers=headers).json()
|
|
942
|
-
print(response)
|
|
946
|
+
# print(response)
|
|
943
947
|
conversation_id = jsonpath(response, "$.data.id")[0]
|
|
944
948
|
return conversation_id,response
|
|
945
949
|
|
|
@@ -1470,3 +1474,4 @@ if __name__=="__main__":
|
|
|
1470
1474
|
# "relationUrl": "https://www.facebook.com/groups/416632743936652/posts/823646243235298/"}
|
|
1471
1475
|
# res = relate_post(data)
|
|
1472
1476
|
# print(res)
|
|
1477
|
+
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sc-common-interface-2.2.6 → sc-common-interface-2.2.8}/sc_common_interface.egg-info/requires.txt
RENAMED
|
File without changes
|
{sc-common-interface-2.2.6 → sc-common-interface-2.2.8}/sc_common_interface.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|