sc-common-interface 2.3.9__tar.gz → 2.4.1__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.9
3
+ Version: 2.4.1
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -69,7 +69,7 @@ def send__live_comment(data):
69
69
  if page_id == "" or post_id == "":
70
70
  info = get_live_info(data)
71
71
  platform_list = jsonpath(info, "$..relatedPostList..platform")
72
- i = platform_list.index(platform)
72
+ i = platform_list.index(platform.upper())
73
73
  page_id = info["data"]["relatedPostList"][i]["page_id"]
74
74
  platform = info["data"]["relatedPostList"][i]["platform"]
75
75
  post_id = info["data"]["relatedPostList"][i]["post_id"]
@@ -134,7 +134,7 @@ def send_mc_message(data):
134
134
  type = "commment"
135
135
  payload = "{}"
136
136
  if "payload" in data:
137
- payload = json.dumps(data["payload"])
137
+ payload = data["payload"]
138
138
  if "type" in data:
139
139
  type = data["type"]
140
140
  if "user_id" in data:
@@ -173,13 +173,15 @@ def send_mc_message(data):
173
173
  body={"object":"instagram","entry":[{"time":stamp,"id":"%s"%page_id,"messaging":[{"sender":{"id":"%s"%user_id},"recipient":{"id":"%s"%page_id},
174
174
  "timestamp":stamp,"message":{"mid":"aWdfZAG1faXRlbToxOklHTWVzc2FnZAUlEOjE3ODQxNDUwMzgwODgwNTMzOjM0MDI4MjM2Njg0MTcxMDMwMTI0NDI3NjAyNDExMzcwMDc2NTA5MDozMTgzODU0Mzg3NTY4MDYwMTE3ODUxOTE2MD%d"%stamp,"text":"%s"%message}}]}]}
175
175
  elif type=="postback" and platform.upper() in ("FB_GROUP","FACEBOOK"):
176
- t_time = stamp * 1000
177
- body = {"object":"page","entry":[{"time":t_time,"id":"%s"%page_id,"messaging":[{"sender":{"id":"%s"%user_id},"recipient":{"id":"%s"%page_id},"timestamp":t_time,"postback":{"title":"继续 ➡️","payload":payload,"mid":"m_w6KNGd0PMndK0LvCw7Hzy1zsVSWT0fpN3ievQ9LtB0NxnnTQGDMyKI5DFeVbaJIRni1cqqJYXIJ-wq98aw%d"%stamp}}]}]}
176
+ # t_time = stamp * 1000
177
+ body = {"object":"page","entry":[{"time":stamp,"id":"%s"%page_id,"messaging":[{"sender":{"id":"%s"%user_id},"recipient":{"id":"%s"%page_id},"timestamp":stamp,"postback":{"title":"继续 ➡️","payload":payload,"mid":"m_w6KNGd0PMndK0LvCw7Hzy1zsVSWT0fpN3ievQ9LtB0NxnnTQGDMyKI5DFeVbaJIRni1cqqJYXIJ-wq98aw%d"%stamp}}]}]}
178
178
  url = "%s/facebook/webhook" % env
179
179
  sign_text = hmac.new(key.encode("utf-8"), json.dumps(body).encode("utf-8"), sha1)
180
180
  signData = sign_text.hexdigest()
181
181
  header = {"Content-Type": "application/json", "x-hub-signature": "sha1=%s" % signData}
182
182
  response = requests.post(url, headers=header, data=json.dumps(body))
183
+ # print(response.text)
184
+ print(body)
183
185
  return user_id, name
184
186
 
185
187
 
@@ -390,10 +392,117 @@ def get_broadcast_detail(data):
390
392
  response = requests.post(url,headers=headers,json=body).json()
391
393
  return response
392
394
 
