smartpush 2.0.6__py3-none-any.whl → 2.0.8__py3-none-any.whl
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.
- smartpush/email/activity.py +2 -12
- smartpush/email/schema.py +10 -0
- smartpush/email/universal_content.py +149 -60
- smartpush/openapi/openapi.py +41 -15
- {smartpush-2.0.6.dist-info → smartpush-2.0.8.dist-info}/METADATA +1 -1
- {smartpush-2.0.6.dist-info → smartpush-2.0.8.dist-info}/RECORD +8 -8
- {smartpush-2.0.6.dist-info → smartpush-2.0.8.dist-info}/WHEEL +0 -0
- {smartpush-2.0.6.dist-info → smartpush-2.0.8.dist-info}/top_level.txt +0 -0
smartpush/email/activity.py
CHANGED
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
from smartpush.base.request_base import ActivityTemplateRequestBase, RequestBase
|
|
1
|
+
from smartpush.base.request_base import ActivityTemplateRequestBase
|
|
4
2
|
from smartpush.base.url_enum import URL
|
|
5
|
-
from smartpush.utils.date_utils import *
|
|
6
3
|
from smartpush.email.schema import *
|
|
7
|
-
|
|
8
|
-
"""
|
|
9
|
-
创建活动草稿
|
|
10
|
-
"""
|
|
11
|
-
|
|
12
|
-
"""
|
|
13
|
-
更新活动草稿内容
|
|
14
|
-
"""
|
|
4
|
+
from smartpush.utils.date_utils import *
|
|
15
5
|
|
|
16
6
|
|
|
17
7
|
class ActivityTemplate(ActivityTemplateRequestBase):
|
smartpush/email/schema.py
CHANGED
|
@@ -10,10 +10,19 @@ def generate_UUID(length=None):
|
|
|
10
10
|
else:
|
|
11
11
|
return _uuid
|
|
12
12
|
|
|
13
|
+
|
|
13
14
|
class BlockType(Enum):
|
|
14
15
|
Section = 1
|
|
15
16
|
Block = 0
|
|
16
17
|
|
|
18
|
+
@staticmethod
|
|
19
|
+
def getType(block_type):
|
|
20
|
+
if block_type == BlockType.Section.name:
|
|
21
|
+
return BlockType.Section.value
|
|
22
|
+
else:
|
|
23
|
+
return BlockType.Block.value
|
|
24
|
+
|
|
25
|
+
|
|
17
26
|
@unique
|
|
18
27
|
class BlockSchema(Enum):
|
|
19
28
|
Logo = {
|
|
@@ -551,6 +560,7 @@ class BlockSchema(Enum):
|
|
|
551
560
|
elif isinstance(node, list):
|
|
552
561
|
for item in node:
|
|
553
562
|
recursive_parse(item)
|
|
563
|
+
|
|
554
564
|
recursive_parse(schema if isinstance(schema, dict) else schema.value)
|
|
555
565
|
schemaAnalysis = {"schema": result}
|
|
556
566
|
return json.dumps(schemaAnalysis)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import time
|
|
2
|
+
from typing import Optional, List, Dict, Any
|
|
2
3
|
|
|
3
4
|
from smartpush.base.request_base import RequestBase
|
|
4
5
|
from smartpush.base.url_enum import *
|
|
@@ -7,7 +8,7 @@ from smartpush.email.schema import *
|
|
|
7
8
|
|
|
8
9
|
def gen_universal_request_param(universalId, schema, **kwargs):
|
|
9
10
|
"""
|
|
10
|
-
|
|
11
|
+
生成单个universal的请求参数
|
|
11
12
|
:param schema:
|
|
12
13
|
:type universalId:
|
|
13
14
|
kwargs :
|
|
@@ -21,15 +22,88 @@ def gen_universal_request_param(universalId, schema, **kwargs):
|
|
|
21
22
|
"universalName": universalName,
|
|
22
23
|
"schema": json.dumps(result_schema),
|
|
23
24
|
"subUniversalId": kwargs.get('subUniversal_id', universalId),
|
|
24
|
-
"type": BlockType
|
|
25
|
+
"type": BlockType.getType(result_schema.get('type')),
|
|
25
26
|
"blockType": result_schema.get('type'),
|
|
26
27
|
"flowModal": kwargs.get('flowModal', '')
|
|
27
28
|
}
|
|
28
|
-
return json.dumps(requestParam)
|
|
29
|
+
return json.dumps(requestParam) if kwargs.get('jsonDumps') else requestParam
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def gen_update_universal_param(
|
|
33
|
+
block_schema_list: Optional[List[Dict[str, Any]]] = None,
|
|
34
|
+
section_schema: Optional[Dict[str, Any]] = None
|
|
35
|
+
) -> dict[str, list[dict[str, Any]] | int]:
|
|
36
|
+
"""
|
|
37
|
+
根据Block列表生成更新参数,支持同时更新关联的Section(Section始终放在参数列表首位)
|
|
38
|
+
|
|
39
|
+
:param block_schema_list: Block schema列表(每个元素为字典格式的schema)
|
|
40
|
+
:param section_schema: Section schema字典(可选,传入则同步更新Section)
|
|
41
|
+
:return: 统一格式的更新请求参数列表(字典类型,未序列化)
|
|
42
|
+
"""
|
|
43
|
+
# 初始化参数列表和Block收集列表(默认空列表,避免None判断)
|
|
44
|
+
update_params: List[Dict[str, Any]] = []
|
|
45
|
+
valid_block_schemas: List[Dict[str, Any]] = []
|
|
46
|
+
type = 0
|
|
47
|
+
# 处理Block参数(过滤无效schema,避免异常)
|
|
48
|
+
block_schema_list = block_schema_list or []
|
|
49
|
+
for block_schema in block_schema_list:
|
|
50
|
+
if not isinstance(block_schema, dict):
|
|
51
|
+
print("不符合格式:",block_schema)
|
|
52
|
+
continue # 跳过非字典格式的无效schema
|
|
53
|
+
# 提取必要字段(无默认值时用空字符串兜底,避免KeyError)
|
|
54
|
+
universal_id = block_schema.get('universalId', '')
|
|
55
|
+
universal_name = block_schema.get('universalName', '')
|
|
56
|
+
|
|
57
|
+
# 生成Block更新参数(指定jsonDumps=False返回字典,保持格式统一)
|
|
58
|
+
block_param = gen_universal_request_param(
|
|
59
|
+
universalId=universal_id,
|
|
60
|
+
schema=block_schema,
|
|
61
|
+
jsonDumps=False,
|
|
62
|
+
universalName=universal_name
|
|
63
|
+
)
|
|
64
|
+
update_params.append(block_param)
|
|
65
|
+
|
|
66
|
+
# 收集有效Block,用于更新Section的children
|
|
67
|
+
if section_schema:
|
|
68
|
+
valid_block_schemas.append(block_schema)
|
|
69
|
+
|
|
70
|
+
# 处理Section参数(如需同步更新,插入列表首位)
|
|
71
|
+
if isinstance(section_schema, dict):
|
|
72
|
+
# 提取Section必要字段
|
|
73
|
+
section_id = section_schema.get('universalId', '')
|
|
74
|
+
section_name = section_schema.get('universalName', '')
|
|
75
|
+
section_inner_id = section_schema.get('id', '')
|
|
76
|
+
|
|
77
|
+
# 若有有效Block,更新Section的children(保持原逻辑)
|
|
78
|
+
final_section_schema = section_schema
|
|
79
|
+
if valid_block_schemas:
|
|
80
|
+
final_section_schema = get_universal_schema(
|
|
81
|
+
schema=BlockSchema.genSection(valid_block_schemas),
|
|
82
|
+
_id=section_inner_id,
|
|
83
|
+
universalId=section_id,
|
|
84
|
+
universalName=section_name
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
# 生成Section更新参数
|
|
88
|
+
section_param = gen_universal_request_param(
|
|
89
|
+
universalId=section_id,
|
|
90
|
+
schema=final_section_schema,
|
|
91
|
+
jsonDumps=False,
|
|
92
|
+
universalName=section_name
|
|
93
|
+
)
|
|
94
|
+
type = 1
|
|
95
|
+
# 插入列表开头(确保Section在首位)
|
|
96
|
+
update_params.insert(0, section_param)
|
|
97
|
+
print(f"生成更新请求参数(共{len(update_params)}个):\n{json.dumps(update_params, indent=2, ensure_ascii=False)}")
|
|
98
|
+
return {'data':update_params,'type':type}
|
|
29
99
|
|
|
30
100
|
|
|
31
101
|
class UniversalContent(RequestBase):
|
|
32
|
-
#
|
|
102
|
+
# 写一个init初始化
|
|
103
|
+
def __init__(self, universal_id=None, *args, **kwargs):
|
|
104
|
+
"""初始化,传入"""
|
|
105
|
+
super().__init__(*args, **kwargs) # 调用父类初始化
|
|
106
|
+
self.universal_id = universal_id # 初始化event_id属性
|
|
33
107
|
|
|
34
108
|
# 创建universal
|
|
35
109
|
def create_universal(self, requestParam):
|
|
@@ -55,35 +129,53 @@ class UniversalContent(RequestBase):
|
|
|
55
129
|
return result
|
|
56
130
|
|
|
57
131
|
# 更新universal
|
|
58
|
-
def update_universal(self, universal_list
|
|
132
|
+
def update_universal(self, universal_list):
|
|
59
133
|
"""
|
|
60
|
-
|
|
61
|
-
:param _type:
|
|
134
|
+
更新素材,需要多个universal参数组合,type参数为section =1 ,block =0,有section和block时取section
|
|
62
135
|
:param universal_list:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
136
|
+
{
|
|
137
|
+
"data": [
|
|
138
|
+
{
|
|
139
|
+
"universalId": "9a1d1b16-7b48-4f9e-9dc9-f379efd746a5",
|
|
140
|
+
"universalName": "Auto-Section-2025-12-03 14:44:01",
|
|
141
|
+
"schema": "{\"id\": \"546bced03\", \"universalId\": \"9a1d1b16-7b48-4f9e-9dc9-f379efd746a5\", \"universalName\": \"Auto-Section-2025-12-03 14:44:01\", \"type\": \"Section\", \"props\": {\"backgroundColor\": \"#f1e6e6\", \"borderLeft\": \"1px none #ffffff\", \"borderRight\": \"1px none #ffffff\", \"borderTop\": \"1px none #ffffff\", \"borderBottom\": \"1px none #ffffff\", \"paddingTop\": \"0px\", \"paddingBottom\": \"0px\", \"paddingLeft\": \"0px\", \"paddingRight\": \"0px\", \"cols\": [12]}, \"children\": [{\"id\": \"8cab9aa48\", \"type\": \"Column\", \"props\": {}, \"children\": [{\"id\": \"f4baab96e\", \"universalId\": \"eed20601-e227-4481-897b-42e4a1a9d37a\", \"universalName\": \"Auto-Logo-2025-12-03 14:44:01\", \"type\": \"Logo\", \"props\": {\"width\": \"120\", \"height\": \"120\", \"imgRatio\": 1, \"src\": \"https://cdn.smartpushedm.com/frontend/smart-push/staging/1741054956275/1758595834300_74d62ae6.png?width=120&height=120\", \"href\": \"https://smartpush4.myshoplinestg.com\", \"align\": \"center\", \"containerBackgroundColor\": \"transparent\", \"paddingLeft\": \"20px\", \"paddingRight\": \"20px\", \"paddingTop\": \"20px\", \"paddingBottom\": \"20px\", \"paddingCondition\": true, \"segmentTypeConfig\": 1}, \"children\": []}]}]}",
|
|
142
|
+
"subUniversalId": "9a1d1b16-7b48-4f9e-9dc9-f379efd746a5",
|
|
143
|
+
"type": 1,
|
|
144
|
+
"blockType": "Section",
|
|
145
|
+
"flowModal": ""
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"universalId": "eed20601-e227-4481-897b-42e4a1a9d37a",
|
|
149
|
+
"universalName": "Auto-Logo-2025-12-03 14:44:01",
|
|
150
|
+
"schema": "{\"id\": \"f4baab96e\", \"universalId\": \"eed20601-e227-4481-897b-42e4a1a9d37a\", \"universalName\": \"Auto-Logo-2025-12-03 14:44:01\", \"type\": \"Logo\", \"props\": {\"width\": \"120\", \"height\": \"120\", \"imgRatio\": 1, \"src\": \"https://cdn.smartpushedm.com/frontend/smart-push/staging/1741054956275/1758595834300_74d62ae6.png?width=120&height=120\", \"href\": \"https://smartpush4.myshoplinestg.com\", \"align\": \"center\", \"containerBackgroundColor\": \"transparent\", \"paddingLeft\": \"20px\", \"paddingRight\": \"20px\", \"paddingTop\": \"20px\", \"paddingBottom\": \"20px\", \"paddingCondition\": true, \"segmentTypeConfig\": 1}, \"children\": []}",
|
|
151
|
+
"subUniversalId": "eed20601-e227-4481-897b-42e4a1a9d37a",
|
|
152
|
+
"type": 0,
|
|
153
|
+
"blockType": "Logo",
|
|
154
|
+
"flowModal": ""
|
|
155
|
+
}
|
|
156
|
+
],
|
|
157
|
+
"type": 1
|
|
158
|
+
}
|
|
71
159
|
:return:
|
|
72
160
|
"""
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
161
|
+
# block_type_list = []
|
|
162
|
+
# for data in universal_list:
|
|
163
|
+
# block_type_list.append(data['type'])
|
|
164
|
+
# if BlockType.Section.value in set(block_type_list):
|
|
165
|
+
# _type = BlockType.Section.value
|
|
166
|
+
# else:
|
|
167
|
+
# _type = BlockType.Block.value
|
|
168
|
+
requestParam = universal_list
|
|
77
169
|
result = self.request(method=URL.UniversalContent.updateUniversalContent.method,
|
|
78
170
|
path=URL.UniversalContent.updateUniversalContent.url,
|
|
79
171
|
data=requestParam)
|
|
80
|
-
# TODO 未完成
|
|
81
172
|
return result
|
|
82
173
|
|
|
83
174
|
# 删除universal
|
|
84
175
|
def delete_universal(self, universalId):
|
|
85
176
|
"""
|
|
86
177
|
删除素材
|
|
178
|
+
:param universalId:
|
|
87
179
|
:param universa_id:
|
|
88
180
|
:return:
|
|
89
181
|
"""
|
|
@@ -129,15 +221,17 @@ class UniversalContent(RequestBase):
|
|
|
129
221
|
print(f"------收藏的block在该section({section_universa_name})中,断言成功------")
|
|
130
222
|
except:
|
|
131
223
|
raise
|
|
224
|
+
|
|
132
225
|
@staticmethod
|
|
133
|
-
def assert_universal_schema_is_update(schema, property='containerBackgroundColor', value
|
|
226
|
+
def assert_universal_schema_is_update(schema, property='containerBackgroundColor', value='#123456'):
|
|
134
227
|
"""
|
|
135
228
|
用于查找素材schema的属性是否更新成功
|
|
229
|
+
:param schema:
|
|
136
230
|
:param property:
|
|
137
231
|
:param value:
|
|
138
232
|
:return:
|
|
139
233
|
"""
|
|
140
|
-
_schema =schema if isinstance(schema,dict) else json.loads(schema)
|
|
234
|
+
_schema = schema if isinstance(schema, dict) else json.loads(schema)
|
|
141
235
|
assert _schema['props'][property] == value
|
|
142
236
|
|
|
143
237
|
|
|
@@ -146,6 +240,11 @@ def get_time():
|
|
|
146
240
|
|
|
147
241
|
|
|
148
242
|
def gen_universal_name(schema):
|
|
243
|
+
"""
|
|
244
|
+
生成素材名称
|
|
245
|
+
:param schema:
|
|
246
|
+
:return:
|
|
247
|
+
"""
|
|
149
248
|
schema = schema if isinstance(schema, dict) else schema.value
|
|
150
249
|
if schema['type']:
|
|
151
250
|
return 'Auto-' + schema['type'] + '-' + get_time()
|
|
@@ -154,42 +253,54 @@ def gen_universal_name(schema):
|
|
|
154
253
|
|
|
155
254
|
|
|
156
255
|
def get_universal_schema(schema, _id, universalId, universalName):
|
|
256
|
+
"""
|
|
257
|
+
获取素材中的schema
|
|
258
|
+
:param schema:
|
|
259
|
+
:param _id:
|
|
260
|
+
:param universalId:
|
|
261
|
+
:param universalName:
|
|
262
|
+
:return:
|
|
263
|
+
"""
|
|
157
264
|
schema = schema if isinstance(schema, dict) else schema.value
|
|
158
265
|
schema.update(id=_id, universalId=universalId, universalName=universalName)
|
|
159
266
|
return schema
|
|
160
267
|
|
|
161
268
|
|
|
162
269
|
if __name__ == '__main__':
|
|
163
|
-
# _list = [get_universal_schema(BlockSchema.Logo, _id=generate_UUID(9), universalId=generate_UUID(),
|
|
164
|
-
# universalName=gen_universal_name(BlockSchema.Logo))]
|
|
165
|
-
# print(json.dumps(_list))
|
|
166
|
-
# print(gen_universal_request_param(generate_UUID(),
|
|
167
|
-
# get_universal_schema(genSection(_list), _id=generate_UUID(9),
|
|
168
|
-
# universalId=generate_UUID(),
|
|
169
|
-
# universalName=gen_universal_name(
|
|
170
|
-
# BlockSchema.Section))))
|
|
171
270
|
sectionUniversalId = generate_UUID()
|
|
172
271
|
sectionUniversalName = gen_universal_name(BlockSchema.Section)
|
|
173
|
-
print(sectionUniversalName)
|
|
174
|
-
block_list = [BlockSchema.Logo]
|
|
175
|
-
block_dict = {}
|
|
272
|
+
# print(sectionUniversalName)
|
|
273
|
+
block_list = [BlockSchema.Logo,BlockSchema.Discount]
|
|
274
|
+
# block_dict = {}
|
|
176
275
|
result_list = []
|
|
177
|
-
|
|
276
|
+
# update_request_param = []
|
|
277
|
+
# blockUniversalNameList = []
|
|
178
278
|
for block in block_list:
|
|
179
279
|
name = block.name
|
|
180
|
-
|
|
280
|
+
universal_id = generate_UUID()
|
|
281
|
+
block_schema = get_universal_schema(block, _id=generate_UUID(9), universalId=universal_id,
|
|
181
282
|
universalName=gen_universal_name(block))
|
|
283
|
+
block_request_param = gen_universal_request_param(universal_id, block_schema, jsonDumps=False)
|
|
182
284
|
result_list.append(block_schema)
|
|
183
|
-
|
|
285
|
+
# update_request_param.append(block_request_param)
|
|
184
286
|
section_schema = get_universal_schema(BlockSchema.genSection(result_list), _id=generate_UUID(9),
|
|
185
287
|
universalId=sectionUniversalId,
|
|
186
288
|
universalName=sectionUniversalName)
|
|
187
|
-
|
|
188
|
-
|
|
289
|
+
# section_universal_request_param = gen_universal_request_param(sectionUniversalId, section_schema, jsonDumps=False)
|
|
290
|
+
#
|
|
291
|
+
# update_request_param.insert(0, section_universal_request_param)
|
|
292
|
+
# print("update_request_param:", update_request_param)
|
|
293
|
+
# print(result_list)
|
|
294
|
+
# print(section_schema)
|
|
295
|
+
print(gen_update_universal_param(result_list,section_schema))
|
|
296
|
+
# print("universal_request_param:", section_universal_request_param)
|
|
189
297
|
# head = {
|
|
190
298
|
# "cookie": "osudb_appid=SMARTPUSH;osudb_oar=#01#SID0000141BOhqtUqYGMjRho2SIPBeE5o1HNWFHo9q+qttt/jMLf+gRshde7x0NZUgAST4PB4CfSuAa450BCuCZf6pwolP1vXs/cF+6e/snBhESLvofXaxDaIFN9swZq4Np2xBc4uw6R4V58uWjrwg+s8XTLVv;osudb_subappid=1;osudb_uid=4213785247;ecom_http_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NjU1OTg0NzQsImp0aSI6ImU0YzAyZjcxLWQ4NDktNDZlYS1iNzNmLTY1YjU0YTc3MTJjZCIsInVzZXJJbmZvIjp7ImlkIjowLCJ1c2VySWQiOiI0MjEzNzg1MjQ3IiwidXNlcm5hbWUiOiIiLCJlbWFpbCI6ImZlbGl4LnNoYW9Ac2hvcGxpbmVhcHAuY29tIiwidXNlclJvbGUiOiJvd25lciIsInBsYXRmb3JtVHlwZSI6Nywic3ViUGxhdGZvcm0iOjEsInBob25lIjoiIiwibGFuZ3VhZ2UiOiJ6aC1oYW5zLWNuIiwiYXV0aFR5cGUiOiIiLCJhdHRyaWJ1dGVzIjp7ImNvdW50cnlDb2RlIjoiQ04iLCJjdXJyZW5jeSI6IkpQWSIsImN1cnJlbmN5U3ltYm9sIjoiSlDCpSIsImRvbWFpbiI6InNtYXJ0cHVzaDQubXlzaG9wbGluZXN0Zy5jb20iLCJsYW5ndWFnZSI6ImVuIiwibWVyY2hhbnRFbWFpbCI6ImZlbGl4LnNoYW9Ac2hvcGxpbmUuY29tIiwibWVyY2hhbnROYW1lIjoiU21hcnRQdXNoNF9lYzJf6Ieq5Yqo5YyW5bqX6ZO6IiwicGhvbmUiOiIiLCJzY29wZUNoYW5nZWQiOmZhbHNlLCJzdGFmZkxhbmd1YWdlIjoiemgtaGFucy1jbiIsInN0YXR1cyI6MCwidGltZXpvbmUiOiJBc2lhL01hY2FvIn0sInN0b3JlSWQiOiIxNjQ0Mzk1OTIwNDQ0IiwiaGFuZGxlIjoic21hcnRwdXNoNCIsImVudiI6IkNOIiwic3RlIjoiIiwidmVyaWZ5IjoiIn0sImxvZ2luVGltZSI6MTc2MzAwNjQ3NDQzNywic2NvcGUiOlsiZW1haWwtbWFya2V0IiwiY29va2llIiwic2wtZWNvbS1lbWFpbC1tYXJrZXQtbmV3LXRlc3QiLCJlbWFpbC1tYXJrZXQtbmV3LWRldi1mcyIsImFwaS11Yy1lYzIiLCJhcGktc3UtZWMyIiwiYXBpLWVtLWVjMiIsImZsb3ctcGx1Z2luIiwiYXBpLXNwLW1hcmtldC1lYzIiXSwiY2xpZW50X2lkIjoiZW1haWwtbWFya2V0In0.erTiG4r364sutySNgx8X1rmrAjFsyfoe3UIUZ6J9e-o;",
|
|
191
299
|
# "Content-Type": "application/json", "accept-language": "zh-CN"}
|
|
192
300
|
# universal = UniversalContent(headers=head, host='https://test.smartpushedm.com/bff/api-sp-market-ec2')
|
|
301
|
+
# universal.update_universal(update_request_param)
|
|
302
|
+
#
|
|
303
|
+
# universal = UniversalContent(headers=head, host='https://test.smartpushedm.com/bff/api-sp-market-ec2')
|
|
193
304
|
# try:
|
|
194
305
|
# # universal.create_universal(requestParam=universal_request_param)
|
|
195
306
|
# # universal.assert_block_in_the_section(sectionUniversalName, result_list)
|
|
@@ -206,25 +317,3 @@ if __name__ == '__main__':
|
|
|
206
317
|
# # pass
|
|
207
318
|
# pass
|
|
208
319
|
#
|
|
209
|
-
# if __name__ == '__main__':
|
|
210
|
-
# sectionUniversalId = generate_UUID()
|
|
211
|
-
# sectionUniversalName = gen_universal_name(BlockSchema.Section)
|
|
212
|
-
# print(sectionUniversalName)
|
|
213
|
-
# block_list = [BlockSchema.Logo] # 添加block
|
|
214
|
-
#
|
|
215
|
-
# block_dict = {}
|
|
216
|
-
# result_list = []
|
|
217
|
-
# blockUniversalNameList = []
|
|
218
|
-
# for block in block_list:
|
|
219
|
-
# name = block.name
|
|
220
|
-
# block_schema = get_universal_schema(block, _id=generate_UUID(9), universalId=generate_UUID(),
|
|
221
|
-
# universalName=gen_universal_name(block))
|
|
222
|
-
# result_list.append(block_schema)
|
|
223
|
-
# print(result_list)
|
|
224
|
-
# # vars['result_list'] = result_list
|
|
225
|
-
# section_schema = get_universal_schema(BlockSchema.genSection(result_list), _id=generate_UUID(9),
|
|
226
|
-
# universalId=sectionUniversalId,
|
|
227
|
-
# universalName=sectionUniversalName)
|
|
228
|
-
# universal_request_param = gen_universal_request_param(sectionUniversalId, section_schema)
|
|
229
|
-
# vars['universal_request_param'] = universal_request_param
|
|
230
|
-
# print(universal_request_param)
|
smartpush/openapi/openapi.py
CHANGED
|
@@ -5,9 +5,9 @@ from smartpush.base.url_enum import URL
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class OpenApi(OpenApiRequestBase):
|
|
8
|
-
def __init__(self, event_id=None,
|
|
8
|
+
def __init__(self, host, headers, event_id=None, **kwargs):
|
|
9
9
|
"""初始化OpenApi,支持传入event_id"""
|
|
10
|
-
super().__init__(
|
|
10
|
+
super().__init__(event_id, host, headers, **kwargs)
|
|
11
11
|
self.event_id = event_id # 初始化event_id属性
|
|
12
12
|
self.attrTypeList = ('STRING', 'BIGINT', 'BOOLEAN', 'DATE', 'DECIMAL')
|
|
13
13
|
|
|
@@ -37,8 +37,8 @@ class OpenApi(OpenApiRequestBase):
|
|
|
37
37
|
if code:
|
|
38
38
|
requestParam["code"] = code
|
|
39
39
|
result = self.request(
|
|
40
|
-
URL.OpenApi.getEventMetaList.url,
|
|
41
|
-
URL.OpenApi.getEventMetaList.method,
|
|
40
|
+
path=URL.OpenApi.getEventMetaList.url,
|
|
41
|
+
method=URL.OpenApi.getEventMetaList.method,
|
|
42
42
|
data=requestParam
|
|
43
43
|
)
|
|
44
44
|
return result
|
|
@@ -53,8 +53,8 @@ class OpenApi(OpenApiRequestBase):
|
|
|
53
53
|
raise ValueError("event_id未初始化,请在实例化时传入")
|
|
54
54
|
requestParam = {"id": self.event_id, "eventCode": eventCode}
|
|
55
55
|
result = self.request(
|
|
56
|
-
URL.OpenApi.getEventMetaById.url,
|
|
57
|
-
URL.OpenApi.getEventMetaById.method,
|
|
56
|
+
path=URL.OpenApi.getEventMetaById.url,
|
|
57
|
+
method=URL.OpenApi.getEventMetaById.method,
|
|
58
58
|
data=requestParam
|
|
59
59
|
)
|
|
60
60
|
return result
|
|
@@ -69,8 +69,8 @@ class OpenApi(OpenApiRequestBase):
|
|
|
69
69
|
raise ValueError("event_id未初始化,请在实例化时传入")
|
|
70
70
|
requestParam = {"id": self.event_id, "eventCode": eventCode}
|
|
71
71
|
result = self.request(
|
|
72
|
-
URL.OpenApi.delEventMetaById.url,
|
|
73
|
-
URL.OpenApi.delEventMetaById.method,
|
|
72
|
+
path=URL.OpenApi.delEventMetaById.url,
|
|
73
|
+
method=URL.OpenApi.delEventMetaById.method,
|
|
74
74
|
data=requestParam
|
|
75
75
|
)
|
|
76
76
|
return result
|
|
@@ -97,8 +97,8 @@ class OpenApi(OpenApiRequestBase):
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
result = self.request(
|
|
100
|
-
URL.OpenApi.editEventMeta.url,
|
|
101
|
-
URL.OpenApi.editEventMeta.method,
|
|
100
|
+
path=URL.OpenApi.editEventMeta.url,
|
|
101
|
+
method=URL.OpenApi.editEventMeta.method,
|
|
102
102
|
data=requestParam
|
|
103
103
|
)
|
|
104
104
|
return result
|
|
@@ -106,15 +106,17 @@ class OpenApi(OpenApiRequestBase):
|
|
|
106
106
|
def getEventChannel(self):
|
|
107
107
|
# requestParam = {"id": self.event_id, "eventCode": eventCode}
|
|
108
108
|
result = self.request(
|
|
109
|
-
URL.OpenApi.getEventChannel.url,
|
|
110
|
-
URL.OpenApi.getEventChannel.method,
|
|
109
|
+
path=URL.OpenApi.getEventChannel.url,
|
|
110
|
+
method=URL.OpenApi.getEventChannel.method,
|
|
111
111
|
)
|
|
112
112
|
return result
|
|
113
113
|
|
|
114
|
-
def getEventAttr(self):
|
|
114
|
+
def getEventAttr(self, pageSize=200, pageNumber=1):
|
|
115
|
+
requestParam = {"pageSize": pageSize, "pageNum": pageNumber}
|
|
115
116
|
result = self.request(
|
|
116
|
-
URL.OpenApi.getEventAttr.url,
|
|
117
|
-
URL.OpenApi.getEventAttr.method,
|
|
117
|
+
path=URL.OpenApi.getEventAttr.url,
|
|
118
|
+
method=URL.OpenApi.getEventAttr.method,
|
|
119
|
+
data=requestParam
|
|
118
120
|
)
|
|
119
121
|
return result
|
|
120
122
|
|
|
@@ -157,3 +159,27 @@ class AssertOpenApi(OpenApi):
|
|
|
157
159
|
if is_delete and event_id:
|
|
158
160
|
self.event_id = event_id
|
|
159
161
|
self.deleteEventMetaById(code)
|
|
162
|
+
|
|
163
|
+
def assert_event_attr_create_success(self, attr_code):
|
|
164
|
+
"""
|
|
165
|
+
断言事件字段添加成功,并返回attr的id
|
|
166
|
+
:param attr_code:
|
|
167
|
+
:return:
|
|
168
|
+
:rtype: tuple[bool, Any]
|
|
169
|
+
"""
|
|
170
|
+
datas = self.getEventAttr().get('resultData', {}).get('datas', []).get('eventAttrs', [])
|
|
171
|
+
for data in datas:
|
|
172
|
+
if data.get('attrCode') == attr_code:
|
|
173
|
+
return True,data.get("attrMetaTabi")
|
|
174
|
+
assert False, f'{attr_code} 新增失败'
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
if __name__ == '__main__':
|
|
178
|
+
head = {'Content-Type': 'application/json',
|
|
179
|
+
'cookie': 'osudb_appid=SMARTPUSH;osudb_oar=#01#SID0000142BLW1n/EjSTsnwj+GuvYaB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X6ZO6IiwicGhvbmUiOiIiLCJzY29wZUNoYW5nZWQiOmZhbHNlLCJzdGFmZkxhbmd1YWdlIjoiemgtaGFucy1jbiIsInN0YXR1cyI6MCwidGltZXpvbmUiOiJBc2lhL01hY2FvIn0sInN0b3JlSWQiOiIxNjQ0Mzk1OTIwNDQ0IiwiaGFuZGxlIjoic21hcnRwdXNoNCIsImVudiI6IkNOIiwic3RlIjoiIiwidmVyaWZ5IjoiIiwiaXNGaXJzdEJpbmQiOmZhbHNlfSwibG9naW5UaW1lIjoxNzY0NTYxNjU2NzA1LCJzY29wZSI6WyJlbWFpbC1tYXJrZXQiLCJjb29raWUiLCJzbC1lY29tLWVtYWlsLW1hcmtldC1uZXctdGVzdCIsImVtYWlsLW1hcmtldC1uZXctZGV2LWZzIiwiYXBpLXVjLWVjMiIsImFwaS1zdS1lYzIiLCJhcGktZW0tZWMyIiwiZmxvdy1wbHVnaW4iLCJhcGktc3AtbWFya2V0LWVjMiJdLCJjbGllbnRfaWQiOiJlbWFpbC1tYXJrZXQifQ.bgfuaOJqX2BXDmOorrWrE6iiQswpqYO0bW78pwbP4Wk'}
|
|
181
|
+
openapi = OpenApi(headers=head, host='https://test.smartpushedm.com/bff/api-sp-market-ec2')
|
|
182
|
+
# openapi.getEventMetaList(channel= 'Smartpush_API')
|
|
183
|
+
assertopenapi = AssertOpenApi(headers=head, host='https://test.smartpushedm.com/bff/api-sp-market-ec2')
|
|
184
|
+
print(assertopenapi.assert_event_attr_create_success('cus_autotest_int'))
|
|
185
|
+
# assert False
|
|
@@ -10,9 +10,9 @@ smartpush/base/url_enum.py,sha256=OuEd3EqlLvKiYesU2gISPLh9wH2nNYZ-5nzBu_6Zxnw,27
|
|
|
10
10
|
smartpush/crowd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
11
|
smartpush/crowd/crowd.py,sha256=KNwvX-BnBnMVVuHM79a-VeBMp_guB-Kqw3tFaAPiAp8,9768
|
|
12
12
|
smartpush/email/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
-
smartpush/email/activity.py,sha256=
|
|
14
|
-
smartpush/email/schema.py,sha256=
|
|
15
|
-
smartpush/email/universal_content.py,sha256=
|
|
13
|
+
smartpush/email/activity.py,sha256=rQ62GIfg0Yh0fFkwiaRIVATBn5vY1wZzbLEJLwHmx1E,10016
|
|
14
|
+
smartpush/email/schema.py,sha256=mysik-N6cry4HuSxzMMhQFsnnu5_UJ_oqVPTGY1RUkQ,31471
|
|
15
|
+
smartpush/email/universal_content.py,sha256=bST0RCVN4YUglrsCv0OsIox7vceEvJRVkqcMaEgj9No,17226
|
|
16
16
|
smartpush/export/__init__.py,sha256=D9GbWcmwnetEndFDty5XbVienFK1WjqV2yYcQp3CM84,99
|
|
17
17
|
smartpush/export/basic/ExcelExportChecker.py,sha256=YqWmDGSFadQdK2vNJ070Qvad9ZtqEwiQyPkOemlACfs,21508
|
|
18
18
|
smartpush/export/basic/GetOssUrl.py,sha256=zxNZj6x7Ph9N3P5k82pLpBFjZxKrDfbgqS2fTYyhvso,8467
|
|
@@ -28,7 +28,7 @@ smartpush/form/form_assert.py,sha256=wPIRfQHhr7lN1fFd-mp0z_qKMtF4jfrNxRWvp2xfqCg
|
|
|
28
28
|
smartpush/form/form_before.py,sha256=CCvAC_2yWPlnQGtjEA8LPLy9853Nq3nNjcL2GewFWIs,175
|
|
29
29
|
smartpush/form/form_client_operation.py,sha256=gg-5uHXCyMa_ypBSYPYFVxXdwZdYBJsNtUCqayknMBw,303
|
|
30
30
|
smartpush/openapi/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
31
|
-
smartpush/openapi/openapi.py,sha256=
|
|
31
|
+
smartpush/openapi/openapi.py,sha256=8qCTvflRQBI-z1jc2hN8ISah_x9ceTf6HbfkTxSEFsc,9548
|
|
32
32
|
smartpush/utils/DataTypeUtils.py,sha256=BC7ioztO3vAfKd1EOoNvXdVuXYY8qjNskV1DP7LhW-M,1082
|
|
33
33
|
smartpush/utils/EmailUtlis.py,sha256=DAHd73bJ8hiJCLEXtD0xcwxPD7SOPSmBB7Jvlf6gN6s,11201
|
|
34
34
|
smartpush/utils/ListDictUtils.py,sha256=Xc8kfSOZjX_k026Au4cfvtgFh5WoHxw4yRJWASyA_Cc,5041
|
|
@@ -36,7 +36,7 @@ smartpush/utils/StringUtils.py,sha256=n8mo9k0JQN63MReImgv-66JxmmymOGknR8pH2fkQrA
|
|
|
36
36
|
smartpush/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
37
37
|
smartpush/utils/date_utils.py,sha256=Xgx2DbmWYri71xXBiaKYTZDeh2a8MFhYns_xB0U2JOA,13159
|
|
38
38
|
smartpush/utils/form_utils.py,sha256=ld-g_Dm_ZlnagQt7imYfUc87bcBRVlTctywuLtzmjXQ,849
|
|
39
|
-
smartpush-2.0.
|
|
40
|
-
smartpush-2.0.
|
|
41
|
-
smartpush-2.0.
|
|
42
|
-
smartpush-2.0.
|
|
39
|
+
smartpush-2.0.8.dist-info/METADATA,sha256=D3-WYT04C9a5G0DZbJES26R09PJg78oWBzI4clh5OPY,131
|
|
40
|
+
smartpush-2.0.8.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
41
|
+
smartpush-2.0.8.dist-info/top_level.txt,sha256=5_CXqu08EfbPaKLjuSAOAqCmGU6shiatwDU_ViBGCmg,10
|
|
42
|
+
smartpush-2.0.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|