sc-common-interface 2.2.9__tar.gz → 2.3.0__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.2.9
3
+ Version: 2.3.0
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -19,6 +19,7 @@ def create_activity(data):
19
19
  if "platform" in data:
20
20
  platform = data["platform"].upper()
21
21
  response = requests.post(url,headers=headers,json=body)
22
+ print(response.json())
22
23
  if response.status_code==200:
23
24
  activity_id = response.json()["data"]
24
25
  return activity_id
@@ -96,6 +97,47 @@ def send__live_comment(data):
96
97
  response = requests.post(url, headers=header, data=json.dumps(body))
97
98
  return user_id, name, comment_id
98
99
 
100
+ def send_mc_message(data):
101
+ env = data["env"]
102
+ key = data["key"]
103
+ stamp = int(time.time()*1000)
104
+ user_id = "488864%d" % int(time.time())
105
+ if "user_id" in data:
106
+ user_id = data['user_id']
107
+ name = "test live%d" % int(time.time())
108
+ if "name" in data:
109
+ name = data['name']
110
+ message = "接口测试普通留言"
111
+ if "message" in data:
112
+ message = data['message']
113
+ page_id = ""
114
+ if "page_id" in data:
115
+ page_id = data['page_id']
116
+ platform = "FACEBOOK"
117
+ if "platform" in data:
118
+ platform = data['platform']
119
+ if page_id=="":
120
+ info = get_live_info(data)
121
+ platform_list = jsonpath(info, "$..relatedPostList..platform")
122
+ i = platform_list.index(platform)
123
+ page_id = info["data"]["relatedPostList"][i]["page_id"]
124
+ platform = info["data"]["relatedPostList"][i]["platform"]
125
+ body = {}
126
+ if platform.upper()=="FACEBOOK":
127
+ body = {"entry":[{"id":"%s"%page_id,"messaging":[{"message":
128
+ {"mid":"m_hhAqPhSlMTY4En2oWjSB59T3BFjeU97DdDV4WHr3DLWnPrO0iCsjQlG3hBN%d-sBlT26-6oNg"%stamp,"text":"%s"%message},
129
+ "recipient":{"id":"%s"%page_id},"sender":{"id":"%s"%user_id},"timestamp":stamp}],"time":stamp}],"object":"page"}
130
+ elif platform.upper()=="INSTAGRAM":
131
+ body={"object":"instagram","entry":[{"time":stamp,"id":"%s"%page_id,"messaging":[{"sender":{"id":"%s"%user_id},"recipient":{"id":"%s"%page_id},
132
+ "timestamp":stamp,"message":{"mid":"aWdfZAG1faXRlbToxOklHTWVzc2FnZAUlEOjE3ODQxNDUwMzgwODgwNTMzOjM0MDI4MjM2Njg0MTcxMDMwMTI0NDI3NjAyNDExMzcwMDc2NTA5MDozMTgzODU0Mzg3NTY4MDYwMTE3ODUxOTE2MD%d"%stamp,"text":"%s"%message}}]}]}
133
+ url = "%s/facebook/webhook" % env
134
+ sign_text = hmac.new(key.encode("utf-8"), json.dumps(body).encode("utf-8"), sha1)
135
+ signData = sign_text.hexdigest()
136
+ header = {"Content-Type": "application/json", "x-hub-signature": "sha1=%s" % signData}
137
+ response = requests.post(url, headers=header, data=json.dumps(body))
138
+ return user_id, name
139
+
140
+
99
141
 
100
142
  def get_live_info(data):
101
143
  env = data["env"]
@@ -253,10 +295,4 @@ def get_merchant_info(data):
253
295
 
254
296
 
255
297
  if __name__=="__main__":
256
- pass
257
- # data["type"] = "sku"
258
- # data['quantity'] = 0
259
- # spu_id,sku_id,sku_id_quantity,product_info = live_search_oa_product(data)
260
- # print(spu_id)
261
- # print(sku_id)
262
- # print(sku_id_quantity)
298
+ pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.2.9
3
+ Version: 2.3.0
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.2.9',
5
+ version='2.3.0',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),