395
+ def end_live(data):
396
+ """结束帖文"""
397
+ env = data["env"]
398
+ headers = data["headers"]
399
+ sales_id = data["sales_id"]
400
+ url = "%s/api/posts/live/sales/%s/end" % (env, sales_id)
401
+ response = requests.put(url, headers=headers).json()
402
+ return response
403
+
404
+ def create_live(data):
405
+ """创建直播,不套用通用配置"""
406
+ env = data["env"]
407
+ headers = data["headers"]
408
+ url = "%s/api/posts/live/sales" % (env)
409
+ stamp = int(time.time())
410
+ title = "接口创建的直播活动名称%d"%stamp
411
+ salesDescription = "接口创建的直播活动介绍%d"%stamp
412
+ salesOwner = "接口创建的直播主%d"%stamp
413
+ platform = "FB_GROUP"
414
+ if "platform" in data:
415
+ platform = data["platform"]
416
+
417
+ body = {
418
+ "sales": {
419
+ "title": title,
420
+ "salesOwner": salesOwner,
421
+ "salesDescription": salesDescription,
422
+ "platforms": [
423
+ platform
424
+ ],
425
+ "platformChannels": []
426
+ },
427
+ "salesConfig": {
428
+ "patternModel": {
429
+ "patternModel": "INCLUDE_MATCH",
430
+ "keywordValidInLive": False,
431
+ "keywordValidAfterLive": False
432
+ },
433
+ "autoNotifyPay": {
434
+ "enable": False,
435
+ "message": "",
436
+ "button": ""
437
+ },
438
+ "stock": {
439
+ "lockStock": False,
440
+ "salesStockLockExpireTime": None
441
+ },
442
+ "lowOfQuantity": {
443
+ "enable": True,
444
+ "sound": False,
445
+ "quantity": "1"
446
+ }
447
+ },
448
+ "postConfigMap": {
449
+ platform: {
450
+ "message": {
451
+ "needSendMessage": True,
452
+ "hasInteractionMessage": {
453
+ "firstMessageTemplate": {
454
+ "topMessage": ""
455
+ },
456
+ "messageButton": ""
457
+ },
458
+ "hasLink": True,
459
+ "noInteractionMessage": {
460
+ "firstMessageTemplate": {
461
+ "topMessage": ""
462
+ },
463
+ "firstMessageButton": "",
464
+ "secondMessageTemplate": {
465
+ "topMessage": ""
466
+ },
467
+ "secondMessageButton": ""
468
+ },
469
+ "messageType": "MESSAGE"
470
+ }
471
+ }
472
+ }
473
+ }
474
+ response = requests.post(url,headers=headers,json=body).json()
475
+ print(response)
476
+ sales_id = response["data"]["sales"]["id"]
477
+ return sales_id
478
+
479
+
480
+ def add_live(data):
481
+ """fb——group 链接帖文"""
482
+ env = data["env"]
483
+ headers = data["headers"]
484
+ sales_id = data["sales_id"]
485
+ url = "%s/api/posts/live/sales/%s/addLive"%(env,sales_id)
486
+ pageId = data["page_id"]
487
+ relationUrl = data["relationUrl"]
488
+
489
+ body = {
490
+ "pageId": pageId,
491
+ "platform": "FB_GROUP",
492
+ "relationUrl": relationUrl
493
+ }
494
+ response = requests.post(url,headers=headers,json=body).json()
495
+ return response
496
+
497
+
498
+
499
+
500
+
501
+
393
502
 
394
503
 
395
504
 
396
505
 
397
506
 
398
507
  if __name__=="__main__":
399
- pass
508
+ pass
@@ -1196,6 +1196,8 @@ def modelone_create_single_product(data):
1196
1196
  body = {"customKey":keyword,"quantity":quantity,"unlimitedQuantity":False,"productName":product_name,
1197
1197
  "imageUrl":"https://s3-ap-southeast-1.amazonaws.com/static.shoplineapp.com/sc-admin/product-default.png","price":3}
1198
1198
  response = requests.post(url,headers=headers,json=body).json()
1199
+ # print(body)
1200
+ print(response)
1199
1201
  spu_id = response["data"]
1200
1202
  return spu_id
1201
1203
 
@@ -1645,10 +1647,4 @@ def edit_message(data):
1645
1647
 
1646
1648
 
1647
1649
  if __name__=="__main__":
1648
- data = {'env': 'https://front-admin-preview.shoplineapp.com', 'headers': {'Content-Type': 'application/json', 'authorization': 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIwNmUxNGU2NzAxMWY0ZDNhMGU0ZDgyNDk3ZDAxYmQwZSIsImRhdGEiOnsibWVyY2hhbnRfaWQiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAiLCJhcHBsaWNhdGlvbl9pZCI6IjVmNTlmMTI4MzcyZWIzMDAwNmRjNDcwMSJ9LCJpc3MiOiJodHRwczovL2RldmVsb3BlcnMtcHJldmlldy5zaG9wbGluZWFwcC5jb20iLCJhdWQiOltdLCJzdWIiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAifQ.gUqa8FJs_vjRJ-kFMhOZx42QtCr7XxcN3gKSK6_4Zvs', 'lang': 'en'}, 'sales_id': 513416, 'platform': 'FB_GROUP'}
1649
- sales_id,response = create_post_lucky_draw(data)
1650
- data["sales_id"] = sales_id
1651
- print(sales_id)
1652
- data["prize_type"] = "discount"
1653
- res2 = modify_lucky_draw(data)
1654
- print(res2)
1650
+ pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.3.9
3
+ Version: 2.4.1
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.9',
5
+ version='2.4.1',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),