sc-common-interface 2.0.9__tar.gz → 2.1.2__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.0.9
3
+ Version: 2.1.2
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -0,0 +1,7 @@
1
+ from enum import Enum
2
+
3
+
4
+ class Platform(Enum):
5
+ FACEBOOK = 1
6
+ INSTAGRAM = 2
7
+ FB_GROUP = 3
@@ -8,6 +8,8 @@ import random
8
8
  import hmac
9
9
  from hashlib import sha1
10
10
  import random
11
+ from Platform import Platform
12
+
11
13
 
12
14
 
13
15
  platform = "FACEBOOK"
@@ -347,28 +349,42 @@ def get_page_post(data):
347
349
  fb group:GROUP_POST
348
350
  :return:响应
349
351
  """
352
+ #时间戳转换
353
+
354
+
355
+
350
356
  env = data["env"]
351
357
  headers = data["headers"]
352
358
  platform = "FACEBOOK"
359
+ type = "POST"
360
+ days = 180
361
+ current_time = datetime.datetime.now()
362
+ since = int((current_time - datetime.timedelta(days=days)).timestamp())
363
+ if "type" in data:
364
+ type = data["type"]
353
365
  if "platform" in data:
354
366
  platform = data["platform"].upper()
355
367
  if "page_id" in data:
356
368
  page_id = data["page_id"]
357
369
  else:
358
370
  page_id, page_name, group_id = get_channel_info(data)
359
- if platform=="FB_GROUP":
371
+ if platform==Platform.FB_GROUP.name:
360
372
  page_id = group_id
361
- type = "POST"
362
- if "type" in data:
363
- type = data["type"]
364
- since = 1699027200
365
- if "since" in data:
366
- since = data["since"]
373
+ type = "GROUP_POST"
374
+ since = int((current_time - datetime.timedelta(days=7)).timestamp())
375
+ if "days" in data:
376
+ days = data["days"]
377
+ since = int((current_time - datetime.timedelta(days=int(days))).timestamp())
378
+
379
+ # since = 1699027200
380
+ # if "since" in data:
381
+ # since = data["since"]
367
382
  page_size = 50
368
383
  if "page_size" in data:
369
384
  page_size = data
370
385
  params = {"page_size":page_size,"type":type,"since":since,"party_channel_id":page_id,"platform":platform}
371
386
  url = "%s/api/posts/post"%env
387
+ print("params",params)
372
388
  response =requests.get(url,headers=headers,params=params).json()
373
389
  return response
374
390
 
@@ -1147,7 +1163,7 @@ def modify_message(data):
1147
1163
  headers = data["headers"]
1148
1164
  sales_id = data["sales_id"]
1149
1165
 
1150
- url = "api/posts/post/sales/%s/keyword_message"%sales_id
1166
+ url = "%s/api/posts/post/sales/%s/keyword_message"%(env,sales_id)
1151
1167
  need_send_message = True
1152
1168
  if "need_send_message" in data:
1153
1169
  need_send_message = data["need_send_message"]
@@ -1304,7 +1320,10 @@ def end_post(data):
1304
1320
 
1305
1321
 
1306
1322
  if __name__=="__main__":
1307
- pass
1308
-
1309
-
1323
+ data = {'env': 'https://front-admin.shoplineapp.com', 'headers': {'Content-Type': 'application/json',
1324
+ 'authorization': 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI3YjdiM2E1MzU4M2IwYzlhZGVhODkyZDY3OTJlNTNlMSIsImRhdGEiOnsibWVyY2hhbnRfaWQiOiI2MWIwOTZiZWI3YmVmMTAwMjQ1ZGJkOGIiLCJhcHBsaWNhdGlvbl9pZCI6IjYyN2M3NTBhMDYyMzcwMDAwYWZlNWVmZCJ9LCJpc3MiOiJodHRwczovL2RldmVsb3BlcnMuc2hvcGxpbmVhcHAuY29tIiwiYXVkIjpbXSwic3ViIjoiNjFiMDk2YmViN2JlZjEwMDI0NWRiZDhiIn0.mkq54BMp-20y8oiw0qc9caeUzH-vT6oRkeUCpZrt1jI',
1325
+ 'lang': 'en'}, 'platform': 'FACBOOK',
1326
+ 'patternModel': 'INCLUDE_MATCH', 'title': 'river接口自动化测试搜索贴文销售列表使用', "sales_id": 68242}
1327
+ response = modify_message(data)
1328
+ print(response)
1310
1329
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.0.9
3
+ Version: 2.1.2
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -1,4 +1,5 @@
1
1
  setup.py
2
+ sc_common_interface/Platform.py
2
3
  sc_common_interface/PostCommonInterface.py
3
4
  sc_common_interface/__init__.py
4
5
  sc_common_interface.egg-info/PKG-INFO
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='sc-common-interface',
5
- version='2.0.9',
5
+ version='2.1.2',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),