sc-common-interface 2.3.5__tar.gz → 2.3.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.3.5
3
+ Version: 2.3.7
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -56,19 +56,23 @@ def send__live_comment(data):
56
56
  platform = "FACEBOOK"
57
57
  page_id = ""
58
58
  post_id = ""
59
+ group_id = ""
59
60
  if "page_id" in data:
60
61
  page_id = data['page_id']
61
62
  if "platform" in data:
62
63
  platform = data['platform']
63
64
  if "post_id" in data:
64
65
  post_id = data['post_id']
66
+ if "group_id" in data:
67
+ post_id = data['group_id']
65
68
  if page_id == "" or post_id == "":
66
69
  info = get_live_info(data)
67
70
  platform_list = jsonpath(info, "$..relatedPostList..platform")
68
71
  i = platform_list.index(platform)
69
72
  page_id = info["data"]["relatedPostList"][i]["page_id"]
70
73
  platform = info["data"]["relatedPostList"][i]["platform"]
71
- post_id = info["data"]["relatedPostList"][i]["post_id"]
74
+ post_id = info["data"]["relatedPostList"][i]["post_id"]
75
+ group_id = info["data"]["relatedPostList"][i]["group_id"]
72
76
  # info = get_live_info(data)
73
77
  # related_post_list = info["data"]["relatedPostList"][0]
74
78
  # page_id = related_post_list["page_id"]
@@ -95,21 +99,21 @@ def send__live_comment(data):
95
99
  "promotion_status": "inactive", "id": post_id}, "message": keyword, "item": "comment",
96
100
  "verb": "add", "post_id": post_id, "comment_id": comment_id,
97
101
  "created_time": stamp, "parent_id": post_id}}]}]}
98
- # if platform == "FACEBOOK":
99
- # body = {"object": "page", "entry": [{"id": page_id, "time": stamp, "changes": [{"field": "feed", "value": {
100
- # "from": {"id": user_id, "name": name},
101
- # "post": {"status_type": "added_video", "is_published": True, "updated_time": "2022-11-18T09:57:26+0000",
102
- # "permalink_url": "https://www.facebook.com/permalink.php?story_fbid=pfbid02jLK3e6YdFSXp2DmD7j7vtStLXoBzTi8rxKrp6jFhVMUTTEgz6qvZA8soR9Uwydd8l&id=107977035056574",
103
- # "promotion_status": "inactive", "id": post_id}, "message": keyword, "item": "comment",
104
- # "verb": "add", "post_id": post_id, "comment_id": comment_id,
105
- # "created_time": stamp, "parent_id": post_id}}]}]}
106
- if platform == "INSTAGRAM":
102
+
103
+ if platform.upper() == "INSTAGRAM":
107
104
  body = {"entry": [{"id": page_id, "time": stamp, "changes": [{"value": {"from": {"id": user_id,
108
105
  "username": name},
109
106
  "media": {"id": post_id,
110
107
  "media_product_type": "FEED"},
111
108
  "id": comment_id, "text": keyword},
112
109
  "field": "comments"}]}], "object": "instagram"}
110
+ elif platform.upper() == "FB_GROUP":
111
+ t_time = stamp*1000
112
+ post_id = post_id.split("_")[-1]
113
+ comment_id = "%d%d" % ( stamp, num)
114
+ body = {"object":"page","entry":[{"id":page_id,"time":t_time,"messaging":[{"recipient":{"id":page_id},"message":keyword,
115
+ "from":{"id":user_id,"name":name},"group_id":group_id,"post_id":post_id,"comment_id":comment_id,"created_time":stamp,"item":"comment",
116
+ "verb":"add","parent_id":post_id,"field":"group_feed"}]}]}
113
117
  print(body)
114
118
  url = "%s/facebook/webhook" % env
115
119
  sign_text = hmac.new(key.encode("utf-8"), json.dumps(body).encode("utf-8"), sha1)
@@ -392,6 +392,9 @@ def get_page_post(data):
392
392
  response =requests.get(url,headers=headers,params=params).json()
393
393
  return response
394
394
 
395
+
396
+
397
+
395
398
  def relate_post(data):
396
399
  """
397
400
  链接贴文,只链接返回的第一个可链接的贴文
@@ -1164,6 +1167,34 @@ def modelone_create_single_product(data):
1164
1167
  env = data["env"]
1165
1168
  headers = data["headers"]
1166
1169
  sales_id = data["sales_id"]
1170
+ quantity = 1000
1171
+ if "quantity" in data:
1172
+ quantity = data["quantity"]
1173
+ url = "%s/api/posts/post/sales/%s/product/create" % (env, sales_id)
1174
+ product_name = "post接口新增商品多规格商品名称%d" % int(time.time())
1175
+ if "product_name" in data:
1176
+ product_name = data["product_name"]
1177
+ keyword = "post接口新增商品多规格商品关键字%d" % int(time.time())
1178
+ if "keyword" in data:
1179
+ keyword = data["keyword"]
1180
+ body = {"customKey":keyword,"quantity":quantity,"unlimitedQuantity":False,"productName":product_name,
1181
+ "imageUrl":"https://s3-ap-southeast-1.amazonaws.com/static.shoplineapp.com/sc-admin/product-default.png","price":3}
1182
+ response = requests.post(url,headers=headers,json=body).json()
1183
+ spu_id = response["data"]
1184
+ return spu_id
1185
+
1186
+ def modelfour_create_single_product(data):
1187
+ """
1188
+ 贴文新增无规格商品
1189
+ :param data:
1190
+ :return: 返回新增的商品的spu_id
1191
+ """
1192
+ env = data["env"]
1193
+ headers = data["headers"]
1194
+ sales_id = data["sales_id"]
1195
+ quantity = 1000
1196
+ if "quantity" in data:
1197
+ quantity = data["quantity"]
1167
1198
  url = "%s/api/posts/post/sales/%s/product/create" % (env, sales_id)
1168
1199
  product_name = "post接口新增商品多规格商品名称%d" % int(time.time())
1169
1200
  if "product_name" in data:
@@ -1171,12 +1202,13 @@ def modelone_create_single_product(data):
1171
1202
  keyword = "post接口新增商品多规格商品关键字%d" % int(time.time())
1172
1203
  if "keyword" in data:
1173
1204
  keyword = data["keyword"]
1174
- body = {"customKey":keyword,"quantity":5,"unlimitedQuantity":False,"productName":product_name,
1205
+ body = {"customNumber":keyword,"quantity":quantity,"unlimitedQuantity":False,"productName":product_name,
1175
1206
  "imageUrl":"https://s3-ap-southeast-1.amazonaws.com/static.shoplineapp.com/sc-admin/product-default.png","price":3}
1176
1207
  response = requests.post(url,headers=headers,json=body).json()
1177
1208
  spu_id = response["data"]
1178
1209
  return spu_id
1179
1210
 
1211
+
1180
1212
  def modelone_create_mutil_product(data):
1181
1213
  """
1182
1214
  贴文新增多规格商品,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.3.5
3
+ Version: 2.3.7
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='sc-common-interface',
5
- version='2.3.5',
5
+ version='2.3.7',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),