@redonvn/zalo-ads-sdk 0.2.2 → 0.2.7
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.
- package/dist/index.d.mts +1381 -101
- package/dist/index.d.ts +1381 -101
- package/dist/index.js +3349 -719
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3309 -718
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ var ZaloSdkError = class extends Error {
|
|
|
3
3
|
status;
|
|
4
4
|
operationId;
|
|
5
5
|
responseBody;
|
|
6
|
-
constructor(message, status, operationId, responseBody) {
|
|
6
|
+
constructor(message, status = 500, operationId = "unknown", responseBody = null) {
|
|
7
7
|
super(message);
|
|
8
8
|
this.name = "ZaloSdkError";
|
|
9
9
|
this.status = status;
|
|
@@ -1038,43 +1038,7 @@ async function resolveCookies(auth, context) {
|
|
|
1038
1038
|
return { ...auth?.cookies ?? {}, ...await auth?.getCookies?.(context) ?? {} };
|
|
1039
1039
|
}
|
|
1040
1040
|
|
|
1041
|
-
// src/services/
|
|
1042
|
-
var OP_ZaloAdsListFlowsByOfficialAccount = {
|
|
1043
|
-
operationId: "ZaloAds_listFlowsByOfficialAccount",
|
|
1044
|
-
method: "GET",
|
|
1045
|
-
endpoint: "/api/flow/getByOaId",
|
|
1046
|
-
baseUrl: "https://ads.zalo.me",
|
|
1047
|
-
binaryFields: [],
|
|
1048
|
-
pathFields: [],
|
|
1049
|
-
queryFields: ["oaId", "limit", "offset", "flowId"],
|
|
1050
|
-
headerFields: [],
|
|
1051
|
-
cookieFields: [],
|
|
1052
|
-
bodyFields: []
|
|
1053
|
-
};
|
|
1054
|
-
var OP_ZaloAdsCreateFlow = {
|
|
1055
|
-
operationId: "ZaloAds_createFlow",
|
|
1056
|
-
method: "POST",
|
|
1057
|
-
endpoint: "/api/flow/create",
|
|
1058
|
-
baseUrl: "https://ads.zalo.me",
|
|
1059
|
-
binaryFields: [],
|
|
1060
|
-
pathFields: [],
|
|
1061
|
-
queryFields: [],
|
|
1062
|
-
headerFields: [],
|
|
1063
|
-
cookieFields: [],
|
|
1064
|
-
bodyFields: ["oaId", "id", "name", "messages"]
|
|
1065
|
-
};
|
|
1066
|
-
var OP_ZaloAdsUpdateFlow = {
|
|
1067
|
-
operationId: "ZaloAds_updateFlow",
|
|
1068
|
-
method: "POST",
|
|
1069
|
-
endpoint: "/api/flow/update",
|
|
1070
|
-
baseUrl: "https://ads.zalo.me",
|
|
1071
|
-
binaryFields: [],
|
|
1072
|
-
pathFields: [],
|
|
1073
|
-
queryFields: [],
|
|
1074
|
-
headerFields: [],
|
|
1075
|
-
cookieFields: [],
|
|
1076
|
-
bodyFields: ["oaId", "id", "name", "messages"]
|
|
1077
|
-
};
|
|
1041
|
+
// src/services/campaigns.service.ts
|
|
1078
1042
|
var OP_ZaloAdsUpdateVideoAd = {
|
|
1079
1043
|
operationId: "ZaloAds_updateVideoAd",
|
|
1080
1044
|
method: "POST",
|
|
@@ -1102,22 +1066,6 @@ var OP_ZaloAdsChangeCampaignStatus = {
|
|
|
1102
1066
|
"campaignId"
|
|
1103
1067
|
]
|
|
1104
1068
|
};
|
|
1105
|
-
var OP_ZaloAdsCreateCustomAudience = {
|
|
1106
|
-
"operationId": "ZaloAds_createCustomAudience",
|
|
1107
|
-
"method": "POST",
|
|
1108
|
-
"endpoint": "/api/ad/audience",
|
|
1109
|
-
"baseUrl": "https://ads.zalo.me",
|
|
1110
|
-
"binaryFields": [],
|
|
1111
|
-
"pathFields": [],
|
|
1112
|
-
"queryFields": [],
|
|
1113
|
-
"headerFields": [],
|
|
1114
|
-
"cookieFields": [],
|
|
1115
|
-
"bodyFields": [
|
|
1116
|
-
"name",
|
|
1117
|
-
"caType",
|
|
1118
|
-
"targeting"
|
|
1119
|
-
]
|
|
1120
|
-
};
|
|
1121
1069
|
var OP_ZaloAdsCreateEcommerceCampaign = {
|
|
1122
1070
|
"operationId": "ZaloAds_createEcommerceCampaign",
|
|
1123
1071
|
"method": "POST",
|
|
@@ -1202,54 +1150,6 @@ var OP_ZaloAdsCreatePostCampaign = {
|
|
|
1202
1150
|
"data"
|
|
1203
1151
|
]
|
|
1204
1152
|
};
|
|
1205
|
-
var OP_ZaloAdsCreateConversion = {
|
|
1206
|
-
"operationId": "ZaloAds_createConversion",
|
|
1207
|
-
"method": "POST",
|
|
1208
|
-
"endpoint": "/api/conversion/add",
|
|
1209
|
-
"baseUrl": "https://ads.zalo.me",
|
|
1210
|
-
"binaryFields": [],
|
|
1211
|
-
"pathFields": [],
|
|
1212
|
-
"queryFields": [],
|
|
1213
|
-
"headerFields": [],
|
|
1214
|
-
"cookieFields": [],
|
|
1215
|
-
"bodyFields": [
|
|
1216
|
-
"name",
|
|
1217
|
-
"landingPage",
|
|
1218
|
-
"urlType",
|
|
1219
|
-
"labelId",
|
|
1220
|
-
"buttonIds",
|
|
1221
|
-
"elements",
|
|
1222
|
-
"keywords"
|
|
1223
|
-
]
|
|
1224
|
-
};
|
|
1225
|
-
var OP_ZaloAdsDeleteConversion = {
|
|
1226
|
-
"operationId": "ZaloAds_deleteConversion",
|
|
1227
|
-
"method": "DELETE",
|
|
1228
|
-
"endpoint": "/api/conversion/delete/{conversionId}",
|
|
1229
|
-
"baseUrl": "https://ads.zalo.me",
|
|
1230
|
-
"binaryFields": [],
|
|
1231
|
-
"pathFields": [
|
|
1232
|
-
"conversionId"
|
|
1233
|
-
],
|
|
1234
|
-
"queryFields": [],
|
|
1235
|
-
"headerFields": [],
|
|
1236
|
-
"cookieFields": [],
|
|
1237
|
-
"bodyFields": []
|
|
1238
|
-
};
|
|
1239
|
-
var OP_ZaloAdsDeleteCustomAudience = {
|
|
1240
|
-
"operationId": "ZaloAds_deleteCustomAudience",
|
|
1241
|
-
"method": "DELETE",
|
|
1242
|
-
"endpoint": "/api/ad/audience/{customAudienceId}",
|
|
1243
|
-
"baseUrl": "https://ads.zalo.me",
|
|
1244
|
-
"binaryFields": [],
|
|
1245
|
-
"pathFields": [
|
|
1246
|
-
"customAudienceId"
|
|
1247
|
-
],
|
|
1248
|
-
"queryFields": [],
|
|
1249
|
-
"headerFields": [],
|
|
1250
|
-
"cookieFields": [],
|
|
1251
|
-
"bodyFields": []
|
|
1252
|
-
};
|
|
1253
1153
|
var OP_ZaloAdsGetAdById = {
|
|
1254
1154
|
"operationId": "ZaloAds_getAdById",
|
|
1255
1155
|
"method": "GET",
|
|
@@ -1280,10 +1180,10 @@ var OP_ZaloAdsGetAdChangeLog = {
|
|
|
1280
1180
|
"cookieFields": [],
|
|
1281
1181
|
"bodyFields": []
|
|
1282
1182
|
};
|
|
1283
|
-
var
|
|
1284
|
-
"operationId": "
|
|
1183
|
+
var OP_ZaloAdsGetApiPlaceGetalldistricts = {
|
|
1184
|
+
"operationId": "ZaloAds_getApiPlaceGetalldistricts",
|
|
1285
1185
|
"method": "GET",
|
|
1286
|
-
"endpoint": "/api/
|
|
1186
|
+
"endpoint": "/api/place/getAllDistricts",
|
|
1287
1187
|
"baseUrl": "https://ads.zalo.me",
|
|
1288
1188
|
"binaryFields": [],
|
|
1289
1189
|
"pathFields": [],
|
|
@@ -1292,48 +1192,54 @@ var OP_ZaloAdsGetApiAdGetlistadadvancetargeting = {
|
|
|
1292
1192
|
"cookieFields": [],
|
|
1293
1193
|
"bodyFields": []
|
|
1294
1194
|
};
|
|
1295
|
-
var
|
|
1296
|
-
"operationId": "
|
|
1195
|
+
var OP_ZaloAdsGetApiSpellCheckV2 = {
|
|
1196
|
+
"operationId": "ZaloAds_getApiSpellCheckV2",
|
|
1297
1197
|
"method": "GET",
|
|
1298
|
-
"endpoint": "/api/
|
|
1198
|
+
"endpoint": "/api/spell-check/v2",
|
|
1299
1199
|
"baseUrl": "https://ads.zalo.me",
|
|
1300
1200
|
"binaryFields": [],
|
|
1301
1201
|
"pathFields": [],
|
|
1302
1202
|
"queryFields": [
|
|
1303
|
-
"
|
|
1203
|
+
"text"
|
|
1304
1204
|
],
|
|
1305
1205
|
"headerFields": [],
|
|
1306
1206
|
"cookieFields": [],
|
|
1307
1207
|
"bodyFields": []
|
|
1308
1208
|
};
|
|
1309
|
-
var
|
|
1310
|
-
"operationId": "
|
|
1209
|
+
var OP_ZaloAdsGetZaapiCheckcamphasmanyads = {
|
|
1210
|
+
"operationId": "ZaloAds_getZaapiCheckcamphasmanyads",
|
|
1311
1211
|
"method": "GET",
|
|
1312
|
-
"endpoint": "/
|
|
1212
|
+
"endpoint": "/zaapi/checkCampHasManyAds",
|
|
1313
1213
|
"baseUrl": "https://ads.zalo.me",
|
|
1314
1214
|
"binaryFields": [],
|
|
1315
1215
|
"pathFields": [],
|
|
1316
|
-
"queryFields": [
|
|
1216
|
+
"queryFields": [
|
|
1217
|
+
"campaignId",
|
|
1218
|
+
"campId"
|
|
1219
|
+
],
|
|
1317
1220
|
"headerFields": [],
|
|
1318
1221
|
"cookieFields": [],
|
|
1319
1222
|
"bodyFields": []
|
|
1320
1223
|
};
|
|
1321
|
-
var
|
|
1322
|
-
"operationId": "
|
|
1224
|
+
var OP_ZaloAdsGetZaapiGetadsfromcampaignid = {
|
|
1225
|
+
"operationId": "ZaloAds_getZaapiGetadsfromcampaignid",
|
|
1323
1226
|
"method": "GET",
|
|
1324
|
-
"endpoint": "/
|
|
1227
|
+
"endpoint": "/zaapi/getAdsFromCampaignId",
|
|
1325
1228
|
"baseUrl": "https://ads.zalo.me",
|
|
1326
1229
|
"binaryFields": [],
|
|
1327
1230
|
"pathFields": [],
|
|
1328
|
-
"queryFields": [
|
|
1231
|
+
"queryFields": [
|
|
1232
|
+
"campaignId",
|
|
1233
|
+
"campId"
|
|
1234
|
+
],
|
|
1329
1235
|
"headerFields": [],
|
|
1330
1236
|
"cookieFields": [],
|
|
1331
1237
|
"bodyFields": []
|
|
1332
1238
|
};
|
|
1333
|
-
var
|
|
1334
|
-
"operationId": "
|
|
1239
|
+
var OP_ZaloAdsGetZaapiGetallpages = {
|
|
1240
|
+
"operationId": "ZaloAds_getZaapiGetallpages",
|
|
1335
1241
|
"method": "GET",
|
|
1336
|
-
"endpoint": "/
|
|
1242
|
+
"endpoint": "/zaapi/getAllPages",
|
|
1337
1243
|
"baseUrl": "https://ads.zalo.me",
|
|
1338
1244
|
"binaryFields": [],
|
|
1339
1245
|
"pathFields": [],
|
|
@@ -1342,24 +1248,24 @@ var OP_ZaloAdsGetApiConversionStandardEvents = {
|
|
|
1342
1248
|
"cookieFields": [],
|
|
1343
1249
|
"bodyFields": []
|
|
1344
1250
|
};
|
|
1345
|
-
var
|
|
1346
|
-
"operationId": "
|
|
1251
|
+
var OP_ZaloAdsGetZaapiGetownedarticles = {
|
|
1252
|
+
"operationId": "ZaloAds_getZaapiGetownedarticles",
|
|
1347
1253
|
"method": "GET",
|
|
1348
|
-
"endpoint": "/
|
|
1254
|
+
"endpoint": "/zaapi/getOwnedArticles",
|
|
1349
1255
|
"baseUrl": "https://ads.zalo.me",
|
|
1350
1256
|
"binaryFields": [],
|
|
1351
1257
|
"pathFields": [],
|
|
1352
1258
|
"queryFields": [
|
|
1353
|
-
"
|
|
1259
|
+
"pageId"
|
|
1354
1260
|
],
|
|
1355
1261
|
"headerFields": [],
|
|
1356
1262
|
"cookieFields": [],
|
|
1357
1263
|
"bodyFields": []
|
|
1358
1264
|
};
|
|
1359
|
-
var
|
|
1360
|
-
"operationId": "
|
|
1265
|
+
var OP_ZaloAdsGetZaapiGetownedpages = {
|
|
1266
|
+
"operationId": "ZaloAds_getZaapiGetownedpages",
|
|
1361
1267
|
"method": "GET",
|
|
1362
|
-
"endpoint": "/
|
|
1268
|
+
"endpoint": "/zaapi/getOwnedPages",
|
|
1363
1269
|
"baseUrl": "https://ads.zalo.me",
|
|
1364
1270
|
"binaryFields": [],
|
|
1365
1271
|
"pathFields": [],
|
|
@@ -1368,324 +1274,1026 @@ var OP_ZaloAdsGetApiFilegroups = {
|
|
|
1368
1274
|
"cookieFields": [],
|
|
1369
1275
|
"bodyFields": []
|
|
1370
1276
|
};
|
|
1371
|
-
var
|
|
1372
|
-
"operationId": "
|
|
1277
|
+
var OP_ZaloAdsListFormsByOfficialAccount = {
|
|
1278
|
+
"operationId": "ZaloAds_listFormsByOfficialAccount",
|
|
1373
1279
|
"method": "GET",
|
|
1374
|
-
"endpoint": "/api/
|
|
1280
|
+
"endpoint": "/api/form/getByOaId",
|
|
1375
1281
|
"baseUrl": "https://ads.zalo.me",
|
|
1376
1282
|
"binaryFields": [],
|
|
1377
1283
|
"pathFields": [],
|
|
1378
|
-
"queryFields": [
|
|
1284
|
+
"queryFields": [
|
|
1285
|
+
"oaId",
|
|
1286
|
+
"isAll"
|
|
1287
|
+
],
|
|
1379
1288
|
"headerFields": [],
|
|
1380
1289
|
"cookieFields": [],
|
|
1381
1290
|
"bodyFields": []
|
|
1382
1291
|
};
|
|
1383
|
-
var
|
|
1384
|
-
"operationId": "
|
|
1292
|
+
var OP_ZaloAdsListMiniPagesByTemplate = {
|
|
1293
|
+
"operationId": "ZaloAds_listMiniPagesByTemplate",
|
|
1385
1294
|
"method": "GET",
|
|
1386
|
-
"endpoint": "/api/
|
|
1295
|
+
"endpoint": "/api/mini-pages",
|
|
1387
1296
|
"baseUrl": "https://ads.zalo.me",
|
|
1388
1297
|
"binaryFields": [],
|
|
1389
1298
|
"pathFields": [],
|
|
1390
1299
|
"queryFields": [
|
|
1391
|
-
"
|
|
1392
|
-
"startDate"
|
|
1300
|
+
"templateIds"
|
|
1393
1301
|
],
|
|
1394
1302
|
"headerFields": [],
|
|
1395
1303
|
"cookieFields": [],
|
|
1396
1304
|
"bodyFields": []
|
|
1397
1305
|
};
|
|
1398
|
-
var
|
|
1399
|
-
"operationId": "
|
|
1400
|
-
"method": "
|
|
1401
|
-
"endpoint": "/
|
|
1306
|
+
var OP_ZaloAdsPostZaapiDeletead = {
|
|
1307
|
+
"operationId": "ZaloAds_postZaapiDeletead",
|
|
1308
|
+
"method": "POST",
|
|
1309
|
+
"endpoint": "/zaapi/deleteAd",
|
|
1402
1310
|
"baseUrl": "https://ads.zalo.me",
|
|
1403
1311
|
"binaryFields": [],
|
|
1404
1312
|
"pathFields": [],
|
|
1405
|
-
"queryFields": [
|
|
1313
|
+
"queryFields": [
|
|
1314
|
+
"adId"
|
|
1315
|
+
],
|
|
1406
1316
|
"headerFields": [],
|
|
1407
1317
|
"cookieFields": [],
|
|
1408
|
-
"bodyFields": [
|
|
1318
|
+
"bodyFields": [
|
|
1319
|
+
"adId"
|
|
1320
|
+
]
|
|
1409
1321
|
};
|
|
1410
|
-
var
|
|
1411
|
-
"operationId": "
|
|
1412
|
-
"method": "
|
|
1413
|
-
"endpoint": "/api/
|
|
1322
|
+
var OP_ZaloAdsRenameCampaign = {
|
|
1323
|
+
"operationId": "ZaloAds_renameCampaign",
|
|
1324
|
+
"method": "POST",
|
|
1325
|
+
"endpoint": "/api/campaign/change-name",
|
|
1414
1326
|
"baseUrl": "https://ads.zalo.me",
|
|
1415
1327
|
"binaryFields": [],
|
|
1416
1328
|
"pathFields": [],
|
|
1417
1329
|
"queryFields": [],
|
|
1418
1330
|
"headerFields": [],
|
|
1419
1331
|
"cookieFields": [],
|
|
1420
|
-
"bodyFields": [
|
|
1332
|
+
"bodyFields": [
|
|
1333
|
+
"campid",
|
|
1334
|
+
"newname"
|
|
1335
|
+
]
|
|
1421
1336
|
};
|
|
1422
|
-
var
|
|
1423
|
-
"operationId": "
|
|
1424
|
-
"method": "
|
|
1425
|
-
"endpoint": "/
|
|
1337
|
+
var OP_ZaloAdsUpdateEcommerceAd = {
|
|
1338
|
+
"operationId": "ZaloAds_updateEcommerceAd",
|
|
1339
|
+
"method": "POST",
|
|
1340
|
+
"endpoint": "/zaapi/UpdateAd",
|
|
1426
1341
|
"baseUrl": "https://ads.zalo.me",
|
|
1427
1342
|
"binaryFields": [],
|
|
1428
1343
|
"pathFields": [],
|
|
1429
|
-
"queryFields": [
|
|
1430
|
-
"to",
|
|
1431
|
-
"from",
|
|
1432
|
-
"memberId"
|
|
1433
|
-
],
|
|
1344
|
+
"queryFields": [],
|
|
1434
1345
|
"headerFields": [],
|
|
1435
1346
|
"cookieFields": [],
|
|
1436
|
-
"bodyFields": [
|
|
1347
|
+
"bodyFields": [
|
|
1348
|
+
"est",
|
|
1349
|
+
"stt",
|
|
1350
|
+
"data",
|
|
1351
|
+
"isBoostAd"
|
|
1352
|
+
]
|
|
1437
1353
|
};
|
|
1438
|
-
var
|
|
1439
|
-
"operationId": "
|
|
1440
|
-
"method": "
|
|
1441
|
-
"endpoint": "/
|
|
1354
|
+
var OP_ZaloAdsUpdateFormAd = {
|
|
1355
|
+
"operationId": "ZaloAds_updateFormAd",
|
|
1356
|
+
"method": "POST",
|
|
1357
|
+
"endpoint": "/zaapi/UpdateAd",
|
|
1442
1358
|
"baseUrl": "https://ads.zalo.me",
|
|
1443
1359
|
"binaryFields": [],
|
|
1444
1360
|
"pathFields": [],
|
|
1445
1361
|
"queryFields": [],
|
|
1446
1362
|
"headerFields": [],
|
|
1447
1363
|
"cookieFields": [],
|
|
1448
|
-
"bodyFields": [
|
|
1364
|
+
"bodyFields": [
|
|
1365
|
+
"est",
|
|
1366
|
+
"stt",
|
|
1367
|
+
"data",
|
|
1368
|
+
"isBoostAd"
|
|
1369
|
+
]
|
|
1449
1370
|
};
|
|
1450
|
-
var
|
|
1451
|
-
"operationId": "
|
|
1452
|
-
"method": "
|
|
1453
|
-
"endpoint": "/
|
|
1371
|
+
var OP_ZaloAdsUpdateMessageAd = {
|
|
1372
|
+
"operationId": "ZaloAds_updateMessageAd",
|
|
1373
|
+
"method": "POST",
|
|
1374
|
+
"endpoint": "/zaapi/UpdateAd",
|
|
1454
1375
|
"baseUrl": "https://ads.zalo.me",
|
|
1455
1376
|
"binaryFields": [],
|
|
1456
1377
|
"pathFields": [],
|
|
1457
|
-
"queryFields": [
|
|
1458
|
-
"text"
|
|
1459
|
-
],
|
|
1378
|
+
"queryFields": [],
|
|
1460
1379
|
"headerFields": [],
|
|
1461
1380
|
"cookieFields": [],
|
|
1462
|
-
"bodyFields": [
|
|
1381
|
+
"bodyFields": [
|
|
1382
|
+
"est",
|
|
1383
|
+
"stt",
|
|
1384
|
+
"data",
|
|
1385
|
+
"isBoostAd"
|
|
1386
|
+
]
|
|
1463
1387
|
};
|
|
1464
|
-
var
|
|
1465
|
-
"operationId": "
|
|
1466
|
-
"method": "
|
|
1467
|
-
"endpoint": "/
|
|
1468
|
-
"baseUrl": "https://ads.zalo.me",
|
|
1469
|
-
"binaryFields": [],
|
|
1470
|
-
"pathFields": [],
|
|
1471
|
-
"queryFields": [],
|
|
1472
|
-
"headerFields": [],
|
|
1473
|
-
"cookieFields": [],
|
|
1474
|
-
"bodyFields": []
|
|
1475
|
-
};
|
|
1476
|
-
var OP_ZaloAdsGetReportapiV2Ads = {
|
|
1477
|
-
"operationId": "ZaloAds_getReportapiV2Ads",
|
|
1478
|
-
"method": "GET",
|
|
1479
|
-
"endpoint": "/reportapi/v2/ads",
|
|
1480
|
-
"baseUrl": "https://ads.zalo.me",
|
|
1481
|
-
"binaryFields": [],
|
|
1482
|
-
"pathFields": [],
|
|
1483
|
-
"queryFields": [
|
|
1484
|
-
"to",
|
|
1485
|
-
"from",
|
|
1486
|
-
"filter",
|
|
1487
|
-
"endDate",
|
|
1488
|
-
"refresh",
|
|
1489
|
-
"breakdown",
|
|
1490
|
-
"startDate"
|
|
1491
|
-
],
|
|
1492
|
-
"headerFields": [],
|
|
1493
|
-
"cookieFields": [],
|
|
1494
|
-
"bodyFields": []
|
|
1495
|
-
};
|
|
1496
|
-
var OP_ZaloAdsGetReportapiV2Campaigns = {
|
|
1497
|
-
"operationId": "ZaloAds_getReportapiV2Campaigns",
|
|
1498
|
-
"method": "GET",
|
|
1499
|
-
"endpoint": "/reportapi/v2/campaigns/{campaignId}",
|
|
1388
|
+
var OP_ZaloAdsUpdateNewAds = {
|
|
1389
|
+
"operationId": "ZaloAds_UpdateNewAds",
|
|
1390
|
+
"method": "POST",
|
|
1391
|
+
"endpoint": "/zaapi/UploadCrop",
|
|
1500
1392
|
"baseUrl": "https://ads.zalo.me",
|
|
1501
|
-
"binaryFields": [
|
|
1502
|
-
|
|
1503
|
-
"campaignId"
|
|
1504
|
-
],
|
|
1505
|
-
"queryFields": [
|
|
1506
|
-
"startDate",
|
|
1507
|
-
"endDate",
|
|
1508
|
-
"refresh"
|
|
1393
|
+
"binaryFields": [
|
|
1394
|
+
"File"
|
|
1509
1395
|
],
|
|
1510
|
-
"headerFields": [],
|
|
1511
|
-
"cookieFields": [],
|
|
1512
|
-
"bodyFields": []
|
|
1513
|
-
};
|
|
1514
|
-
var OP_ZaloAdsGetReportapiV2UniqueUser = {
|
|
1515
|
-
"operationId": "ZaloAds_getReportapiV2UniqueUser",
|
|
1516
|
-
"method": "GET",
|
|
1517
|
-
"endpoint": "/reportapi/v2/unique-user",
|
|
1518
|
-
"baseUrl": "https://ads.zalo.me",
|
|
1519
|
-
"binaryFields": [],
|
|
1520
1396
|
"pathFields": [],
|
|
1521
1397
|
"queryFields": [],
|
|
1522
1398
|
"headerFields": [],
|
|
1523
1399
|
"cookieFields": [],
|
|
1524
|
-
"bodyFields": [
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
"pathFields": [],
|
|
1533
|
-
"queryFields": [
|
|
1534
|
-
"filter",
|
|
1535
|
-
"endDate",
|
|
1536
|
-
"refresh",
|
|
1537
|
-
"agencyId",
|
|
1538
|
-
"createdBy",
|
|
1539
|
-
"startDate"
|
|
1540
|
-
],
|
|
1541
|
-
"headerFields": [],
|
|
1542
|
-
"cookieFields": [],
|
|
1543
|
-
"bodyFields": []
|
|
1544
|
-
};
|
|
1545
|
-
var OP_ZaloAdsGetZaapiCampaignReportcampaign = {
|
|
1546
|
-
"operationId": "ZaloAds_getZaapiCampaignReportcampaign",
|
|
1547
|
-
"method": "GET",
|
|
1548
|
-
"endpoint": "/zaapi/Campaign/reportCampaign",
|
|
1549
|
-
"baseUrl": "https://ads.zalo.me",
|
|
1550
|
-
"binaryFields": [],
|
|
1551
|
-
"pathFields": [],
|
|
1552
|
-
"queryFields": [
|
|
1553
|
-
"campaignId",
|
|
1554
|
-
"campId"
|
|
1555
|
-
],
|
|
1556
|
-
"headerFields": [],
|
|
1557
|
-
"cookieFields": [],
|
|
1558
|
-
"bodyFields": []
|
|
1400
|
+
"bodyFields": [
|
|
1401
|
+
"File",
|
|
1402
|
+
"x",
|
|
1403
|
+
"y",
|
|
1404
|
+
"width",
|
|
1405
|
+
"height",
|
|
1406
|
+
"scale"
|
|
1407
|
+
]
|
|
1559
1408
|
};
|
|
1560
|
-
var
|
|
1561
|
-
"operationId": "
|
|
1562
|
-
"method": "
|
|
1563
|
-
"endpoint": "/zaapi/
|
|
1409
|
+
var OP_ZaloAdsUpdateOfficialAccountAd = {
|
|
1410
|
+
"operationId": "ZaloAds_updateOfficialAccountAd",
|
|
1411
|
+
"method": "POST",
|
|
1412
|
+
"endpoint": "/zaapi/UpdateAd",
|
|
1564
1413
|
"baseUrl": "https://ads.zalo.me",
|
|
1565
1414
|
"binaryFields": [],
|
|
1566
1415
|
"pathFields": [],
|
|
1567
|
-
"queryFields": [
|
|
1568
|
-
"campaignId",
|
|
1569
|
-
"campId"
|
|
1570
|
-
],
|
|
1416
|
+
"queryFields": [],
|
|
1571
1417
|
"headerFields": [],
|
|
1572
1418
|
"cookieFields": [],
|
|
1573
|
-
"bodyFields": [
|
|
1419
|
+
"bodyFields": [
|
|
1420
|
+
"est",
|
|
1421
|
+
"stt",
|
|
1422
|
+
"data",
|
|
1423
|
+
"isBoostAd"
|
|
1424
|
+
]
|
|
1574
1425
|
};
|
|
1575
|
-
var
|
|
1576
|
-
"operationId": "
|
|
1577
|
-
"method": "
|
|
1578
|
-
"endpoint": "/zaapi/
|
|
1426
|
+
var OP_ZaloAdsUpdatePostAd = {
|
|
1427
|
+
"operationId": "ZaloAds_updatePostAd",
|
|
1428
|
+
"method": "POST",
|
|
1429
|
+
"endpoint": "/zaapi/UpdateAd",
|
|
1579
1430
|
"baseUrl": "https://ads.zalo.me",
|
|
1580
1431
|
"binaryFields": [],
|
|
1581
1432
|
"pathFields": [],
|
|
1582
|
-
"queryFields": [
|
|
1583
|
-
"campaignId",
|
|
1584
|
-
"campId"
|
|
1585
|
-
],
|
|
1433
|
+
"queryFields": [],
|
|
1586
1434
|
"headerFields": [],
|
|
1587
1435
|
"cookieFields": [],
|
|
1588
|
-
"bodyFields": [
|
|
1436
|
+
"bodyFields": [
|
|
1437
|
+
"est",
|
|
1438
|
+
"stt",
|
|
1439
|
+
"data",
|
|
1440
|
+
"isBoostAd"
|
|
1441
|
+
]
|
|
1589
1442
|
};
|
|
1590
|
-
var
|
|
1591
|
-
"operationId": "
|
|
1592
|
-
"method": "
|
|
1593
|
-
"endpoint": "/zaapi/
|
|
1443
|
+
var OP_ZaloAdsCreateWebsiteCampaign = {
|
|
1444
|
+
"operationId": "ZaloAds_createWebsiteCampaign",
|
|
1445
|
+
"method": "POST",
|
|
1446
|
+
"endpoint": "/zaapi/addNewCamp",
|
|
1594
1447
|
"baseUrl": "https://ads.zalo.me",
|
|
1595
1448
|
"binaryFields": [],
|
|
1596
1449
|
"pathFields": [],
|
|
1597
1450
|
"queryFields": [],
|
|
1598
1451
|
"headerFields": [],
|
|
1599
1452
|
"cookieFields": [],
|
|
1600
|
-
"bodyFields": [
|
|
1453
|
+
"bodyFields": [
|
|
1454
|
+
"data"
|
|
1455
|
+
]
|
|
1601
1456
|
};
|
|
1602
|
-
var
|
|
1603
|
-
"operationId": "
|
|
1604
|
-
"method": "
|
|
1605
|
-
"endpoint": "/zaapi/
|
|
1457
|
+
var OP_ZaloAdsUpdateWebsiteAd = {
|
|
1458
|
+
"operationId": "ZaloAds_updateWebsiteAd",
|
|
1459
|
+
"method": "POST",
|
|
1460
|
+
"endpoint": "/zaapi/UpdateAd",
|
|
1606
1461
|
"baseUrl": "https://ads.zalo.me",
|
|
1607
1462
|
"binaryFields": [],
|
|
1608
1463
|
"pathFields": [],
|
|
1609
|
-
"queryFields": [
|
|
1610
|
-
"pageId"
|
|
1611
|
-
],
|
|
1464
|
+
"queryFields": [],
|
|
1612
1465
|
"headerFields": [],
|
|
1613
1466
|
"cookieFields": [],
|
|
1614
|
-
"bodyFields": [
|
|
1467
|
+
"bodyFields": [
|
|
1468
|
+
"est",
|
|
1469
|
+
"stt",
|
|
1470
|
+
"data",
|
|
1471
|
+
"isBoostAd"
|
|
1472
|
+
]
|
|
1615
1473
|
};
|
|
1616
|
-
var
|
|
1617
|
-
"operationId": "
|
|
1618
|
-
"method": "
|
|
1619
|
-
"endpoint": "/zaapi/
|
|
1474
|
+
var OP_ZaloAdsCreateDisplayCampaign = {
|
|
1475
|
+
"operationId": "ZaloAds_createDisplayCampaign",
|
|
1476
|
+
"method": "POST",
|
|
1477
|
+
"endpoint": "/zaapi/addNewCamp",
|
|
1620
1478
|
"baseUrl": "https://ads.zalo.me",
|
|
1621
1479
|
"binaryFields": [],
|
|
1622
1480
|
"pathFields": [],
|
|
1623
1481
|
"queryFields": [],
|
|
1624
1482
|
"headerFields": [],
|
|
1625
1483
|
"cookieFields": [],
|
|
1626
|
-
"bodyFields": [
|
|
1484
|
+
"bodyFields": [
|
|
1485
|
+
"data"
|
|
1486
|
+
]
|
|
1627
1487
|
};
|
|
1628
|
-
var
|
|
1629
|
-
"operationId": "
|
|
1630
|
-
"method": "
|
|
1631
|
-
"endpoint": "/
|
|
1488
|
+
var OP_ZaloAdsUpdateDisplayAd = {
|
|
1489
|
+
"operationId": "ZaloAds_updateDisplayAd",
|
|
1490
|
+
"method": "POST",
|
|
1491
|
+
"endpoint": "/zaapi/UpdateAd",
|
|
1632
1492
|
"baseUrl": "https://ads.zalo.me",
|
|
1633
1493
|
"binaryFields": [],
|
|
1634
1494
|
"pathFields": [],
|
|
1635
|
-
"queryFields": [
|
|
1636
|
-
"limit",
|
|
1637
|
-
"offset",
|
|
1638
|
-
"joinDateAsc"
|
|
1639
|
-
],
|
|
1495
|
+
"queryFields": [],
|
|
1640
1496
|
"headerFields": [],
|
|
1641
1497
|
"cookieFields": [],
|
|
1642
|
-
"bodyFields": [
|
|
1498
|
+
"bodyFields": [
|
|
1499
|
+
"est",
|
|
1500
|
+
"stt",
|
|
1501
|
+
"data",
|
|
1502
|
+
"isBoostAd"
|
|
1503
|
+
]
|
|
1643
1504
|
};
|
|
1644
|
-
var
|
|
1645
|
-
"operationId": "
|
|
1646
|
-
"method": "
|
|
1647
|
-
"endpoint": "/
|
|
1505
|
+
var OP_ZaloAdsCreateVideoCampaign = {
|
|
1506
|
+
"operationId": "ZaloAds_createVideoCampaign",
|
|
1507
|
+
"method": "POST",
|
|
1508
|
+
"endpoint": "/zaapi/addNewCamp",
|
|
1648
1509
|
"baseUrl": "https://ads.zalo.me",
|
|
1649
1510
|
"binaryFields": [],
|
|
1650
1511
|
"pathFields": [],
|
|
1651
1512
|
"queryFields": [],
|
|
1652
1513
|
"headerFields": [],
|
|
1653
1514
|
"cookieFields": [],
|
|
1654
|
-
"bodyFields": [
|
|
1515
|
+
"bodyFields": [
|
|
1516
|
+
"data"
|
|
1517
|
+
]
|
|
1655
1518
|
};
|
|
1656
|
-
var
|
|
1657
|
-
"operationId": "
|
|
1658
|
-
"method": "
|
|
1659
|
-
"endpoint": "/api/
|
|
1519
|
+
var OP_ZaloAdsDeleteCampaign = {
|
|
1520
|
+
"operationId": "ZaloAds_deleteCampaign",
|
|
1521
|
+
"method": "POST",
|
|
1522
|
+
"endpoint": "/api/campaign/change-status",
|
|
1660
1523
|
"baseUrl": "https://ads.zalo.me",
|
|
1661
1524
|
"binaryFields": [],
|
|
1662
1525
|
"pathFields": [],
|
|
1663
|
-
"queryFields": [
|
|
1664
|
-
"oaId",
|
|
1665
|
-
"isAll"
|
|
1666
|
-
],
|
|
1526
|
+
"queryFields": [],
|
|
1667
1527
|
"headerFields": [],
|
|
1668
1528
|
"cookieFields": [],
|
|
1669
|
-
"bodyFields": [
|
|
1529
|
+
"bodyFields": [
|
|
1530
|
+
"campaignId",
|
|
1531
|
+
"status"
|
|
1532
|
+
]
|
|
1670
1533
|
};
|
|
1671
|
-
var
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
],
|
|
1681
|
-
"
|
|
1682
|
-
"cookieFields": [],
|
|
1683
|
-
"bodyFields": []
|
|
1534
|
+
var OP_ZaloAdsCreateSpellCheckV3Job = {
|
|
1535
|
+
operationId: "zalo_ads_create_spell_check_v3_job",
|
|
1536
|
+
method: "POST",
|
|
1537
|
+
endpoint: "/api/spell-check/v3",
|
|
1538
|
+
baseUrl: "https://ads.zalo.me",
|
|
1539
|
+
binaryFields: [],
|
|
1540
|
+
pathFields: [],
|
|
1541
|
+
queryFields: [],
|
|
1542
|
+
headerFields: [],
|
|
1543
|
+
cookieFields: [],
|
|
1544
|
+
bodyFields: ["title", "caption"]
|
|
1684
1545
|
};
|
|
1685
|
-
var
|
|
1686
|
-
|
|
1546
|
+
var OP_ZaloAdsGetSpellCheckV3Job = {
|
|
1547
|
+
operationId: "zalo_ads_get_spell_check_v3_job",
|
|
1548
|
+
method: "GET",
|
|
1549
|
+
endpoint: "/api/spell-check/v3/{jobId}",
|
|
1550
|
+
baseUrl: "https://ads.zalo.me",
|
|
1551
|
+
binaryFields: [],
|
|
1552
|
+
pathFields: ["jobId"],
|
|
1553
|
+
queryFields: [],
|
|
1554
|
+
headerFields: [],
|
|
1555
|
+
cookieFields: [],
|
|
1556
|
+
bodyFields: []
|
|
1557
|
+
};
|
|
1558
|
+
var ZaloCampaignsService = class {
|
|
1559
|
+
constructor(client) {
|
|
1560
|
+
this.client = client;
|
|
1561
|
+
}
|
|
1562
|
+
updateVideoAd(request, options) {
|
|
1563
|
+
return this.client.requestFormUrlEncoded(OP_ZaloAdsUpdateVideoAd, this.client.toTransportInput(OP_ZaloAdsUpdateVideoAd, request), options);
|
|
1564
|
+
}
|
|
1565
|
+
changeCampaignStatus(request, options) {
|
|
1566
|
+
return this.client.requestFormUrlEncoded(OP_ZaloAdsChangeCampaignStatus, this.client.toTransportInput(OP_ZaloAdsChangeCampaignStatus, request), options);
|
|
1567
|
+
}
|
|
1568
|
+
deleteCampaign(request, options) {
|
|
1569
|
+
const payload = { campaignId: request.campaignId, status: request.status ?? -2 };
|
|
1570
|
+
return this.client.requestFormUrlEncoded(OP_ZaloAdsDeleteCampaign, this.client.toTransportInput(OP_ZaloAdsDeleteCampaign, payload), options);
|
|
1571
|
+
}
|
|
1572
|
+
createWebsiteCampaign(request, options) {
|
|
1573
|
+
return this.client.requestFormUrlEncoded(OP_ZaloAdsCreateWebsiteCampaign, this.client.toTransportInput(OP_ZaloAdsCreateWebsiteCampaign, request), options);
|
|
1574
|
+
}
|
|
1575
|
+
updateWebsiteAd(request, options) {
|
|
1576
|
+
return this.client.requestFormUrlEncoded(OP_ZaloAdsUpdateWebsiteAd, this.client.toTransportInput(OP_ZaloAdsUpdateWebsiteAd, request), options);
|
|
1577
|
+
}
|
|
1578
|
+
createDisplayCampaign(request, options) {
|
|
1579
|
+
return this.client.requestFormUrlEncoded(OP_ZaloAdsCreateDisplayCampaign, this.client.toTransportInput(OP_ZaloAdsCreateDisplayCampaign, request), options);
|
|
1580
|
+
}
|
|
1581
|
+
updateDisplayAd(request, options) {
|
|
1582
|
+
return this.client.requestFormUrlEncoded(OP_ZaloAdsUpdateDisplayAd, this.client.toTransportInput(OP_ZaloAdsUpdateDisplayAd, request), options);
|
|
1583
|
+
}
|
|
1584
|
+
createVideoCampaign(request, options) {
|
|
1585
|
+
return this.client.requestFormUrlEncoded(OP_ZaloAdsCreateVideoCampaign, this.client.toTransportInput(OP_ZaloAdsCreateVideoCampaign, request), options);
|
|
1586
|
+
}
|
|
1587
|
+
createEcommerceCampaign(request, options) {
|
|
1588
|
+
return this.client.requestFormUrlEncoded(OP_ZaloAdsCreateEcommerceCampaign, this.client.toTransportInput(OP_ZaloAdsCreateEcommerceCampaign, request), options);
|
|
1589
|
+
}
|
|
1590
|
+
/** Alias theo tên tool chuẩn `zalo_ads_create_commerce_campaign` trong Project Schema Zalo ADS (`campaignType = 22`). */
|
|
1591
|
+
createCommerceCampaign(request, options) {
|
|
1592
|
+
return this.createEcommerceCampaign(request, options);
|
|
1593
|
+
}
|
|
1594
|
+
createForm(request, options) {
|
|
1595
|
+
return this.client.requestFormUrlEncoded(OP_ZaloAdsCreateForm, this.client.toTransportInput(OP_ZaloAdsCreateForm, request), options);
|
|
1596
|
+
}
|
|
1597
|
+
createFormCampaign(request, options) {
|
|
1598
|
+
return this.client.requestFormUrlEncoded(OP_ZaloAdsCreateFormCampaign, this.client.toTransportInput(OP_ZaloAdsCreateFormCampaign, request), options);
|
|
1599
|
+
}
|
|
1600
|
+
createMessageCampaign(request, options) {
|
|
1601
|
+
return this.client.requestFormUrlEncoded(OP_ZaloAdsCreateMessageCampaign, this.client.toTransportInput(OP_ZaloAdsCreateMessageCampaign, request), options);
|
|
1602
|
+
}
|
|
1603
|
+
createOfficialAccountCampaign(request, options) {
|
|
1604
|
+
return this.client.requestFormUrlEncoded(OP_ZaloAdsCreateOfficialAccountCampaign, this.client.toTransportInput(OP_ZaloAdsCreateOfficialAccountCampaign, request), options);
|
|
1605
|
+
}
|
|
1606
|
+
/** Alias theo tên tool chuẩn `zalo_ads_create_oa_campaign` trong Project Schema Zalo ADS (`campaignType = 3`). */
|
|
1607
|
+
createOaCampaign(request, options) {
|
|
1608
|
+
return this.createOfficialAccountCampaign(request, options);
|
|
1609
|
+
}
|
|
1610
|
+
createPostCampaign(request, options) {
|
|
1611
|
+
return this.client.requestFormUrlEncoded(OP_ZaloAdsCreatePostCampaign, this.client.toTransportInput(OP_ZaloAdsCreatePostCampaign, request), options);
|
|
1612
|
+
}
|
|
1613
|
+
/** Alias theo tên tool chuẩn `zalo_ads_create_article_campaign` trong Project Schema Zalo ADS (`campaignType = 4`). */
|
|
1614
|
+
createArticleCampaign(request, options) {
|
|
1615
|
+
return this.createPostCampaign(request, options);
|
|
1616
|
+
}
|
|
1617
|
+
getAdById(request = {}, options) {
|
|
1618
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetAdById, this.client.toTransportInput(OP_ZaloAdsGetAdById, request), options);
|
|
1619
|
+
}
|
|
1620
|
+
getAdChangeLog(request, options) {
|
|
1621
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetAdChangeLog, this.client.toTransportInput(OP_ZaloAdsGetAdChangeLog, request), options);
|
|
1622
|
+
}
|
|
1623
|
+
getApiPlaceGetalldistricts(request = {}, options) {
|
|
1624
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetApiPlaceGetalldistricts, this.client.toTransportInput(OP_ZaloAdsGetApiPlaceGetalldistricts, request), options);
|
|
1625
|
+
}
|
|
1626
|
+
getApiSpellCheckV2(request, options) {
|
|
1627
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetApiSpellCheckV2, this.client.toTransportInput(OP_ZaloAdsGetApiSpellCheckV2, request), options);
|
|
1628
|
+
}
|
|
1629
|
+
getZaapiCheckcamphasmanyads(request = {}, options) {
|
|
1630
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetZaapiCheckcamphasmanyads, this.client.toTransportInput(OP_ZaloAdsGetZaapiCheckcamphasmanyads, request), options);
|
|
1631
|
+
}
|
|
1632
|
+
getZaapiGetadsfromcampaignid(request = {}, options) {
|
|
1633
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetZaapiGetadsfromcampaignid, this.client.toTransportInput(OP_ZaloAdsGetZaapiGetadsfromcampaignid, request), options);
|
|
1634
|
+
}
|
|
1635
|
+
getZaapiGetallpages(request = {}, options) {
|
|
1636
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetZaapiGetallpages, this.client.toTransportInput(OP_ZaloAdsGetZaapiGetallpages, request), options);
|
|
1637
|
+
}
|
|
1638
|
+
getAllPages(request = {}, options) {
|
|
1639
|
+
return this.getZaapiGetallpages(request, options);
|
|
1640
|
+
}
|
|
1641
|
+
getZaapiGetownedarticles(request, options) {
|
|
1642
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetZaapiGetownedarticles, this.client.toTransportInput(OP_ZaloAdsGetZaapiGetownedarticles, request), options);
|
|
1643
|
+
}
|
|
1644
|
+
getOwnedArticles(request, options) {
|
|
1645
|
+
return this.getZaapiGetownedarticles(request, options);
|
|
1646
|
+
}
|
|
1647
|
+
getZaapiGetownedpages(request = {}, options) {
|
|
1648
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetZaapiGetownedpages, this.client.toTransportInput(OP_ZaloAdsGetZaapiGetownedpages, request), options);
|
|
1649
|
+
}
|
|
1650
|
+
getOwnedPages(request = {}, options) {
|
|
1651
|
+
return this.getZaapiGetownedpages(request, options);
|
|
1652
|
+
}
|
|
1653
|
+
listFormsByOfficialAccount(request, options) {
|
|
1654
|
+
return this.client.requestWithoutBody(OP_ZaloAdsListFormsByOfficialAccount, this.client.toTransportInput(OP_ZaloAdsListFormsByOfficialAccount, request), options);
|
|
1655
|
+
}
|
|
1656
|
+
listMiniPagesByTemplate(request, options) {
|
|
1657
|
+
return this.client.requestWithoutBody(OP_ZaloAdsListMiniPagesByTemplate, this.client.toTransportInput(OP_ZaloAdsListMiniPagesByTemplate, request), options);
|
|
1658
|
+
}
|
|
1659
|
+
postZaapiDeletead(request = {}, options) {
|
|
1660
|
+
return this.client.requestWithoutBody(OP_ZaloAdsPostZaapiDeletead, this.client.toTransportInput(OP_ZaloAdsPostZaapiDeletead, request), options);
|
|
1661
|
+
}
|
|
1662
|
+
renameCampaign(request, options) {
|
|
1663
|
+
return this.client.requestFormUrlEncoded(OP_ZaloAdsRenameCampaign, this.client.toTransportInput(OP_ZaloAdsRenameCampaign, request), options);
|
|
1664
|
+
}
|
|
1665
|
+
updateEcommerceAd(request, options) {
|
|
1666
|
+
return this.client.requestFormUrlEncoded(OP_ZaloAdsUpdateEcommerceAd, this.client.toTransportInput(OP_ZaloAdsUpdateEcommerceAd, request), options);
|
|
1667
|
+
}
|
|
1668
|
+
/** Alias theo tên tool chuẩn `zalo_ads_update_commerce_ad` trong Project Schema Zalo ADS (`Type = 23`, gắn `MiniPageId`). */
|
|
1669
|
+
updateCommerceAd(request, options) {
|
|
1670
|
+
return this.updateEcommerceAd(request, options);
|
|
1671
|
+
}
|
|
1672
|
+
updateFormAd(request, options) {
|
|
1673
|
+
return this.client.requestFormUrlEncoded(OP_ZaloAdsUpdateFormAd, this.client.toTransportInput(OP_ZaloAdsUpdateFormAd, request), options);
|
|
1674
|
+
}
|
|
1675
|
+
updateMessageAd(request, options) {
|
|
1676
|
+
return this.client.requestFormUrlEncoded(OP_ZaloAdsUpdateMessageAd, this.client.toTransportInput(OP_ZaloAdsUpdateMessageAd, request), options);
|
|
1677
|
+
}
|
|
1678
|
+
updateNewAds(request, options) {
|
|
1679
|
+
return this.client.requestMultipart(OP_ZaloAdsUpdateNewAds, this.client.toTransportInput(OP_ZaloAdsUpdateNewAds, request), options);
|
|
1680
|
+
}
|
|
1681
|
+
updateOfficialAccountAd(request, options) {
|
|
1682
|
+
return this.client.requestFormUrlEncoded(OP_ZaloAdsUpdateOfficialAccountAd, this.client.toTransportInput(OP_ZaloAdsUpdateOfficialAccountAd, request), options);
|
|
1683
|
+
}
|
|
1684
|
+
/** Alias theo tên tool chuẩn `zalo_ads_update_oa_ad` trong Project Schema Zalo ADS (`Type = 2`, `Action = 6`). */
|
|
1685
|
+
updateOaAd(request, options) {
|
|
1686
|
+
return this.updateOfficialAccountAd(request, options);
|
|
1687
|
+
}
|
|
1688
|
+
updatePostAd(request, options) {
|
|
1689
|
+
return this.client.requestFormUrlEncoded(OP_ZaloAdsUpdatePostAd, this.client.toTransportInput(OP_ZaloAdsUpdatePostAd, request), options);
|
|
1690
|
+
}
|
|
1691
|
+
/** Alias theo tên tool chuẩn `zalo_ads_update_article_ad` trong Project Schema Zalo ADS (`Type = 3`, gắn `ZaloFeedId`). */
|
|
1692
|
+
updateArticleAd(request, options) {
|
|
1693
|
+
return this.updatePostAd(request, options);
|
|
1694
|
+
}
|
|
1695
|
+
/** Xóa quảng cáo */
|
|
1696
|
+
deleteAd(...args) {
|
|
1697
|
+
return this.postZaapiDeletead(...args);
|
|
1698
|
+
}
|
|
1699
|
+
/** Danh sách quận/huyện để nhắm mục tiêu */
|
|
1700
|
+
getAllDistricts(...args) {
|
|
1701
|
+
return this.getApiPlaceGetalldistricts(...args);
|
|
1702
|
+
}
|
|
1703
|
+
/** Kiểm tra chính tả văn bản quảng cáo */
|
|
1704
|
+
getSpellCheckV2(...args) {
|
|
1705
|
+
return this.getApiSpellCheckV2(...args);
|
|
1706
|
+
}
|
|
1707
|
+
/**
|
|
1708
|
+
* Khởi tạo tác vụ kiểm tra chính tả và vi phạm quy chuẩn quảng cáo AI V3 (POST /api/spell-check/v3).
|
|
1709
|
+
*/
|
|
1710
|
+
createSpellCheckV3Job(request, options) {
|
|
1711
|
+
return this.client.requestJson(
|
|
1712
|
+
OP_ZaloAdsCreateSpellCheckV3Job,
|
|
1713
|
+
this.client.toTransportInput(OP_ZaloAdsCreateSpellCheckV3Job, request),
|
|
1714
|
+
options
|
|
1715
|
+
);
|
|
1716
|
+
}
|
|
1717
|
+
/**
|
|
1718
|
+
* Lấy kết quả kiểm tra chính tả AI V3 theo jobId (GET /api/spell-check/v3/{jobId}).
|
|
1719
|
+
*/
|
|
1720
|
+
getSpellCheckV3Job(request, options) {
|
|
1721
|
+
return this.client.requestWithoutBody(
|
|
1722
|
+
OP_ZaloAdsGetSpellCheckV3Job,
|
|
1723
|
+
this.client.toTransportInput(OP_ZaloAdsGetSpellCheckV3Job, request),
|
|
1724
|
+
options
|
|
1725
|
+
);
|
|
1726
|
+
}
|
|
1727
|
+
/**
|
|
1728
|
+
* Helper kiểm tra chính tả AI V3 trọn gói: Gửi kiểm tra và tự động polling cho đến khi hoàn thành (hoặc timeout).
|
|
1729
|
+
* @param request Tiêu đề (title) và chú thích (caption) cần kiểm tra.
|
|
1730
|
+
* @param pollIntervalMs Chu kỳ polling kiểm tra trạng thái (mặc định: 600ms).
|
|
1731
|
+
* @param timeoutMs Thời gian chờ tối đa (mặc định: 15.000ms = 15 giây).
|
|
1732
|
+
*/
|
|
1733
|
+
async checkSpellV3AndWait(request, pollIntervalMs = 600, timeoutMs = 15e3, options) {
|
|
1734
|
+
const jobRes = await this.createSpellCheckV3Job(request, options);
|
|
1735
|
+
const jobId = jobRes?.data?.jobId;
|
|
1736
|
+
if (!jobId) {
|
|
1737
|
+
throw new Error(`[SpellCheckV3] Kh\xF4ng nh\u1EADn \u0111\u01B0\u1EE3c jobId t\u1EEB Zalo Ads (code: ${jobRes?.code})`);
|
|
1738
|
+
}
|
|
1739
|
+
const startTime = Date.now();
|
|
1740
|
+
while (Date.now() - startTime < timeoutMs) {
|
|
1741
|
+
await new Promise((r) => setTimeout(r, pollIntervalMs));
|
|
1742
|
+
const res = await this.getSpellCheckV3Job({ jobId }, options);
|
|
1743
|
+
if (res?.data?.status === "COMPLETED") {
|
|
1744
|
+
return res;
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
throw new Error(`[SpellCheckV3] Qu\xE1 th\u1EDDi gian ch\u1EDD (${timeoutMs}ms) cho t\xE1c v\u1EE5 ki\u1EC3m tra ch\xEDnh t\u1EA3 jobId: ${jobId}`);
|
|
1748
|
+
}
|
|
1749
|
+
};
|
|
1750
|
+
|
|
1751
|
+
// src/services/account.service.ts
|
|
1752
|
+
var OP_ZaloAdsGetApiWhoami = {
|
|
1753
|
+
"operationId": "ZaloAds_getApiWhoami",
|
|
1687
1754
|
"method": "GET",
|
|
1688
|
-
"endpoint": "/api/
|
|
1755
|
+
"endpoint": "/api/whoami",
|
|
1756
|
+
"baseUrl": "https://ads.zalo.me",
|
|
1757
|
+
"binaryFields": [],
|
|
1758
|
+
"pathFields": [],
|
|
1759
|
+
"queryFields": [],
|
|
1760
|
+
"headerFields": [],
|
|
1761
|
+
"cookieFields": [],
|
|
1762
|
+
"bodyFields": []
|
|
1763
|
+
};
|
|
1764
|
+
var OP_ZaloAdsGetApiPaymentTransactionHistory = {
|
|
1765
|
+
"operationId": "ZaloAds_getApiPaymentTransactionHistory",
|
|
1766
|
+
"method": "GET",
|
|
1767
|
+
"endpoint": "/api/payment/transaction-history",
|
|
1768
|
+
"baseUrl": "https://ads.zalo.me",
|
|
1769
|
+
"binaryFields": [],
|
|
1770
|
+
"pathFields": [],
|
|
1771
|
+
"queryFields": [
|
|
1772
|
+
"to",
|
|
1773
|
+
"from",
|
|
1774
|
+
"memberId"
|
|
1775
|
+
],
|
|
1776
|
+
"headerFields": [],
|
|
1777
|
+
"cookieFields": [],
|
|
1778
|
+
"bodyFields": []
|
|
1779
|
+
};
|
|
1780
|
+
var OP_ZaloAdsGetApiBaAccountAllaccessors = {
|
|
1781
|
+
"operationId": "ZaloAds_getApiBaAccountAllaccessors",
|
|
1782
|
+
"method": "GET",
|
|
1783
|
+
"endpoint": "/api/ba/account/allAccessors",
|
|
1784
|
+
"baseUrl": "https://ads.zalo.me",
|
|
1785
|
+
"binaryFields": [],
|
|
1786
|
+
"pathFields": [],
|
|
1787
|
+
"queryFields": [
|
|
1788
|
+
"isShowAll"
|
|
1789
|
+
],
|
|
1790
|
+
"headerFields": [],
|
|
1791
|
+
"cookieFields": [],
|
|
1792
|
+
"bodyFields": []
|
|
1793
|
+
};
|
|
1794
|
+
var OP_ZaloAdsGetApiBaAccountAllgrantedmembers = {
|
|
1795
|
+
"operationId": "ZaloAds_getApiBaAccountAllgrantedmembers",
|
|
1796
|
+
"method": "GET",
|
|
1797
|
+
"endpoint": "/api/ba/account/allGrantedMembers",
|
|
1798
|
+
"baseUrl": "https://ads.zalo.me",
|
|
1799
|
+
"binaryFields": [],
|
|
1800
|
+
"pathFields": [],
|
|
1801
|
+
"queryFields": [],
|
|
1802
|
+
"headerFields": [],
|
|
1803
|
+
"cookieFields": [],
|
|
1804
|
+
"bodyFields": []
|
|
1805
|
+
};
|
|
1806
|
+
var OP_ZaloAdsListAgencyCustomersWithBudget = {
|
|
1807
|
+
"operationId": "ZaloAds_listAgencyCustomersWithBudget",
|
|
1808
|
+
"method": "GET",
|
|
1809
|
+
"endpoint": "/api/ba/agency/customersWithBudget",
|
|
1810
|
+
"baseUrl": "https://ads.zalo.me",
|
|
1811
|
+
"binaryFields": [],
|
|
1812
|
+
"pathFields": [],
|
|
1813
|
+
"queryFields": [
|
|
1814
|
+
"limit",
|
|
1815
|
+
"offset",
|
|
1816
|
+
"joinDateAsc"
|
|
1817
|
+
],
|
|
1818
|
+
"headerFields": [],
|
|
1819
|
+
"cookieFields": [],
|
|
1820
|
+
"bodyFields": []
|
|
1821
|
+
};
|
|
1822
|
+
var OP_ZaloAdsGetApiNotifiesHeader = {
|
|
1823
|
+
"operationId": "ZaloAds_getApiNotifiesHeader",
|
|
1824
|
+
"method": "GET",
|
|
1825
|
+
"endpoint": "/api/notifies/header",
|
|
1826
|
+
"baseUrl": "https://ads.zalo.me",
|
|
1827
|
+
"binaryFields": [],
|
|
1828
|
+
"pathFields": [],
|
|
1829
|
+
"queryFields": [],
|
|
1830
|
+
"headerFields": [],
|
|
1831
|
+
"cookieFields": [],
|
|
1832
|
+
"bodyFields": []
|
|
1833
|
+
};
|
|
1834
|
+
var OP_ZaloAdsGetApiLpNews = {
|
|
1835
|
+
"operationId": "ZaloAds_getApiLpNews",
|
|
1836
|
+
"method": "GET",
|
|
1837
|
+
"endpoint": "/api/lp-news",
|
|
1838
|
+
"baseUrl": "https://ads.zalo.me",
|
|
1839
|
+
"binaryFields": [],
|
|
1840
|
+
"pathFields": [],
|
|
1841
|
+
"queryFields": [],
|
|
1842
|
+
"headerFields": [],
|
|
1843
|
+
"cookieFields": [],
|
|
1844
|
+
"bodyFields": []
|
|
1845
|
+
};
|
|
1846
|
+
var ZaloAccountService = class {
|
|
1847
|
+
constructor(client) {
|
|
1848
|
+
this.client = client;
|
|
1849
|
+
}
|
|
1850
|
+
getApiWhoami(request = {}, options) {
|
|
1851
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetApiWhoami, this.client.toTransportInput(OP_ZaloAdsGetApiWhoami, request), options);
|
|
1852
|
+
}
|
|
1853
|
+
getApiPaymentTransactionHistory(request, options) {
|
|
1854
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetApiPaymentTransactionHistory, this.client.toTransportInput(OP_ZaloAdsGetApiPaymentTransactionHistory, request), options);
|
|
1855
|
+
}
|
|
1856
|
+
getApiBaAccountAllaccessors(request = {}, options) {
|
|
1857
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetApiBaAccountAllaccessors, this.client.toTransportInput(OP_ZaloAdsGetApiBaAccountAllaccessors, request), options);
|
|
1858
|
+
}
|
|
1859
|
+
getApiBaAccountAllgrantedmembers(request = {}, options) {
|
|
1860
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetApiBaAccountAllgrantedmembers, this.client.toTransportInput(OP_ZaloAdsGetApiBaAccountAllgrantedmembers, request), options);
|
|
1861
|
+
}
|
|
1862
|
+
listAgencyCustomersWithBudget(request = { limit: 15, offset: 0, joinDateAsc: true }, options) {
|
|
1863
|
+
const normalized = {
|
|
1864
|
+
limit: 15,
|
|
1865
|
+
offset: 0,
|
|
1866
|
+
joinDateAsc: true,
|
|
1867
|
+
...request
|
|
1868
|
+
};
|
|
1869
|
+
return this.client.requestWithoutBody(OP_ZaloAdsListAgencyCustomersWithBudget, this.client.toTransportInput(OP_ZaloAdsListAgencyCustomersWithBudget, normalized), options);
|
|
1870
|
+
}
|
|
1871
|
+
getApiNotifiesHeader(request = {}, options) {
|
|
1872
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetApiNotifiesHeader, this.client.toTransportInput(OP_ZaloAdsGetApiNotifiesHeader, request), options);
|
|
1873
|
+
}
|
|
1874
|
+
getApiLpNews(request = {}, options) {
|
|
1875
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetApiLpNews, this.client.toTransportInput(OP_ZaloAdsGetApiLpNews, request), options);
|
|
1876
|
+
}
|
|
1877
|
+
/** Lấy thông tin tài khoản đang đăng nhập */
|
|
1878
|
+
getWhoami(...args) {
|
|
1879
|
+
return this.getApiWhoami(...args);
|
|
1880
|
+
}
|
|
1881
|
+
/** Lịch sử giao dịch thanh toán */
|
|
1882
|
+
getPaymentTransactionHistory(...args) {
|
|
1883
|
+
return this.getApiPaymentTransactionHistory(...args);
|
|
1884
|
+
}
|
|
1885
|
+
/** Danh sách accessor tài khoản BA */
|
|
1886
|
+
getBaAccountAllAccessors(...args) {
|
|
1887
|
+
return this.getApiBaAccountAllaccessors(...args);
|
|
1888
|
+
}
|
|
1889
|
+
/** Danh sách thành viên được cấp quyền BA */
|
|
1890
|
+
getBaAccountAllGrantedMembers(...args) {
|
|
1891
|
+
return this.getApiBaAccountAllgrantedmembers(...args);
|
|
1892
|
+
}
|
|
1893
|
+
/** Thông báo trên thanh tiêu đề */
|
|
1894
|
+
getNotifiesHeader(...args) {
|
|
1895
|
+
return this.getApiNotifiesHeader(...args);
|
|
1896
|
+
}
|
|
1897
|
+
/** Tin tức landing page / bảng tin */
|
|
1898
|
+
getLpNews(...args) {
|
|
1899
|
+
return this.getApiLpNews(...args);
|
|
1900
|
+
}
|
|
1901
|
+
};
|
|
1902
|
+
|
|
1903
|
+
// src/validators/audiences.validator.ts
|
|
1904
|
+
function validateCreateSavedAudienceRequest(input) {
|
|
1905
|
+
const errors = [];
|
|
1906
|
+
if (!input || typeof input !== "object") {
|
|
1907
|
+
return { isValid: false, errors: ["Input ph\u1EA3i l\xE0 m\u1ED9t object."], data: void 0 };
|
|
1908
|
+
}
|
|
1909
|
+
const raw = input;
|
|
1910
|
+
const name = typeof raw.name === "string" ? raw.name.trim() : "";
|
|
1911
|
+
if (!name) {
|
|
1912
|
+
errors.push("T\xEAn nh\xF3m \u0111\u1ED1i t\u01B0\u1EE3ng 'name' l\xE0 b\u1EAFt bu\u1ED9c.");
|
|
1913
|
+
} else if (name.length < 2 || name.length > 255) {
|
|
1914
|
+
errors.push("T\xEAn nh\xF3m \u0111\u1ED1i t\u01B0\u1EE3ng 'name' ph\u1EA3i t\u1EEB 2 \u0111\u1EBFn 255 k\xFD t\u1EF1.");
|
|
1915
|
+
}
|
|
1916
|
+
let targetingObj;
|
|
1917
|
+
if (typeof raw.targeting === "string") {
|
|
1918
|
+
try {
|
|
1919
|
+
targetingObj = JSON.parse(raw.targeting);
|
|
1920
|
+
} catch {
|
|
1921
|
+
errors.push("Tr\u01B0\u1EDDng 'targeting' l\xE0 chu\u1ED7i JSON kh\xF4ng h\u1EE3p l\u1EC7.");
|
|
1922
|
+
targetingObj = {};
|
|
1923
|
+
}
|
|
1924
|
+
} else if (raw.targeting && typeof raw.targeting === "object") {
|
|
1925
|
+
targetingObj = raw.targeting;
|
|
1926
|
+
} else {
|
|
1927
|
+
errors.push("Tr\u01B0\u1EDDng 'targeting' l\xE0 b\u1EAFt bu\u1ED9c (chu\u1ED7i JSON ho\u1EB7c Object c\u1EA5u h\xECnh targeting).");
|
|
1928
|
+
targetingObj = {};
|
|
1929
|
+
}
|
|
1930
|
+
const gender = typeof targetingObj.Gender === "number" ? targetingObj.Gender : 0;
|
|
1931
|
+
if (![0, 1, 2].includes(gender)) {
|
|
1932
|
+
errors.push("Tr\u01B0\u1EDDng 'Gender' ph\u1EA3i l\xE0 0 (T\u1EA5t c\u1EA3), 1 (Nam), ho\u1EB7c 2 (N\u1EEF).");
|
|
1933
|
+
}
|
|
1934
|
+
const VALID_AGE_RANGES = [10282, 10283, 10284, 10285, 10286, 10287, 10288];
|
|
1935
|
+
const newAgeRanges = Array.isArray(targetingObj.NewAgeRanges) && targetingObj.NewAgeRanges.length > 0 ? targetingObj.NewAgeRanges.map(Number) : VALID_AGE_RANGES;
|
|
1936
|
+
for (const age of newAgeRanges) {
|
|
1937
|
+
if (!VALID_AGE_RANGES.includes(age)) {
|
|
1938
|
+
errors.push(`M\xE3 \u0111\u1ED9 tu\u1ED5i '${age}' kh\xF4ng h\u1EE3p l\u1EC7. C\xE1c m\xE3 cho ph\xE9p: ${VALID_AGE_RANGES.join(", ")}.`);
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
const VALID_OS = [0, 1, 2, 3];
|
|
1942
|
+
const os = Array.isArray(targetingObj.Os) && targetingObj.Os.length > 0 ? targetingObj.Os.map(Number) : [0, 1, 3];
|
|
1943
|
+
for (const o of os) {
|
|
1944
|
+
if (!VALID_OS.includes(o)) {
|
|
1945
|
+
errors.push(`M\xE3 h\u1EC7 \u0111i\u1EC1u h\xE0nh '${o}' kh\xF4ng h\u1EE3p l\u1EC7 (0: Android, 1: iOS, 2: Windows Phone, 3: PC).`);
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
let location = targetingObj.Location;
|
|
1949
|
+
if (!location || typeof location !== "object") {
|
|
1950
|
+
location = {
|
|
1951
|
+
Addresses: [],
|
|
1952
|
+
Cities: [],
|
|
1953
|
+
WardTargeting: { Includes: [], Excludes: [] }
|
|
1954
|
+
};
|
|
1955
|
+
} else {
|
|
1956
|
+
location = {
|
|
1957
|
+
Addresses: Array.isArray(location.Addresses) ? location.Addresses : [],
|
|
1958
|
+
Cities: Array.isArray(location.Cities) ? location.Cities : [],
|
|
1959
|
+
WardTargeting: location.WardTargeting && typeof location.WardTargeting === "object" ? location.WardTargeting : { Includes: [], Excludes: [] }
|
|
1960
|
+
};
|
|
1961
|
+
if (location.WardTargeting.Includes && !Array.isArray(location.WardTargeting.Includes)) {
|
|
1962
|
+
errors.push("Tr\u01B0\u1EDDng 'Location.WardTargeting.Includes' ph\u1EA3i l\xE0 m\u1ED9t m\u1EA3ng khu v\u1EF1c.");
|
|
1963
|
+
} else if (Array.isArray(location.WardTargeting.Includes)) {
|
|
1964
|
+
for (const inc of location.WardTargeting.Includes) {
|
|
1965
|
+
if (![1, 2, 3].includes(Number(inc.Id))) {
|
|
1966
|
+
errors.push(`M\xE3 v\xF9ng mi\u1EC1n Id='${inc.Id}' kh\xF4ng h\u1EE3p l\u1EC7 (1: Mi\u1EC1n B\u1EAFc, 2: Mi\u1EC1n Trung, 3: Mi\u1EC1n Nam).`);
|
|
1967
|
+
}
|
|
1968
|
+
if (inc.Provinces && !Array.isArray(inc.Provinces)) {
|
|
1969
|
+
errors.push(`Tr\u01B0\u1EDDng 'Provinces' trong v\xF9ng mi\u1EC1n Id=${inc.Id} ph\u1EA3i l\xE0 m\u1ED9t m\u1EA3ng t\u1EC9nh/th\xE0nh.`);
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
const finalTargeting = {
|
|
1975
|
+
...targetingObj,
|
|
1976
|
+
CustomAudienceId: 0,
|
|
1977
|
+
Gender: gender,
|
|
1978
|
+
NewAgeRanges: newAgeRanges,
|
|
1979
|
+
Os: os,
|
|
1980
|
+
Location: location
|
|
1981
|
+
};
|
|
1982
|
+
return {
|
|
1983
|
+
isValid: errors.length === 0,
|
|
1984
|
+
errors,
|
|
1985
|
+
data: errors.length === 0 ? {
|
|
1986
|
+
name,
|
|
1987
|
+
caType: 1,
|
|
1988
|
+
targeting: JSON.stringify(finalTargeting)
|
|
1989
|
+
} : void 0
|
|
1990
|
+
};
|
|
1991
|
+
}
|
|
1992
|
+
function validateCreatePhoneAudienceRequest(input) {
|
|
1993
|
+
const errors = [];
|
|
1994
|
+
if (!input || typeof input !== "object") {
|
|
1995
|
+
return { isValid: false, errors: ["Input ph\u1EA3i l\xE0 m\u1ED9t object."], data: void 0 };
|
|
1996
|
+
}
|
|
1997
|
+
const raw = input;
|
|
1998
|
+
const name = typeof raw.name === "string" ? raw.name.trim() : "";
|
|
1999
|
+
if (!name || name.length < 2 || name.length > 255) {
|
|
2000
|
+
errors.push("T\xEAn nh\xF3m \u0111\u1ED1i t\u01B0\u1EE3ng 'name' ph\u1EA3i t\u1EEB 2 \u0111\u1EBFn 255 k\xFD t\u1EF1.");
|
|
2001
|
+
}
|
|
2002
|
+
let targetingObj = {};
|
|
2003
|
+
if (typeof raw.targeting === "string") {
|
|
2004
|
+
try {
|
|
2005
|
+
targetingObj = JSON.parse(raw.targeting);
|
|
2006
|
+
} catch {
|
|
2007
|
+
errors.push("Tr\u01B0\u1EDDng 'targeting' l\xE0 chu\u1ED7i JSON kh\xF4ng h\u1EE3p l\u1EC7.");
|
|
2008
|
+
}
|
|
2009
|
+
} else if (raw.targeting && typeof raw.targeting === "object") {
|
|
2010
|
+
targetingObj = raw.targeting;
|
|
2011
|
+
} else {
|
|
2012
|
+
errors.push("Tr\u01B0\u1EDDng 'targeting' l\xE0 b\u1EAFt bu\u1ED9c.");
|
|
2013
|
+
}
|
|
2014
|
+
const path = typeof targetingObj.Path === "string" ? targetingObj.Path.trim() : "";
|
|
2015
|
+
if (!path) {
|
|
2016
|
+
errors.push("Tr\u01B0\u1EDDng 'Path' (URL file .txt sau khi upload) l\xE0 b\u1EAFt bu\u1ED9c.");
|
|
2017
|
+
}
|
|
2018
|
+
const total = typeof targetingObj.Total === "number" ? targetingObj.Total : 0;
|
|
2019
|
+
if (total <= 0) {
|
|
2020
|
+
errors.push("Tr\u01B0\u1EDDng 'Total' (s\u1ED1 l\u01B0\u1EE3ng S\u0110T trong file) ph\u1EA3i l\u1EDBn h\u01A1n 0.");
|
|
2021
|
+
}
|
|
2022
|
+
return {
|
|
2023
|
+
isValid: errors.length === 0,
|
|
2024
|
+
errors,
|
|
2025
|
+
data: errors.length === 0 ? {
|
|
2026
|
+
name,
|
|
2027
|
+
caType: 3,
|
|
2028
|
+
targeting: JSON.stringify({
|
|
2029
|
+
Name: String(targetingObj.Name || "phones.txt"),
|
|
2030
|
+
Path: path,
|
|
2031
|
+
Total: total,
|
|
2032
|
+
ZaloId: Number(targetingObj.ZaloId || 0),
|
|
2033
|
+
OriginAudience: 0
|
|
2034
|
+
})
|
|
2035
|
+
} : void 0
|
|
2036
|
+
};
|
|
2037
|
+
}
|
|
2038
|
+
function validateCreateLookalikeAudienceRequest(input) {
|
|
2039
|
+
const errors = [];
|
|
2040
|
+
if (!input || typeof input !== "object") {
|
|
2041
|
+
return { isValid: false, errors: ["Input ph\u1EA3i l\xE0 m\u1ED9t object."], data: void 0 };
|
|
2042
|
+
}
|
|
2043
|
+
const raw = input;
|
|
2044
|
+
const name = typeof raw.name === "string" ? raw.name.trim() : "";
|
|
2045
|
+
if (!name || name.length < 2 || name.length > 255) {
|
|
2046
|
+
errors.push("T\xEAn nh\xF3m \u0111\u1ED1i t\u01B0\u1EE3ng 'name' ph\u1EA3i t\u1EEB 2 \u0111\u1EBFn 255 k\xFD t\u1EF1.");
|
|
2047
|
+
}
|
|
2048
|
+
let targetingObj = {};
|
|
2049
|
+
if (typeof raw.targeting === "string") {
|
|
2050
|
+
try {
|
|
2051
|
+
targetingObj = JSON.parse(raw.targeting);
|
|
2052
|
+
} catch {
|
|
2053
|
+
errors.push("Tr\u01B0\u1EDDng 'targeting' l\xE0 chu\u1ED7i JSON kh\xF4ng h\u1EE3p l\u1EC7.");
|
|
2054
|
+
}
|
|
2055
|
+
} else if (raw.targeting && typeof raw.targeting === "object") {
|
|
2056
|
+
targetingObj = raw.targeting;
|
|
2057
|
+
} else {
|
|
2058
|
+
errors.push("Tr\u01B0\u1EDDng 'targeting' l\xE0 b\u1EAFt bu\u1ED9c.");
|
|
2059
|
+
}
|
|
2060
|
+
const originAudience = Number(targetingObj.OriginAudience);
|
|
2061
|
+
if (!originAudience || originAudience <= 0) {
|
|
2062
|
+
errors.push("Tr\u01B0\u1EDDng 'OriginAudience' (ID nh\xF3m \u0111\u1ED1i t\u01B0\u1EE3ng S\u0110T g\u1ED1c) l\xE0 b\u1EAFt bu\u1ED9c.");
|
|
2063
|
+
}
|
|
2064
|
+
const total = Number(targetingObj.Total);
|
|
2065
|
+
if (![1e6, 15e5, 2e6].includes(total)) {
|
|
2066
|
+
errors.push("Tr\u01B0\u1EDDng 'Total' c\u1EE7a Lookalike ch\u1EC9 ch\u1EA5p nh\u1EADn c\xE1c m\u1ED1c: 1.000.000, 1.500.000 ho\u1EB7c 2.000.000.");
|
|
2067
|
+
}
|
|
2068
|
+
return {
|
|
2069
|
+
isValid: errors.length === 0,
|
|
2070
|
+
errors,
|
|
2071
|
+
data: errors.length === 0 ? {
|
|
2072
|
+
name,
|
|
2073
|
+
caType: 6,
|
|
2074
|
+
targeting: JSON.stringify({
|
|
2075
|
+
OriginAudience: originAudience,
|
|
2076
|
+
Total: total,
|
|
2077
|
+
Name: String(targetingObj.Name || "Lookalike Audience"),
|
|
2078
|
+
Path: String(targetingObj.Path || "")
|
|
2079
|
+
})
|
|
2080
|
+
} : void 0
|
|
2081
|
+
};
|
|
2082
|
+
}
|
|
2083
|
+
function validateCreateFormEventAudienceRequest(input) {
|
|
2084
|
+
const errors = [];
|
|
2085
|
+
if (!input || typeof input !== "object") {
|
|
2086
|
+
return { isValid: false, errors: ["Input ph\u1EA3i l\xE0 m\u1ED9t object."], data: void 0 };
|
|
2087
|
+
}
|
|
2088
|
+
const raw = input;
|
|
2089
|
+
const name = typeof raw.name === "string" ? raw.name.trim() : "";
|
|
2090
|
+
if (!name || name.length < 2 || name.length > 255) {
|
|
2091
|
+
errors.push("T\xEAn nh\xF3m \u0111\u1ED1i t\u01B0\u1EE3ng 'name' ph\u1EA3i t\u1EEB 2 \u0111\u1EBFn 255 k\xFD t\u1EF1.");
|
|
2092
|
+
}
|
|
2093
|
+
let targetingObj = {};
|
|
2094
|
+
if (typeof raw.targeting === "string") {
|
|
2095
|
+
try {
|
|
2096
|
+
targetingObj = JSON.parse(raw.targeting);
|
|
2097
|
+
} catch {
|
|
2098
|
+
errors.push("Tr\u01B0\u1EDDng 'targeting' l\xE0 chu\u1ED7i JSON kh\xF4ng h\u1EE3p l\u1EC7.");
|
|
2099
|
+
}
|
|
2100
|
+
} else if (raw.targeting && typeof raw.targeting === "object") {
|
|
2101
|
+
targetingObj = raw.targeting;
|
|
2102
|
+
}
|
|
2103
|
+
const eventType = Number(targetingObj.EventType);
|
|
2104
|
+
if (![1, 2, 3, 4].includes(eventType)) {
|
|
2105
|
+
errors.push("Tr\u01B0\u1EDDng 'EventType' ph\u1EA3i l\xE0 1 (\u0110\xE3 xem ch\u01B0a g\u1EEDi), 2 (\u0110\xE3 xem & g\u1EEDi), 3 (\u0110\xE3 xem), ho\u1EB7c 4 (M\u1EDF chat t\u1EEB Form).");
|
|
2106
|
+
}
|
|
2107
|
+
const oaId = typeof targetingObj.OaId === "string" ? targetingObj.OaId.trim() : String(targetingObj.OaId || "");
|
|
2108
|
+
if (!oaId) {
|
|
2109
|
+
errors.push("Tr\u01B0\u1EDDng 'OaId' (d\u1EA1ng chu\u1ED7i c\u1EE7a pageId ho\u1EB7c noisedId) l\xE0 b\u1EAFt bu\u1ED9c.");
|
|
2110
|
+
}
|
|
2111
|
+
const numDays = Number(targetingObj.NumDays);
|
|
2112
|
+
if (isNaN(numDays) || numDays < 1 || numDays > 90) {
|
|
2113
|
+
errors.push("Tr\u01B0\u1EDDng 'NumDays' ph\u1EA3i n\u1EB1m trong kho\u1EA3ng t\u1EEB 1 \u0111\u1EBFn 90 ng\xE0y.");
|
|
2114
|
+
}
|
|
2115
|
+
const formIds = Array.isArray(targetingObj.FormIds) ? targetingObj.FormIds : [];
|
|
2116
|
+
if (formIds.length === 0) {
|
|
2117
|
+
errors.push("Tr\u01B0\u1EDDng 'FormIds' ph\u1EA3i ch\u1EE9a \xEDt nh\u1EA5t 1 ID Form.");
|
|
2118
|
+
}
|
|
2119
|
+
return {
|
|
2120
|
+
isValid: errors.length === 0,
|
|
2121
|
+
errors,
|
|
2122
|
+
data: errors.length === 0 ? {
|
|
2123
|
+
name,
|
|
2124
|
+
caType: 12,
|
|
2125
|
+
targeting: JSON.stringify({
|
|
2126
|
+
EventType: eventType,
|
|
2127
|
+
OaId: oaId,
|
|
2128
|
+
NumDays: numDays,
|
|
2129
|
+
FormIds: formIds
|
|
2130
|
+
})
|
|
2131
|
+
} : void 0
|
|
2132
|
+
};
|
|
2133
|
+
}
|
|
2134
|
+
function validateCreateMessageOaEventAudienceRequest(input) {
|
|
2135
|
+
const errors = [];
|
|
2136
|
+
if (!input || typeof input !== "object") {
|
|
2137
|
+
return { isValid: false, errors: ["Input ph\u1EA3i l\xE0 m\u1ED9t object."], data: void 0 };
|
|
2138
|
+
}
|
|
2139
|
+
const raw = input;
|
|
2140
|
+
const name = typeof raw.name === "string" ? raw.name.trim() : "";
|
|
2141
|
+
if (!name || name.length < 2 || name.length > 255) {
|
|
2142
|
+
errors.push("T\xEAn nh\xF3m \u0111\u1ED1i t\u01B0\u1EE3ng 'name' ph\u1EA3i t\u1EEB 2 \u0111\u1EBFn 255 k\xFD t\u1EF1.");
|
|
2143
|
+
}
|
|
2144
|
+
let targetingObj = {};
|
|
2145
|
+
if (typeof raw.targeting === "string") {
|
|
2146
|
+
try {
|
|
2147
|
+
targetingObj = JSON.parse(raw.targeting);
|
|
2148
|
+
} catch {
|
|
2149
|
+
errors.push("Tr\u01B0\u1EDDng 'targeting' l\xE0 chu\u1ED7i JSON kh\xF4ng h\u1EE3p l\u1EC7.");
|
|
2150
|
+
}
|
|
2151
|
+
} else if (raw.targeting && typeof raw.targeting === "object") {
|
|
2152
|
+
targetingObj = raw.targeting;
|
|
2153
|
+
}
|
|
2154
|
+
const eventId = Number(targetingObj.EventId ?? targetingObj.EventType ?? 1);
|
|
2155
|
+
const oaId = typeof targetingObj.OaId === "string" ? targetingObj.OaId.trim() : String(targetingObj.OaId || "");
|
|
2156
|
+
if (!oaId) {
|
|
2157
|
+
errors.push("Tr\u01B0\u1EDDng 'OaId' (chu\u1ED7i pageId ho\u1EB7c noisedId c\u1EE7a OA) l\xE0 b\u1EAFt bu\u1ED9c.");
|
|
2158
|
+
}
|
|
2159
|
+
const numDays = Number(targetingObj.NumDays);
|
|
2160
|
+
if (isNaN(numDays) || numDays < 1 || numDays > 90) {
|
|
2161
|
+
errors.push("Tr\u01B0\u1EDDng 'NumDays' ph\u1EA3i n\u1EB1m trong kho\u1EA3ng t\u1EEB 1 \u0111\u1EBFn 90 ng\xE0y.");
|
|
2162
|
+
}
|
|
2163
|
+
return {
|
|
2164
|
+
isValid: errors.length === 0,
|
|
2165
|
+
errors,
|
|
2166
|
+
data: errors.length === 0 ? {
|
|
2167
|
+
name,
|
|
2168
|
+
caType: 11,
|
|
2169
|
+
targeting: JSON.stringify({
|
|
2170
|
+
EventId: eventId,
|
|
2171
|
+
OaId: oaId,
|
|
2172
|
+
NumDays: numDays
|
|
2173
|
+
})
|
|
2174
|
+
} : void 0
|
|
2175
|
+
};
|
|
2176
|
+
}
|
|
2177
|
+
function validateCreateMessagePersonalEventAudienceRequest(input) {
|
|
2178
|
+
const errors = [];
|
|
2179
|
+
if (!input || typeof input !== "object") {
|
|
2180
|
+
return { isValid: false, errors: ["Input ph\u1EA3i l\xE0 m\u1ED9t object."], data: void 0 };
|
|
2181
|
+
}
|
|
2182
|
+
const raw = input;
|
|
2183
|
+
const name = typeof raw.name === "string" ? raw.name.trim() : "";
|
|
2184
|
+
if (!name || name.length < 2 || name.length > 255) {
|
|
2185
|
+
errors.push("T\xEAn nh\xF3m \u0111\u1ED1i t\u01B0\u1EE3ng 'name' ph\u1EA3i t\u1EEB 2 \u0111\u1EBFn 255 k\xFD t\u1EF1.");
|
|
2186
|
+
}
|
|
2187
|
+
let targetingObj = {};
|
|
2188
|
+
if (typeof raw.targeting === "string") {
|
|
2189
|
+
try {
|
|
2190
|
+
targetingObj = JSON.parse(raw.targeting);
|
|
2191
|
+
} catch {
|
|
2192
|
+
errors.push("Tr\u01B0\u1EDDng 'targeting' l\xE0 chu\u1ED7i JSON kh\xF4ng h\u1EE3p l\u1EC7.");
|
|
2193
|
+
}
|
|
2194
|
+
} else if (raw.targeting && typeof raw.targeting === "object") {
|
|
2195
|
+
targetingObj = raw.targeting;
|
|
2196
|
+
}
|
|
2197
|
+
const eventId = Number(targetingObj.EventId ?? targetingObj.EventType ?? 1);
|
|
2198
|
+
if (![1, 2, 3].includes(eventId)) {
|
|
2199
|
+
errors.push("Tr\u01B0\u1EDDng 'EventId' ph\u1EA3i l\xE0 1 (\u0110\xE3 li\xEAn h\u1EC7), 2 (\u0110\xE3 xem kh\xF4ng li\xEAn h\u1EC7), ho\u1EB7c 3 (Xem carousel kh\xF4ng li\xEAn h\u1EC7).");
|
|
2200
|
+
}
|
|
2201
|
+
const numDays = Number(targetingObj.NumDays);
|
|
2202
|
+
if (isNaN(numDays) || numDays < 1 || numDays > 90) {
|
|
2203
|
+
errors.push("Tr\u01B0\u1EDDng 'NumDays' ph\u1EA3i n\u1EB1m trong kho\u1EA3ng t\u1EEB 1 \u0111\u1EBFn 90 ng\xE0y.");
|
|
2204
|
+
}
|
|
2205
|
+
const pageIds = Array.isArray(targetingObj.PageIds) ? targetingObj.PageIds.map(String) : [];
|
|
2206
|
+
if (pageIds.length === 0) {
|
|
2207
|
+
errors.push("Tr\u01B0\u1EDDng 'PageIds' ph\u1EA3i ch\u1EE9a \xEDt nh\u1EA5t 1 ID trang c\xE1 nh\xE2n.");
|
|
2208
|
+
}
|
|
2209
|
+
return {
|
|
2210
|
+
isValid: errors.length === 0,
|
|
2211
|
+
errors,
|
|
2212
|
+
data: errors.length === 0 ? {
|
|
2213
|
+
name,
|
|
2214
|
+
caType: 14,
|
|
2215
|
+
targeting: JSON.stringify({
|
|
2216
|
+
EventId: eventId,
|
|
2217
|
+
NumDays: numDays,
|
|
2218
|
+
PageIds: pageIds
|
|
2219
|
+
})
|
|
2220
|
+
} : void 0
|
|
2221
|
+
};
|
|
2222
|
+
}
|
|
2223
|
+
function validateEstimateAudienceRequest(input) {
|
|
2224
|
+
const errors = [];
|
|
2225
|
+
if (!input || typeof input !== "object") {
|
|
2226
|
+
return { isValid: false, errors: ["Input ph\u1EA3i l\xE0 m\u1ED9t object."], data: void 0 };
|
|
2227
|
+
}
|
|
2228
|
+
const raw = input;
|
|
2229
|
+
const gender = typeof raw.gender === "number" ? raw.gender : 0;
|
|
2230
|
+
if (![0, 1, 2].includes(gender)) {
|
|
2231
|
+
errors.push("Tr\u01B0\u1EDDng 'gender' ph\u1EA3i l\xE0 0, 1 ho\u1EB7c 2.");
|
|
2232
|
+
}
|
|
2233
|
+
const ageRanges = Array.isArray(raw.ageRanges) && raw.ageRanges.length > 0 ? raw.ageRanges.map(Number) : [10283, 10284, 10285, 10286, 10287];
|
|
2234
|
+
const platforms = Array.isArray(raw.platforms) && raw.platforms.length > 0 ? raw.platforms.map(Number) : [0, 1, 3];
|
|
2235
|
+
const priceType = typeof raw.priceType === "number" ? raw.priceType : 2;
|
|
2236
|
+
const wardsTargeting = typeof raw.wardsTargeting === "string" && raw.wardsTargeting.trim() ? raw.wardsTargeting.trim() : JSON.stringify({ Includes: [], Excludes: [] });
|
|
2237
|
+
return {
|
|
2238
|
+
isValid: errors.length === 0,
|
|
2239
|
+
errors,
|
|
2240
|
+
data: errors.length === 0 ? {
|
|
2241
|
+
gender,
|
|
2242
|
+
ageRanges,
|
|
2243
|
+
platforms,
|
|
2244
|
+
locations: typeof raw.locations === "string" ? raw.locations : "",
|
|
2245
|
+
provinces: Array.isArray(raw.provinces) ? raw.provinces.map(Number) : [],
|
|
2246
|
+
wardsTargeting,
|
|
2247
|
+
priceType,
|
|
2248
|
+
number: typeof raw.number === "string" ? raw.number : String(raw.number || "0")
|
|
2249
|
+
} : void 0
|
|
2250
|
+
};
|
|
2251
|
+
}
|
|
2252
|
+
var ZaloAudiencesValidator = {
|
|
2253
|
+
createSavedAudience: validateCreateSavedAudienceRequest,
|
|
2254
|
+
createPhoneAudience: validateCreatePhoneAudienceRequest,
|
|
2255
|
+
createLookalikeAudience: validateCreateLookalikeAudienceRequest,
|
|
2256
|
+
createFormEventAudience: validateCreateFormEventAudienceRequest,
|
|
2257
|
+
createMessageOaEventAudience: validateCreateMessageOaEventAudienceRequest,
|
|
2258
|
+
createMessagePersonalEventAudience: validateCreateMessagePersonalEventAudienceRequest,
|
|
2259
|
+
estimateAudience: validateEstimateAudienceRequest
|
|
2260
|
+
};
|
|
2261
|
+
|
|
2262
|
+
// src/services/audiences.service.ts
|
|
2263
|
+
var OP_ZaloAdsCreateCustomAudience = {
|
|
2264
|
+
"operationId": "ZaloAds_createCustomAudience",
|
|
2265
|
+
"method": "POST",
|
|
2266
|
+
"endpoint": "/api/ad/audience",
|
|
2267
|
+
"baseUrl": "https://ads.zalo.me",
|
|
2268
|
+
"binaryFields": [],
|
|
2269
|
+
"pathFields": [],
|
|
2270
|
+
"queryFields": [],
|
|
2271
|
+
"headerFields": [],
|
|
2272
|
+
"cookieFields": [],
|
|
2273
|
+
"bodyFields": [
|
|
2274
|
+
"name",
|
|
2275
|
+
"caType",
|
|
2276
|
+
"targeting"
|
|
2277
|
+
]
|
|
2278
|
+
};
|
|
2279
|
+
var OP_ZaloAdsDeleteCustomAudience = {
|
|
2280
|
+
"operationId": "ZaloAds_deleteCustomAudience",
|
|
2281
|
+
"method": "DELETE",
|
|
2282
|
+
"endpoint": "/api/ad/audience/{customAudienceId}",
|
|
2283
|
+
"baseUrl": "https://ads.zalo.me",
|
|
2284
|
+
"binaryFields": [],
|
|
2285
|
+
"pathFields": [
|
|
2286
|
+
"customAudienceId"
|
|
2287
|
+
],
|
|
2288
|
+
"queryFields": [],
|
|
2289
|
+
"headerFields": [],
|
|
2290
|
+
"cookieFields": [],
|
|
2291
|
+
"bodyFields": []
|
|
2292
|
+
};
|
|
2293
|
+
var OP_ZaloAdsGetApiAdGetlistadadvancetargeting = {
|
|
2294
|
+
"operationId": "ZaloAds_getApiAdGetlistadadvancetargeting",
|
|
2295
|
+
"method": "GET",
|
|
2296
|
+
"endpoint": "/api/ad/getListAdAdvanceTargeting",
|
|
1689
2297
|
"baseUrl": "https://ads.zalo.me",
|
|
1690
2298
|
"binaryFields": [],
|
|
1691
2299
|
"pathFields": [],
|
|
@@ -1694,6 +2302,20 @@ var OP_ZaloAdsListPersonalPixelLabels = {
|
|
|
1694
2302
|
"cookieFields": [],
|
|
1695
2303
|
"bodyFields": []
|
|
1696
2304
|
};
|
|
2305
|
+
var OP_ZaloAdsGetApiCustomAudienceAll = {
|
|
2306
|
+
"operationId": "ZaloAds_getApiCustomAudienceAll",
|
|
2307
|
+
"method": "GET",
|
|
2308
|
+
"endpoint": "/api/custom-audience/all",
|
|
2309
|
+
"baseUrl": "https://ads.zalo.me",
|
|
2310
|
+
"binaryFields": [],
|
|
2311
|
+
"pathFields": [],
|
|
2312
|
+
"queryFields": [
|
|
2313
|
+
"newWard"
|
|
2314
|
+
],
|
|
2315
|
+
"headerFields": [],
|
|
2316
|
+
"cookieFields": [],
|
|
2317
|
+
"bodyFields": []
|
|
2318
|
+
};
|
|
1697
2319
|
var OP_ZaloAdsPostApiAdEstimateaudience = {
|
|
1698
2320
|
"operationId": "ZaloAds_postApiAdEstimateaudience",
|
|
1699
2321
|
"method": "POST",
|
|
@@ -1716,177 +2338,302 @@ var OP_ZaloAdsPostApiAdEstimateaudience = {
|
|
|
1716
2338
|
"districtsTargeting"
|
|
1717
2339
|
]
|
|
1718
2340
|
};
|
|
1719
|
-
var
|
|
1720
|
-
"operationId": "
|
|
2341
|
+
var OP_ZaloAdsUploadCustomAudiencePhoneList = {
|
|
2342
|
+
"operationId": "ZaloAds_uploadCustomAudiencePhoneList",
|
|
1721
2343
|
"method": "POST",
|
|
1722
|
-
"endpoint": "/
|
|
2344
|
+
"endpoint": "/zaapi/uploadPhoneList",
|
|
1723
2345
|
"baseUrl": "https://ads.zalo.me",
|
|
1724
|
-
"binaryFields": [
|
|
2346
|
+
"binaryFields": [
|
|
2347
|
+
"File"
|
|
2348
|
+
],
|
|
1725
2349
|
"pathFields": [],
|
|
1726
2350
|
"queryFields": [],
|
|
1727
2351
|
"headerFields": [],
|
|
1728
2352
|
"cookieFields": [],
|
|
1729
2353
|
"bodyFields": [
|
|
1730
|
-
"
|
|
2354
|
+
"File",
|
|
2355
|
+
"isHash"
|
|
1731
2356
|
]
|
|
1732
2357
|
};
|
|
1733
|
-
var
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
2358
|
+
var ZaloAudiencesService = class {
|
|
2359
|
+
constructor(client) {
|
|
2360
|
+
this.client = client;
|
|
2361
|
+
}
|
|
2362
|
+
static validator = ZaloAudiencesValidator;
|
|
2363
|
+
postApiAdEstimateaudience(request, options) {
|
|
2364
|
+
return this.client.requestJson(OP_ZaloAdsPostApiAdEstimateaudience, this.client.toTransportInput(OP_ZaloAdsPostApiAdEstimateaudience, request), options);
|
|
2365
|
+
}
|
|
2366
|
+
getApiAdGetlistadadvancetargeting(request = {}, options) {
|
|
2367
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetApiAdGetlistadadvancetargeting, this.client.toTransportInput(OP_ZaloAdsGetApiAdGetlistadadvancetargeting, request), options);
|
|
2368
|
+
}
|
|
2369
|
+
getApiCustomAudienceAll(request = {}, options) {
|
|
2370
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetApiCustomAudienceAll, this.client.toTransportInput(OP_ZaloAdsGetApiCustomAudienceAll, request), options);
|
|
2371
|
+
}
|
|
2372
|
+
createCustomAudience(request, options) {
|
|
2373
|
+
return this.client.requestJson(OP_ZaloAdsCreateCustomAudience, this.client.toTransportInput(OP_ZaloAdsCreateCustomAudience, request), options);
|
|
2374
|
+
}
|
|
2375
|
+
deleteCustomAudience(request, options) {
|
|
2376
|
+
return this.client.requestWithoutBody(OP_ZaloAdsDeleteCustomAudience, this.client.toTransportInput(OP_ZaloAdsDeleteCustomAudience, request), options);
|
|
2377
|
+
}
|
|
2378
|
+
uploadCustomAudiencePhoneList(request, options) {
|
|
2379
|
+
return this.client.requestMultipart(OP_ZaloAdsUploadCustomAudiencePhoneList, this.client.toTransportInput(OP_ZaloAdsUploadCustomAudiencePhoneList, request), options);
|
|
2380
|
+
}
|
|
2381
|
+
/** Tạo mới 'Nhóm đối tượng đã lưu' (`caType = 1` - `DEFAULT`) trên Zalo Ads (`POST /api/ad/audience`). */
|
|
2382
|
+
createSavedAudience(request, options) {
|
|
2383
|
+
const targetingStr = typeof request.targeting === "string" ? request.targeting : JSON.stringify(request.targeting);
|
|
2384
|
+
return this.createCustomAudience(
|
|
2385
|
+
{
|
|
2386
|
+
name: request.name,
|
|
2387
|
+
caType: 1,
|
|
2388
|
+
targeting: targetingStr
|
|
2389
|
+
},
|
|
2390
|
+
options
|
|
2391
|
+
);
|
|
2392
|
+
}
|
|
2393
|
+
/** Tạo mới Nhóm đối tượng từ danh sách Số điện thoại (`caType = 3` - `PHONE_LIST`). */
|
|
2394
|
+
createPhoneAudience(request, options) {
|
|
2395
|
+
const targetingStr = typeof request.targeting === "string" ? request.targeting : JSON.stringify(request.targeting);
|
|
2396
|
+
return this.createCustomAudience({ name: request.name, caType: 3, targeting: targetingStr }, options);
|
|
2397
|
+
}
|
|
2398
|
+
/** Tạo mới Nhóm đối tượng tương tự Lookalike (`caType = 6` - `LOOKALIKE`). */
|
|
2399
|
+
createLookalikeAudience(request, options) {
|
|
2400
|
+
const targetingStr = typeof request.targeting === "string" ? request.targeting : JSON.stringify(request.targeting);
|
|
2401
|
+
return this.createCustomAudience({ name: request.name, caType: 6, targeting: targetingStr }, options);
|
|
2402
|
+
}
|
|
2403
|
+
/** Tạo mới Nhóm đối tượng phát sinh sự kiện trên Zalo Form (`caType = 12` - `FORM_EVENT_AUDIENCE`). */
|
|
2404
|
+
createFormEventAudience(request, options) {
|
|
2405
|
+
const targetingStr = typeof request.targeting === "string" ? request.targeting : JSON.stringify(request.targeting);
|
|
2406
|
+
return this.createCustomAudience({ name: request.name, caType: 12, targeting: targetingStr }, options);
|
|
2407
|
+
}
|
|
2408
|
+
/** Tạo mới Nhóm đối tượng phát sinh sự kiện trên Kịch bản Tin nhắn OA (`caType = 11` - `MESSAGE_AUDIENCE`). */
|
|
2409
|
+
createMessageOaEventAudience(request, options) {
|
|
2410
|
+
const targetingStr = typeof request.targeting === "string" ? request.targeting : JSON.stringify(request.targeting);
|
|
2411
|
+
return this.createCustomAudience({ name: request.name, caType: 11, targeting: targetingStr }, options);
|
|
2412
|
+
}
|
|
2413
|
+
/** Tạo mới Nhóm đối tượng phát sinh sự kiện trên Kịch bản Tin nhắn cá nhân (`caType = 14` - `MESSAGE_PERSONAL_EVENT_AUDIENCE`). */
|
|
2414
|
+
createMessagePersonalEventAudience(request, options) {
|
|
2415
|
+
let targetingObj;
|
|
2416
|
+
if (typeof request.targeting === "string") {
|
|
2417
|
+
try {
|
|
2418
|
+
targetingObj = JSON.parse(request.targeting);
|
|
2419
|
+
} catch {
|
|
2420
|
+
targetingObj = null;
|
|
2421
|
+
}
|
|
2422
|
+
} else if (request.targeting && typeof request.targeting === "object") {
|
|
2423
|
+
targetingObj = { ...request.targeting };
|
|
2424
|
+
}
|
|
2425
|
+
if (targetingObj && typeof targetingObj === "object") {
|
|
2426
|
+
if (targetingObj.EventId === void 0 && targetingObj.EventType !== void 0) {
|
|
2427
|
+
targetingObj.EventId = targetingObj.EventType;
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
const targetingStr = targetingObj ? JSON.stringify(targetingObj) : typeof request.targeting === "string" ? request.targeting : JSON.stringify(request.targeting);
|
|
2431
|
+
return this.createCustomAudience({ name: request.name, caType: 14, targeting: targetingStr }, options);
|
|
2432
|
+
}
|
|
2433
|
+
/** Tạo mới Nhóm đối tượng từ Trung tâm Lead - Zalo Form (`caType = 10` - `FORM_AUDIENCE`). */
|
|
2434
|
+
createFormLeadAudience(request, options) {
|
|
2435
|
+
const targetingStr = typeof request.targeting === "string" ? request.targeting : JSON.stringify(request.targeting);
|
|
2436
|
+
return this.createCustomAudience({ name: request.name, caType: 10, targeting: targetingStr }, options);
|
|
2437
|
+
}
|
|
2438
|
+
/** Tạo mới Nhóm đối tượng từ Trung tâm Lead - Commerce Form (`caType = 15` - `COMMERCE_FORM_AUDIENCE`). */
|
|
2439
|
+
createCommerceFormAudience(request, options) {
|
|
2440
|
+
const targetingStr = typeof request.targeting === "string" ? request.targeting : JSON.stringify(request.targeting);
|
|
2441
|
+
return this.createCustomAudience({ name: request.name, caType: 15, targeting: targetingStr }, options);
|
|
2442
|
+
}
|
|
2443
|
+
/** Tạo mới Nhóm đối tượng từ Trung tâm Lead - Kịch bản Tin nhắn OA (`caType = 13` - `MESSAGE_OA_AUDIENCE`). */
|
|
2444
|
+
createMessageOaLeadAudience(request, options) {
|
|
2445
|
+
const targetingStr = typeof request.targeting === "string" ? request.targeting : JSON.stringify(request.targeting);
|
|
2446
|
+
return this.createCustomAudience({ name: request.name, caType: 13, targeting: targetingStr }, options);
|
|
2447
|
+
}
|
|
2448
|
+
/** Tạo mới Nhóm đối tượng từ Dữ liệu chuyển đổi Lead Signal (`caType = 16` - `LEAD_SIGNAL_AUDIENCE`). */
|
|
2449
|
+
createLeadSignalAudience(request, options) {
|
|
2450
|
+
const targetingStr = typeof request.targeting === "string" ? request.targeting : JSON.stringify(request.targeting);
|
|
2451
|
+
return this.createCustomAudience({ name: request.name, caType: 16, targeting: targetingStr }, options);
|
|
2452
|
+
}
|
|
2453
|
+
/** Ước tính quy mô đối tượng tiếp cận */
|
|
2454
|
+
estimateAudience(...args) {
|
|
2455
|
+
return this.postApiAdEstimateaudience(...args);
|
|
2456
|
+
}
|
|
2457
|
+
/** Danh sách toàn bộ nhóm đối tượng tùy chỉnh */
|
|
2458
|
+
listCustomAudiences(...args) {
|
|
2459
|
+
return this.getApiCustomAudienceAll(...args);
|
|
2460
|
+
}
|
|
2461
|
+
/** Danh sách cấu hình nhắm mục tiêu nâng cao */
|
|
2462
|
+
getListAdAdvanceTargeting(...args) {
|
|
2463
|
+
return this.getApiAdGetlistadadvancetargeting(...args);
|
|
2464
|
+
}
|
|
2465
|
+
};
|
|
2466
|
+
|
|
2467
|
+
// src/services/reports.service.ts
|
|
2468
|
+
var OP_ZaloAdsGetReportapiV2Ads = {
|
|
2469
|
+
"operationId": "ZaloAds_getReportapiV2Ads",
|
|
2470
|
+
"method": "GET",
|
|
2471
|
+
"endpoint": "/reportapi/v2/ads",
|
|
1737
2472
|
"baseUrl": "https://ads.zalo.me",
|
|
1738
|
-
"binaryFields": [
|
|
1739
|
-
"File"
|
|
1740
|
-
],
|
|
2473
|
+
"binaryFields": [],
|
|
1741
2474
|
"pathFields": [],
|
|
1742
|
-
"queryFields": [
|
|
2475
|
+
"queryFields": [
|
|
2476
|
+
"to",
|
|
2477
|
+
"from",
|
|
2478
|
+
"filter",
|
|
2479
|
+
"endDate",
|
|
2480
|
+
"refresh",
|
|
2481
|
+
"breakdown",
|
|
2482
|
+
"startDate"
|
|
2483
|
+
],
|
|
1743
2484
|
"headerFields": [],
|
|
1744
2485
|
"cookieFields": [],
|
|
1745
|
-
"bodyFields": [
|
|
1746
|
-
"File"
|
|
1747
|
-
]
|
|
2486
|
+
"bodyFields": []
|
|
1748
2487
|
};
|
|
1749
|
-
var
|
|
1750
|
-
"operationId": "
|
|
1751
|
-
"method": "
|
|
1752
|
-
"endpoint": "/
|
|
2488
|
+
var OP_ZaloAdsGetReportapiV2Campaigns = {
|
|
2489
|
+
"operationId": "ZaloAds_getReportapiV2Campaigns",
|
|
2490
|
+
"method": "GET",
|
|
2491
|
+
"endpoint": "/reportapi/v2/campaigns/{campaignId}",
|
|
2492
|
+
"baseUrl": "https://ads.zalo.me",
|
|
2493
|
+
"binaryFields": [],
|
|
2494
|
+
"pathFields": [
|
|
2495
|
+
"campaignId"
|
|
2496
|
+
],
|
|
2497
|
+
"queryFields": [
|
|
2498
|
+
"startDate",
|
|
2499
|
+
"endDate",
|
|
2500
|
+
"refresh"
|
|
2501
|
+
],
|
|
2502
|
+
"headerFields": [],
|
|
2503
|
+
"cookieFields": [],
|
|
2504
|
+
"bodyFields": []
|
|
2505
|
+
};
|
|
2506
|
+
var OP_ZaloAdsGetReportapiV2UniqueUser = {
|
|
2507
|
+
"operationId": "ZaloAds_getReportapiV2UniqueUser",
|
|
2508
|
+
"method": "GET",
|
|
2509
|
+
"endpoint": "/reportapi/v2/unique-user",
|
|
1753
2510
|
"baseUrl": "https://ads.zalo.me",
|
|
1754
2511
|
"binaryFields": [],
|
|
1755
2512
|
"pathFields": [],
|
|
1756
2513
|
"queryFields": [
|
|
2514
|
+
"start",
|
|
2515
|
+
"end",
|
|
2516
|
+
"campaignId",
|
|
1757
2517
|
"adId"
|
|
1758
2518
|
],
|
|
1759
2519
|
"headerFields": [],
|
|
1760
2520
|
"cookieFields": [],
|
|
1761
|
-
"bodyFields": [
|
|
1762
|
-
"adId"
|
|
1763
|
-
]
|
|
2521
|
+
"bodyFields": []
|
|
1764
2522
|
};
|
|
1765
|
-
var
|
|
1766
|
-
"operationId": "
|
|
1767
|
-
"method": "
|
|
1768
|
-
"endpoint": "/
|
|
2523
|
+
var OP_ZaloAdsGetReportapiV3Campaigns = {
|
|
2524
|
+
"operationId": "ZaloAds_getReportapiV3Campaigns",
|
|
2525
|
+
"method": "GET",
|
|
2526
|
+
"endpoint": "/reportapi/v3/campaigns",
|
|
1769
2527
|
"baseUrl": "https://ads.zalo.me",
|
|
1770
2528
|
"binaryFields": [],
|
|
1771
2529
|
"pathFields": [],
|
|
1772
|
-
"queryFields": [
|
|
2530
|
+
"queryFields": [
|
|
2531
|
+
"filter",
|
|
2532
|
+
"endDate",
|
|
2533
|
+
"refresh",
|
|
2534
|
+
"agencyId",
|
|
2535
|
+
"createdBy",
|
|
2536
|
+
"startDate"
|
|
2537
|
+
],
|
|
1773
2538
|
"headerFields": [],
|
|
1774
2539
|
"cookieFields": [],
|
|
1775
|
-
"bodyFields": [
|
|
1776
|
-
"campid",
|
|
1777
|
-
"newname"
|
|
1778
|
-
]
|
|
2540
|
+
"bodyFields": []
|
|
1779
2541
|
};
|
|
1780
|
-
var
|
|
1781
|
-
"operationId": "
|
|
1782
|
-
"method": "
|
|
1783
|
-
"endpoint": "/
|
|
2542
|
+
var OP_ZaloAdsGetReportOverview = {
|
|
2543
|
+
"operationId": "ZaloAds_getReportOverview",
|
|
2544
|
+
"method": "GET",
|
|
2545
|
+
"endpoint": "/reportapi/report/overview",
|
|
1784
2546
|
"baseUrl": "https://ads.zalo.me",
|
|
1785
2547
|
"binaryFields": [],
|
|
1786
2548
|
"pathFields": [],
|
|
1787
|
-
"queryFields": [
|
|
2549
|
+
"queryFields": [
|
|
2550
|
+
"data"
|
|
2551
|
+
],
|
|
1788
2552
|
"headerFields": [],
|
|
1789
2553
|
"cookieFields": [],
|
|
1790
|
-
"bodyFields": [
|
|
1791
|
-
"est",
|
|
1792
|
-
"stt",
|
|
1793
|
-
"data",
|
|
1794
|
-
"isBoostAd"
|
|
1795
|
-
]
|
|
2554
|
+
"bodyFields": []
|
|
1796
2555
|
};
|
|
1797
|
-
var
|
|
1798
|
-
"operationId": "
|
|
1799
|
-
"method": "
|
|
1800
|
-
"endpoint": "/
|
|
2556
|
+
var OP_ZaloAdsGetDemographicsReport = {
|
|
2557
|
+
"operationId": "ZaloAds_getDemographicsReport",
|
|
2558
|
+
"method": "GET",
|
|
2559
|
+
"endpoint": "/api/demographics/report",
|
|
1801
2560
|
"baseUrl": "https://ads.zalo.me",
|
|
1802
2561
|
"binaryFields": [],
|
|
1803
2562
|
"pathFields": [],
|
|
1804
|
-
"queryFields": [
|
|
2563
|
+
"queryFields": [
|
|
2564
|
+
"campaignId",
|
|
2565
|
+
"adId",
|
|
2566
|
+
"startDate",
|
|
2567
|
+
"endDate",
|
|
2568
|
+
"agencyId",
|
|
2569
|
+
"from",
|
|
2570
|
+
"to"
|
|
2571
|
+
],
|
|
1805
2572
|
"headerFields": [],
|
|
1806
2573
|
"cookieFields": [],
|
|
1807
|
-
"bodyFields": [
|
|
1808
|
-
"est",
|
|
1809
|
-
"stt",
|
|
1810
|
-
"data",
|
|
1811
|
-
"isBoostAd"
|
|
1812
|
-
]
|
|
2574
|
+
"bodyFields": []
|
|
1813
2575
|
};
|
|
1814
|
-
var
|
|
1815
|
-
"operationId": "
|
|
2576
|
+
var OP_ZaloAdsDeleteCustomReport = {
|
|
2577
|
+
"operationId": "ZaloAds_deleteCustomReport",
|
|
1816
2578
|
"method": "POST",
|
|
1817
|
-
"endpoint": "/
|
|
2579
|
+
"endpoint": "/reportapi/custom-report/delete/{id}",
|
|
1818
2580
|
"baseUrl": "https://ads.zalo.me",
|
|
1819
2581
|
"binaryFields": [],
|
|
1820
|
-
"pathFields": [
|
|
2582
|
+
"pathFields": [
|
|
2583
|
+
"id"
|
|
2584
|
+
],
|
|
1821
2585
|
"queryFields": [],
|
|
1822
2586
|
"headerFields": [],
|
|
1823
2587
|
"cookieFields": [],
|
|
1824
|
-
"bodyFields": [
|
|
1825
|
-
"est",
|
|
1826
|
-
"stt",
|
|
1827
|
-
"data",
|
|
1828
|
-
"isBoostAd"
|
|
1829
|
-
]
|
|
2588
|
+
"bodyFields": []
|
|
1830
2589
|
};
|
|
1831
|
-
var
|
|
1832
|
-
"operationId": "
|
|
1833
|
-
"method": "
|
|
1834
|
-
"endpoint": "/
|
|
2590
|
+
var OP_ZaloAdsListReportFilters = {
|
|
2591
|
+
"operationId": "ZaloAds_listReportFilters",
|
|
2592
|
+
"method": "GET",
|
|
2593
|
+
"endpoint": "/reportapi/api/filter/list",
|
|
1835
2594
|
"baseUrl": "https://ads.zalo.me",
|
|
1836
|
-
"binaryFields": [
|
|
1837
|
-
"File"
|
|
1838
|
-
],
|
|
2595
|
+
"binaryFields": [],
|
|
1839
2596
|
"pathFields": [],
|
|
1840
|
-
"queryFields": [
|
|
2597
|
+
"queryFields": [
|
|
2598
|
+
"model"
|
|
2599
|
+
],
|
|
1841
2600
|
"headerFields": [],
|
|
1842
2601
|
"cookieFields": [],
|
|
1843
|
-
"bodyFields": [
|
|
1844
|
-
"File",
|
|
1845
|
-
"x",
|
|
1846
|
-
"y",
|
|
1847
|
-
"width",
|
|
1848
|
-
"height",
|
|
1849
|
-
"scale"
|
|
1850
|
-
]
|
|
2602
|
+
"bodyFields": []
|
|
1851
2603
|
};
|
|
1852
|
-
var
|
|
1853
|
-
"operationId": "
|
|
1854
|
-
"method": "
|
|
1855
|
-
"endpoint": "/zaapi/
|
|
2604
|
+
var OP_ZaloAdsGetZaapiCampaignReportcampaign = {
|
|
2605
|
+
"operationId": "ZaloAds_getZaapiCampaignReportcampaign",
|
|
2606
|
+
"method": "GET",
|
|
2607
|
+
"endpoint": "/zaapi/Campaign/reportCampaign",
|
|
1856
2608
|
"baseUrl": "https://ads.zalo.me",
|
|
1857
2609
|
"binaryFields": [],
|
|
1858
2610
|
"pathFields": [],
|
|
1859
|
-
"queryFields": [
|
|
2611
|
+
"queryFields": [
|
|
2612
|
+
"campaignId",
|
|
2613
|
+
"campId",
|
|
2614
|
+
"from",
|
|
2615
|
+
"to"
|
|
2616
|
+
],
|
|
1860
2617
|
"headerFields": [],
|
|
1861
2618
|
"cookieFields": [],
|
|
1862
|
-
"bodyFields": [
|
|
1863
|
-
"est",
|
|
1864
|
-
"stt",
|
|
1865
|
-
"data",
|
|
1866
|
-
"isBoostAd"
|
|
1867
|
-
]
|
|
2619
|
+
"bodyFields": []
|
|
1868
2620
|
};
|
|
1869
|
-
var
|
|
1870
|
-
"operationId": "
|
|
1871
|
-
"method": "
|
|
1872
|
-
"endpoint": "/
|
|
2621
|
+
var OP_ZaloAdsListCustomReports = {
|
|
2622
|
+
"operationId": "ZaloAds_listCustomReports",
|
|
2623
|
+
"method": "GET",
|
|
2624
|
+
"endpoint": "/reportapi/custom-report/list",
|
|
1873
2625
|
"baseUrl": "https://ads.zalo.me",
|
|
1874
2626
|
"binaryFields": [],
|
|
1875
2627
|
"pathFields": [],
|
|
1876
2628
|
"queryFields": [],
|
|
1877
2629
|
"headerFields": [],
|
|
1878
2630
|
"cookieFields": [],
|
|
1879
|
-
"bodyFields": [
|
|
1880
|
-
"est",
|
|
1881
|
-
"stt",
|
|
1882
|
-
"data",
|
|
1883
|
-
"isBoostAd"
|
|
1884
|
-
]
|
|
2631
|
+
"bodyFields": []
|
|
1885
2632
|
};
|
|
1886
|
-
var
|
|
1887
|
-
"operationId": "
|
|
2633
|
+
var OP_ZaloAdsUpsertCustomReport = {
|
|
2634
|
+
"operationId": "ZaloAds_upsertCustomReport",
|
|
1888
2635
|
"method": "POST",
|
|
1889
|
-
"endpoint": "/
|
|
2636
|
+
"endpoint": "/reportapi/custom-report/update",
|
|
1890
2637
|
"baseUrl": "https://ads.zalo.me",
|
|
1891
2638
|
"binaryFields": [],
|
|
1892
2639
|
"pathFields": [],
|
|
@@ -1894,13 +2641,81 @@ var OP_ZaloAdsCreateWebsiteCampaign = {
|
|
|
1894
2641
|
"headerFields": [],
|
|
1895
2642
|
"cookieFields": [],
|
|
1896
2643
|
"bodyFields": [
|
|
1897
|
-
"
|
|
2644
|
+
"id",
|
|
2645
|
+
"name",
|
|
2646
|
+
"settings",
|
|
2647
|
+
"isDefault"
|
|
1898
2648
|
]
|
|
1899
2649
|
};
|
|
1900
|
-
var
|
|
1901
|
-
|
|
2650
|
+
var ZaloReportsService = class {
|
|
2651
|
+
constructor(client) {
|
|
2652
|
+
this.client = client;
|
|
2653
|
+
}
|
|
2654
|
+
getReportapiV2Ads(request, options) {
|
|
2655
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetReportapiV2Ads, this.client.toTransportInput(OP_ZaloAdsGetReportapiV2Ads, request), options);
|
|
2656
|
+
}
|
|
2657
|
+
getReportapiV2Campaigns(request = {}, options) {
|
|
2658
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetReportapiV2Campaigns, this.client.toTransportInput(OP_ZaloAdsGetReportapiV2Campaigns, request), options);
|
|
2659
|
+
}
|
|
2660
|
+
getReportapiV2UniqueUser(request, options) {
|
|
2661
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetReportapiV2UniqueUser, this.client.toTransportInput(OP_ZaloAdsGetReportapiV2UniqueUser, request), options);
|
|
2662
|
+
}
|
|
2663
|
+
getReportapiV3Campaigns(request, options) {
|
|
2664
|
+
const normalized = {
|
|
2665
|
+
filter: "[]",
|
|
2666
|
+
agencyId: 0,
|
|
2667
|
+
...request
|
|
2668
|
+
};
|
|
2669
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetReportapiV3Campaigns, this.client.toTransportInput(OP_ZaloAdsGetReportapiV3Campaigns, normalized), options);
|
|
2670
|
+
}
|
|
2671
|
+
getReportOverview(request, options) {
|
|
2672
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetReportOverview, this.client.toTransportInput(OP_ZaloAdsGetReportOverview, request), options);
|
|
2673
|
+
}
|
|
2674
|
+
getDemographicsReport(request, options) {
|
|
2675
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetDemographicsReport, this.client.toTransportInput(OP_ZaloAdsGetDemographicsReport, request), options);
|
|
2676
|
+
}
|
|
2677
|
+
getZaapiCampaignReportcampaign(request, options) {
|
|
2678
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetZaapiCampaignReportcampaign, this.client.toTransportInput(OP_ZaloAdsGetZaapiCampaignReportcampaign, request), options);
|
|
2679
|
+
}
|
|
2680
|
+
listCustomReports(request = {}, options) {
|
|
2681
|
+
return this.client.requestWithoutBody(OP_ZaloAdsListCustomReports, this.client.toTransportInput(OP_ZaloAdsListCustomReports, request), options);
|
|
2682
|
+
}
|
|
2683
|
+
upsertCustomReport(request, options) {
|
|
2684
|
+
return this.client.requestJson(OP_ZaloAdsUpsertCustomReport, this.client.toTransportInput(OP_ZaloAdsUpsertCustomReport, request), options);
|
|
2685
|
+
}
|
|
2686
|
+
deleteCustomReport(request, options) {
|
|
2687
|
+
return this.client.requestJson(OP_ZaloAdsDeleteCustomReport, this.client.toTransportInput(OP_ZaloAdsDeleteCustomReport, request), options);
|
|
2688
|
+
}
|
|
2689
|
+
listReportFilters(request, options) {
|
|
2690
|
+
return this.client.requestWithoutBody(OP_ZaloAdsListReportFilters, this.client.toTransportInput(OP_ZaloAdsListReportFilters, request), options);
|
|
2691
|
+
}
|
|
2692
|
+
/** Báo cáo hiệu quả chiến dịch (API V3 - Khuyên dùng) */
|
|
2693
|
+
getCampaignReportV3(...args) {
|
|
2694
|
+
return this.getReportapiV3Campaigns(...args);
|
|
2695
|
+
}
|
|
2696
|
+
/** Báo cáo hiệu quả chiến dịch (API V2) */
|
|
2697
|
+
getCampaignReportV2(...args) {
|
|
2698
|
+
return this.getReportapiV2Campaigns(...args);
|
|
2699
|
+
}
|
|
2700
|
+
/** Báo cáo hiệu quả quảng cáo (API V2) */
|
|
2701
|
+
getAdsReportV2(...args) {
|
|
2702
|
+
return this.getReportapiV2Ads(...args);
|
|
2703
|
+
}
|
|
2704
|
+
/** Báo cáo người dùng tiếp cận duy nhất (Unique Reach) */
|
|
2705
|
+
getUniqueUserReport(...args) {
|
|
2706
|
+
return this.getReportapiV2UniqueUser(...args);
|
|
2707
|
+
}
|
|
2708
|
+
/** Báo cáo chiến dịch theo ngày/tháng (Legacy ZAAPI) */
|
|
2709
|
+
getCampaignReportLegacy(...args) {
|
|
2710
|
+
return this.getZaapiCampaignReportcampaign(...args);
|
|
2711
|
+
}
|
|
2712
|
+
};
|
|
2713
|
+
|
|
2714
|
+
// src/services/conversions.service.ts
|
|
2715
|
+
var OP_ZaloAdsCreateConversion = {
|
|
2716
|
+
"operationId": "ZaloAds_createConversion",
|
|
1902
2717
|
"method": "POST",
|
|
1903
|
-
"endpoint": "/
|
|
2718
|
+
"endpoint": "/api/conversion/add",
|
|
1904
2719
|
"baseUrl": "https://ads.zalo.me",
|
|
1905
2720
|
"binaryFields": [],
|
|
1906
2721
|
"pathFields": [],
|
|
@@ -1908,72 +2723,138 @@ var OP_ZaloAdsUpdateWebsiteAd = {
|
|
|
1908
2723
|
"headerFields": [],
|
|
1909
2724
|
"cookieFields": [],
|
|
1910
2725
|
"bodyFields": [
|
|
1911
|
-
"
|
|
1912
|
-
"
|
|
1913
|
-
"
|
|
1914
|
-
"
|
|
2726
|
+
"name",
|
|
2727
|
+
"landingPage",
|
|
2728
|
+
"urlType",
|
|
2729
|
+
"labelId",
|
|
2730
|
+
"buttonIds",
|
|
2731
|
+
"elements",
|
|
2732
|
+
"keywords"
|
|
1915
2733
|
]
|
|
1916
2734
|
};
|
|
1917
|
-
var
|
|
1918
|
-
"operationId": "
|
|
1919
|
-
"method": "
|
|
1920
|
-
"endpoint": "/
|
|
2735
|
+
var OP_ZaloAdsDeleteConversion = {
|
|
2736
|
+
"operationId": "ZaloAds_deleteConversion",
|
|
2737
|
+
"method": "DELETE",
|
|
2738
|
+
"endpoint": "/api/conversion/delete/{conversionId}",
|
|
1921
2739
|
"baseUrl": "https://ads.zalo.me",
|
|
1922
2740
|
"binaryFields": [],
|
|
1923
|
-
"pathFields": [
|
|
2741
|
+
"pathFields": [
|
|
2742
|
+
"conversionId"
|
|
2743
|
+
],
|
|
1924
2744
|
"queryFields": [],
|
|
1925
2745
|
"headerFields": [],
|
|
1926
2746
|
"cookieFields": [],
|
|
1927
|
-
"bodyFields": [
|
|
1928
|
-
"data"
|
|
1929
|
-
]
|
|
2747
|
+
"bodyFields": []
|
|
1930
2748
|
};
|
|
1931
|
-
var
|
|
1932
|
-
"operationId": "
|
|
1933
|
-
"method": "
|
|
1934
|
-
"endpoint": "/
|
|
2749
|
+
var OP_ZaloAdsGetApiConversionAll = {
|
|
2750
|
+
"operationId": "ZaloAds_getApiConversionAll",
|
|
2751
|
+
"method": "GET",
|
|
2752
|
+
"endpoint": "/api/conversion/all",
|
|
1935
2753
|
"baseUrl": "https://ads.zalo.me",
|
|
1936
2754
|
"binaryFields": [],
|
|
1937
2755
|
"pathFields": [],
|
|
1938
2756
|
"queryFields": [],
|
|
1939
2757
|
"headerFields": [],
|
|
1940
2758
|
"cookieFields": [],
|
|
1941
|
-
"bodyFields": [
|
|
1942
|
-
"est",
|
|
1943
|
-
"stt",
|
|
1944
|
-
"data",
|
|
1945
|
-
"isBoostAd"
|
|
1946
|
-
]
|
|
2759
|
+
"bodyFields": []
|
|
1947
2760
|
};
|
|
1948
|
-
var
|
|
1949
|
-
"operationId": "
|
|
1950
|
-
"method": "
|
|
1951
|
-
"endpoint": "/
|
|
2761
|
+
var OP_ZaloAdsGetApiConversionStandardEvents = {
|
|
2762
|
+
"operationId": "ZaloAds_getApiConversionStandardEvents",
|
|
2763
|
+
"method": "GET",
|
|
2764
|
+
"endpoint": "/api/conversion/standard-events",
|
|
1952
2765
|
"baseUrl": "https://ads.zalo.me",
|
|
1953
2766
|
"binaryFields": [],
|
|
1954
2767
|
"pathFields": [],
|
|
1955
2768
|
"queryFields": [],
|
|
1956
2769
|
"headerFields": [],
|
|
1957
2770
|
"cookieFields": [],
|
|
1958
|
-
"bodyFields": [
|
|
1959
|
-
"data"
|
|
1960
|
-
]
|
|
2771
|
+
"bodyFields": []
|
|
1961
2772
|
};
|
|
1962
|
-
var
|
|
1963
|
-
"operationId": "
|
|
1964
|
-
"method": "
|
|
1965
|
-
"endpoint": "/api/
|
|
2773
|
+
var OP_ZaloAdsListPersonalPixelLabels = {
|
|
2774
|
+
"operationId": "ZaloAds_listPersonalPixelLabels",
|
|
2775
|
+
"method": "GET",
|
|
2776
|
+
"endpoint": "/api/conversion/support-personal-pixel-labels",
|
|
1966
2777
|
"baseUrl": "https://ads.zalo.me",
|
|
1967
2778
|
"binaryFields": [],
|
|
1968
2779
|
"pathFields": [],
|
|
1969
2780
|
"queryFields": [],
|
|
1970
2781
|
"headerFields": [],
|
|
1971
2782
|
"cookieFields": [],
|
|
1972
|
-
"bodyFields": [
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
2783
|
+
"bodyFields": []
|
|
2784
|
+
};
|
|
2785
|
+
var ZaloConversionsService = class {
|
|
2786
|
+
constructor(client) {
|
|
2787
|
+
this.client = client;
|
|
2788
|
+
}
|
|
2789
|
+
createConversion(request, options) {
|
|
2790
|
+
return this.client.requestJson(OP_ZaloAdsCreateConversion, this.client.toTransportInput(OP_ZaloAdsCreateConversion, request), options);
|
|
2791
|
+
}
|
|
2792
|
+
deleteConversion(request, options) {
|
|
2793
|
+
return this.client.requestWithoutBody(OP_ZaloAdsDeleteConversion, this.client.toTransportInput(OP_ZaloAdsDeleteConversion, request), options);
|
|
2794
|
+
}
|
|
2795
|
+
getApiConversionAll(request = {}, options) {
|
|
2796
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetApiConversionAll, this.client.toTransportInput(OP_ZaloAdsGetApiConversionAll, request), options);
|
|
2797
|
+
}
|
|
2798
|
+
getApiConversionStandardEvents(request = {}, options) {
|
|
2799
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetApiConversionStandardEvents, this.client.toTransportInput(OP_ZaloAdsGetApiConversionStandardEvents, request), options);
|
|
2800
|
+
}
|
|
2801
|
+
listPersonalPixelLabels(request = {}, options) {
|
|
2802
|
+
return this.client.requestWithoutBody(OP_ZaloAdsListPersonalPixelLabels, this.client.toTransportInput(OP_ZaloAdsListPersonalPixelLabels, request), options);
|
|
2803
|
+
}
|
|
2804
|
+
/** Lấy danh sách tài khoản Zalo Official Account (OA) có dữ liệu chuyển đổi (Lead Signal) (`GET /api/ad/audience/leadSignal/oas`). */
|
|
2805
|
+
listLeadSignalOas(options) {
|
|
2806
|
+
return this.client.requestWithoutBody(
|
|
2807
|
+
{
|
|
2808
|
+
operationId: "ZaloAds_listLeadSignalOas",
|
|
2809
|
+
method: "GET",
|
|
2810
|
+
endpoint: "/api/ad/audience/leadSignal/oas",
|
|
2811
|
+
baseUrl: "https://ads.zalo.me",
|
|
2812
|
+
binaryFields: [],
|
|
2813
|
+
pathFields: [],
|
|
2814
|
+
queryFields: [],
|
|
2815
|
+
headerFields: [],
|
|
2816
|
+
cookieFields: [],
|
|
2817
|
+
bodyFields: []
|
|
2818
|
+
},
|
|
2819
|
+
void 0,
|
|
2820
|
+
options
|
|
2821
|
+
);
|
|
2822
|
+
}
|
|
2823
|
+
/** Lấy danh sách rút gọn gồm ID và tên của toàn bộ các sự kiện chuyển đổi (Conversion) đã tạo trên tài khoản quảng cáo Zalo Ads (`GET /api/conversion/names`). */
|
|
2824
|
+
listConversionNames(request = {}, options) {
|
|
2825
|
+
const op = {
|
|
2826
|
+
operationId: "ZaloAds_listConversionNames",
|
|
2827
|
+
method: "GET",
|
|
2828
|
+
endpoint: "/api/conversion/names",
|
|
2829
|
+
baseUrl: "https://ads.zalo.me",
|
|
2830
|
+
binaryFields: [],
|
|
2831
|
+
pathFields: [],
|
|
2832
|
+
queryFields: [],
|
|
2833
|
+
headerFields: [],
|
|
2834
|
+
cookieFields: [],
|
|
2835
|
+
bodyFields: []
|
|
2836
|
+
};
|
|
2837
|
+
return this.client.requestWithoutBody(
|
|
2838
|
+
op,
|
|
2839
|
+
this.client.toTransportInput(op, request),
|
|
2840
|
+
options
|
|
2841
|
+
);
|
|
2842
|
+
}
|
|
2843
|
+
/** Alias cho `listConversionNames` (`GET /api/conversion/names`). */
|
|
2844
|
+
getApiConversionNames(request = {}, options) {
|
|
2845
|
+
return this.listConversionNames(request, options);
|
|
2846
|
+
}
|
|
2847
|
+
/** Danh sách toàn bộ sự kiện chuyển đổi */
|
|
2848
|
+
listConversions(...args) {
|
|
2849
|
+
return this.getApiConversionAll(...args);
|
|
2850
|
+
}
|
|
2851
|
+
/** Danh sách sự kiện chuyển đổi tiêu chuẩn */
|
|
2852
|
+
getConversionStandardEvents(...args) {
|
|
2853
|
+
return this.getApiConversionStandardEvents(...args);
|
|
2854
|
+
}
|
|
1976
2855
|
};
|
|
2856
|
+
|
|
2857
|
+
// src/services/automated-rules.service.ts
|
|
1977
2858
|
var OP_ZaloAdsListAutomatedRules = {
|
|
1978
2859
|
"operationId": "ZaloAds_listAutomatedRules",
|
|
1979
2860
|
"method": "GET",
|
|
@@ -2077,62 +2958,310 @@ var OP_ZaloAdsDeleteAutomatedRule = {
|
|
|
2077
2958
|
"automatedRuleIds"
|
|
2078
2959
|
]
|
|
2079
2960
|
};
|
|
2080
|
-
var
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2961
|
+
var ZaloAutomatedRulesService = class {
|
|
2962
|
+
constructor(client) {
|
|
2963
|
+
this.client = client;
|
|
2964
|
+
}
|
|
2965
|
+
listAutomatedRules(request = {}, options) {
|
|
2966
|
+
const queryInput = { query_param: { ruleName: request.ruleName ?? "" } };
|
|
2967
|
+
return this.client.requestWithoutBody(OP_ZaloAdsListAutomatedRules, queryInput, options);
|
|
2968
|
+
}
|
|
2969
|
+
createAutomatedRule(request, options) {
|
|
2970
|
+
return this.client.requestJson(OP_ZaloAdsCreateAutomatedRule, this.client.toTransportInput(OP_ZaloAdsCreateAutomatedRule, request), options);
|
|
2971
|
+
}
|
|
2972
|
+
updateAutomatedRule(request, options) {
|
|
2973
|
+
return this.client.requestJson(OP_ZaloAdsUpdateAutomatedRule, this.client.toTransportInput(OP_ZaloAdsUpdateAutomatedRule, request), options);
|
|
2974
|
+
}
|
|
2975
|
+
changeAutomatedRuleStatus(request, options) {
|
|
2976
|
+
return this.client.requestJson(OP_ZaloAdsChangeAutomatedRuleStatus, this.client.toTransportInput(OP_ZaloAdsChangeAutomatedRuleStatus, request), options);
|
|
2977
|
+
}
|
|
2978
|
+
getAutomatedRuleHistory(request, options) {
|
|
2979
|
+
return this.client.requestWithoutBody(OP_ZaloAdsGetAutomatedRuleHistory, this.client.toTransportInput(OP_ZaloAdsGetAutomatedRuleHistory, request), options);
|
|
2980
|
+
}
|
|
2981
|
+
deleteAutomatedRule(request, options) {
|
|
2982
|
+
return this.client.requestJson(OP_ZaloAdsDeleteAutomatedRule, this.client.toTransportInput(OP_ZaloAdsDeleteAutomatedRule, request), options);
|
|
2983
|
+
}
|
|
2096
2984
|
};
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
"
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2985
|
+
|
|
2986
|
+
// src/validators/flows.validator.ts
|
|
2987
|
+
var MAX_INT_32 = 2147483647;
|
|
2988
|
+
function is32BitPositiveInteger(val) {
|
|
2989
|
+
if (typeof val === "number") {
|
|
2990
|
+
return Number.isInteger(val) && val > 0 && val <= MAX_INT_32;
|
|
2991
|
+
}
|
|
2992
|
+
if (typeof val === "string" && val.trim() !== "") {
|
|
2993
|
+
const num = Number(val);
|
|
2994
|
+
return Number.isInteger(num) && num > 0 && num <= MAX_INT_32;
|
|
2995
|
+
}
|
|
2996
|
+
return false;
|
|
2997
|
+
}
|
|
2998
|
+
function isPositiveInteger(val) {
|
|
2999
|
+
if (typeof val === "number") return Number.isInteger(val) && val > 0;
|
|
3000
|
+
if (typeof val === "string" && val.trim() !== "") {
|
|
3001
|
+
const num = Number(val);
|
|
3002
|
+
return Number.isInteger(num) && num > 0;
|
|
3003
|
+
}
|
|
3004
|
+
return false;
|
|
3005
|
+
}
|
|
3006
|
+
function isNonNegativeInteger(val) {
|
|
3007
|
+
if (typeof val === "number") return Number.isInteger(val) && val >= 0;
|
|
3008
|
+
if (typeof val === "string" && val.trim() !== "") {
|
|
3009
|
+
const num = Number(val);
|
|
3010
|
+
return Number.isInteger(num) && num >= 0;
|
|
3011
|
+
}
|
|
3012
|
+
return false;
|
|
3013
|
+
}
|
|
3014
|
+
function toPositiveInteger(val) {
|
|
3015
|
+
return typeof val === "number" ? Math.floor(val) : parseInt(String(val), 10);
|
|
3016
|
+
}
|
|
3017
|
+
function validateFlowButtons(buttons, errors, prefix) {
|
|
3018
|
+
if (!Array.isArray(buttons)) {
|
|
3019
|
+
errors.push(`${prefix}: Tr\u01B0\u1EDDng 'buttons' ph\u1EA3i l\xE0 m\u1ED9t m\u1EA3ng.`);
|
|
3020
|
+
return [];
|
|
3021
|
+
}
|
|
3022
|
+
const cleanButtons = [];
|
|
3023
|
+
buttons.forEach((btn, idx) => {
|
|
3024
|
+
const btnPrefix = `${prefix}.buttons[${idx}]`;
|
|
3025
|
+
if (!btn || typeof btn !== "object") {
|
|
3026
|
+
errors.push(`${btnPrefix}: N\xFAt b\u1EA5m ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng.`);
|
|
3027
|
+
return;
|
|
3028
|
+
}
|
|
3029
|
+
const b = btn;
|
|
3030
|
+
if (typeof b.text !== "string" || b.text.trim() === "") {
|
|
3031
|
+
errors.push(`${btnPrefix}: Nh\xE3n n\xFAt 'text' l\xE0 b\u1EAFt bu\u1ED9c v\xE0 kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng.`);
|
|
3032
|
+
}
|
|
3033
|
+
const btnType = Number(b.type);
|
|
3034
|
+
if (![3, 10, 12].includes(btnType)) {
|
|
3035
|
+
errors.push(`${btnPrefix}: Lo\u1EA1i n\xFAt 'type' ph\u1EA3i l\xE0 3 (nh\xE1nh h\u1ED9i tho\u1EA1i), 10 (m\u1EDF website), ho\u1EB7c 12 (g\u1ECDi hotline).`);
|
|
3036
|
+
}
|
|
3037
|
+
const cleanBtn = {
|
|
3038
|
+
type: btnType,
|
|
3039
|
+
text: String(b.text ?? "").trim(),
|
|
3040
|
+
editable: b.editable !== false
|
|
3041
|
+
};
|
|
3042
|
+
if (btnType === 10) {
|
|
3043
|
+
if (typeof b.url !== "string" || b.url.trim() === "") {
|
|
3044
|
+
errors.push(`${btnPrefix}: N\xFAt lo\u1EA1i 10 (m\u1EDF website) b\u1EAFt bu\u1ED9c ph\u1EA3i c\xF3 tr\u01B0\u1EDDng 'url' h\u1EE3p l\u1EC7.`);
|
|
3045
|
+
} else {
|
|
3046
|
+
cleanBtn.url = b.url.trim();
|
|
3047
|
+
}
|
|
3048
|
+
} else if (btnType === 12) {
|
|
3049
|
+
if (typeof b.phone !== "string" || b.phone.trim() === "") {
|
|
3050
|
+
errors.push(`${btnPrefix}: N\xFAt lo\u1EA1i 12 (g\u1ECDi hotline) b\u1EAFt bu\u1ED9c ph\u1EA3i c\xF3 tr\u01B0\u1EDDng 'phone' h\u1EE3p l\u1EC7.`);
|
|
3051
|
+
} else {
|
|
3052
|
+
cleanBtn.phone = b.phone.trim();
|
|
3053
|
+
}
|
|
3054
|
+
} else if (btnType === 3) {
|
|
3055
|
+
if (!Array.isArray(b.messages) || b.messages.length === 0) {
|
|
3056
|
+
errors.push(`${btnPrefix}: N\xFAt lo\u1EA1i 3 (nh\xE1nh h\u1ED9i tho\u1EA1i) b\u1EAFt bu\u1ED9c ph\u1EA3i c\xF3 m\u1EA3ng 'messages' ch\u1EE9a \xEDt nh\u1EA5t 1 tin nh\u1EAFn con ph\u1EA3n h\u1ED3i.`);
|
|
3057
|
+
} else {
|
|
3058
|
+
const cleanChildMsgs = [];
|
|
3059
|
+
b.messages.forEach((child, cIdx) => {
|
|
3060
|
+
const childPrefix = `${btnPrefix}.messages[${cIdx}]`;
|
|
3061
|
+
if (!child || typeof child !== "object") {
|
|
3062
|
+
errors.push(`${childPrefix}: Tin nh\u1EAFn con ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng.`);
|
|
3063
|
+
return;
|
|
3064
|
+
}
|
|
3065
|
+
const c = child;
|
|
3066
|
+
if (typeof c.text !== "string" || c.text.trim() === "") {
|
|
3067
|
+
errors.push(`${childPrefix}: N\u1ED9i dung tin nh\u1EAFn con 'text' kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng.`);
|
|
3068
|
+
} else if (c.text.length > 1961) {
|
|
3069
|
+
errors.push(`${childPrefix}: N\u1ED9i dung tin nh\u1EAFn con v\u01B0\u1EE3t qu\xE1 1961 k\xFD t\u1EF1 (hi\u1EC7n c\xF3 ${c.text.length} k\xFD t\u1EF1).`);
|
|
3070
|
+
}
|
|
3071
|
+
cleanChildMsgs.push({
|
|
3072
|
+
type: 8,
|
|
3073
|
+
text: String(c.text ?? "").trim()
|
|
3074
|
+
});
|
|
3075
|
+
});
|
|
3076
|
+
cleanBtn.messages = cleanChildMsgs;
|
|
3077
|
+
}
|
|
3078
|
+
}
|
|
3079
|
+
cleanButtons.push(cleanBtn);
|
|
3080
|
+
});
|
|
3081
|
+
return cleanButtons;
|
|
3082
|
+
}
|
|
3083
|
+
function validateFlowMessages(messages, errors) {
|
|
3084
|
+
if (!Array.isArray(messages)) {
|
|
3085
|
+
errors.push("Tr\u01B0\u1EDDng 'messages' ph\u1EA3i l\xE0 m\u1ED9t m\u1EA3ng ch\u1EE9a tin nh\u1EAFn k\u1ECBch b\u1EA3n.");
|
|
3086
|
+
return [];
|
|
3087
|
+
}
|
|
3088
|
+
if (messages.length !== 1) {
|
|
3089
|
+
errors.push(`Zalo Ads ch\u1EC9 cho ph\xE9p k\u1ECBch b\u1EA3n ch\u1EE9a DUY NH\u1EA4T 1 tin nh\u1EAFn ch\xE0o m\u1EEBng c\u1EA5p cao (hi\u1EC7n c\xF3 ${messages.length} tin nh\u1EAFn). C\xE1c nh\xE1nh h\u1ED9i tho\u1EA1i ti\u1EBFp theo ph\u1EA3i c\u1EA5u h\xECnh b\xEAn trong n\xFAt b\u1EA5m lo\u1EA1i 3 (type=3).`);
|
|
3090
|
+
return [];
|
|
3091
|
+
}
|
|
3092
|
+
const msg = messages[0];
|
|
3093
|
+
if (!msg || typeof msg !== "object") {
|
|
3094
|
+
errors.push("Tin nh\u1EAFn k\u1ECBch b\u1EA3n ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng.");
|
|
3095
|
+
return [];
|
|
3096
|
+
}
|
|
3097
|
+
const m = msg;
|
|
3098
|
+
const msgType = Number(m.type);
|
|
3099
|
+
if (![1, 2].includes(msgType)) {
|
|
3100
|
+
errors.push("Lo\u1EA1i tin nh\u1EAFn 'type' ph\u1EA3i l\xE0 1 (v\u0103n b\u1EA3n) ho\u1EB7c 2 (k\xE8m h\xECnh \u1EA3nh).");
|
|
3101
|
+
}
|
|
3102
|
+
if (typeof m.text !== "string" || m.text.trim() === "") {
|
|
3103
|
+
errors.push("N\u1ED9i dung tin nh\u1EAFn 'text' l\xE0 b\u1EAFt bu\u1ED9c v\xE0 kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng.");
|
|
3104
|
+
} else if (m.text.length > 1961) {
|
|
3105
|
+
errors.push(`N\u1ED9i dung tin nh\u1EAFn v\u01B0\u1EE3t qu\xE1 1961 k\xFD t\u1EF1 (hi\u1EC7n c\xF3 ${m.text.length} k\xFD t\u1EF1).`);
|
|
3106
|
+
}
|
|
3107
|
+
const cleanMsg = {
|
|
3108
|
+
type: msgType,
|
|
3109
|
+
text: String(m.text ?? "").trim()
|
|
3110
|
+
};
|
|
3111
|
+
if (msgType === 2) {
|
|
3112
|
+
if (typeof m.url !== "string" || m.url.trim() === "") {
|
|
3113
|
+
errors.push("Tin nh\u1EAFn lo\u1EA1i 2 (k\xE8m \u1EA3nh) b\u1EAFt bu\u1ED9c ph\u1EA3i c\xF3 tr\u01B0\u1EDDng 'url' ch\u1EE9a \u0111\u01B0\u1EDDng d\u1EABn h\xECnh \u1EA3nh.");
|
|
3114
|
+
} else {
|
|
3115
|
+
cleanMsg.url = m.url.trim();
|
|
3116
|
+
}
|
|
3117
|
+
}
|
|
3118
|
+
if (m.buttons !== void 0 && m.buttons !== null) {
|
|
3119
|
+
cleanMsg.buttons = validateFlowButtons(m.buttons, errors, "messages[0]");
|
|
3120
|
+
}
|
|
3121
|
+
return [cleanMsg];
|
|
3122
|
+
}
|
|
3123
|
+
function validateListFlowsByOfficialAccountRequest(input) {
|
|
3124
|
+
const errors = [];
|
|
3125
|
+
if (!input || typeof input !== "object") {
|
|
3126
|
+
return { isValid: false, errors: ["D\u1EEF li\u1EC7u y\xEAu c\u1EA7u l\u1EA5y danh s\xE1ch k\u1ECBch b\u1EA3n ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng."] };
|
|
3127
|
+
}
|
|
3128
|
+
const obj = input;
|
|
3129
|
+
if (!is32BitPositiveInteger(obj.oaId)) {
|
|
3130
|
+
errors.push("Tr\u01B0\u1EDDng 'oaId' l\xE0 b\u1EAFt bu\u1ED9c v\xE0 ph\u1EA3i l\xE0 m\xE3 pageId n\u1ED9i b\u1ED9 ki\u1EC3u s\u1ED1 nguy\xEAn 32-bit (<= 2,147,483,647). Kh\xF4ng truy\u1EC1n chu\u1ED7i noisedId c\xF4ng khai (18 ch\u1EEF s\u1ED1) v\xEC backend Play Framework s\u1EBD t\u1EEB ch\u1ED1i.");
|
|
3131
|
+
}
|
|
3132
|
+
if (!isPositiveInteger(obj.limit)) {
|
|
3133
|
+
errors.push("Tr\u01B0\u1EDDng 'limit' l\xE0 b\u1EAFt bu\u1ED9c v\xE0 ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn d\u01B0\u01A1ng (> 0).");
|
|
3134
|
+
}
|
|
3135
|
+
if (obj.offset !== void 0 && obj.offset !== null && !isNonNegativeInteger(obj.offset)) {
|
|
3136
|
+
errors.push("Tr\u01B0\u1EDDng 'offset' n\u1EBFu c\xF3 ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn kh\xF4ng \xE2m (>= 0).");
|
|
3137
|
+
}
|
|
3138
|
+
if (obj.flowId !== void 0 && obj.flowId !== null && !isPositiveInteger(obj.flowId)) {
|
|
3139
|
+
errors.push("Tr\u01B0\u1EDDng 'flowId' n\u1EBFu c\xF3 ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn d\u01B0\u01A1ng (> 0).");
|
|
3140
|
+
}
|
|
3141
|
+
const cleanData = {
|
|
3142
|
+
oaId: toPositiveInteger(obj.oaId),
|
|
3143
|
+
limit: toPositiveInteger(obj.limit)
|
|
3144
|
+
};
|
|
3145
|
+
if (obj.offset !== void 0 && obj.offset !== null) cleanData.offset = toPositiveInteger(obj.offset);
|
|
3146
|
+
if (obj.flowId !== void 0 && obj.flowId !== null) cleanData.flowId = toPositiveInteger(obj.flowId);
|
|
3147
|
+
return {
|
|
3148
|
+
isValid: errors.length === 0,
|
|
3149
|
+
errors,
|
|
3150
|
+
data: errors.length === 0 ? cleanData : void 0
|
|
3151
|
+
};
|
|
3152
|
+
}
|
|
3153
|
+
function validateCreateFlowRequest(input) {
|
|
3154
|
+
const errors = [];
|
|
3155
|
+
if (!input || typeof input !== "object") {
|
|
3156
|
+
return { isValid: false, errors: ["D\u1EEF li\u1EC7u y\xEAu c\u1EA7u t\u1EA1o k\u1ECBch b\u1EA3n ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng."] };
|
|
3157
|
+
}
|
|
3158
|
+
const obj = input;
|
|
3159
|
+
if (!is32BitPositiveInteger(obj.oaId)) {
|
|
3160
|
+
errors.push("Tr\u01B0\u1EDDng 'oaId' l\xE0 b\u1EAFt bu\u1ED9c v\xE0 ph\u1EA3i l\xE0 m\xE3 pageId n\u1ED9i b\u1ED9 ki\u1EC3u s\u1ED1 nguy\xEAn 32-bit (<= 2,147,483,647).");
|
|
3161
|
+
}
|
|
3162
|
+
if (typeof obj.name !== "string" || obj.name.trim() === "") {
|
|
3163
|
+
errors.push("Tr\u01B0\u1EDDng 'name' (t\xEAn k\u1ECBch b\u1EA3n) l\xE0 b\u1EAFt bu\u1ED9c v\xE0 kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng.");
|
|
3164
|
+
} else if (obj.name.trim().length > 50) {
|
|
3165
|
+
errors.push(`T\xEAn k\u1ECBch b\u1EA3n kh\xF4ng \u0111\u01B0\u1EE3c v\u01B0\u1EE3t qu\xE1 50 k\xFD t\u1EF1 (hi\u1EC7n c\xF3 ${obj.name.trim().length} k\xFD t\u1EF1).`);
|
|
3166
|
+
}
|
|
3167
|
+
const cleanMessages = validateFlowMessages(obj.messages, errors);
|
|
3168
|
+
const cleanData = {
|
|
3169
|
+
oaId: toPositiveInteger(obj.oaId),
|
|
3170
|
+
id: null,
|
|
3171
|
+
name: String(obj.name ?? "").trim(),
|
|
3172
|
+
messages: cleanMessages
|
|
3173
|
+
};
|
|
3174
|
+
return {
|
|
3175
|
+
isValid: errors.length === 0,
|
|
3176
|
+
errors,
|
|
3177
|
+
data: errors.length === 0 ? cleanData : void 0
|
|
3178
|
+
};
|
|
3179
|
+
}
|
|
3180
|
+
function validateUpdateFlowRequest(input) {
|
|
3181
|
+
const errors = [];
|
|
3182
|
+
if (!input || typeof input !== "object") {
|
|
3183
|
+
return { isValid: false, errors: ["D\u1EEF li\u1EC7u y\xEAu c\u1EA7u c\u1EADp nh\u1EADt k\u1ECBch b\u1EA3n ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng."] };
|
|
3184
|
+
}
|
|
3185
|
+
const obj = input;
|
|
3186
|
+
if (!isPositiveInteger(obj.id)) {
|
|
3187
|
+
errors.push("Tr\u01B0\u1EDDng 'id' (ID Flow c\u1EA7n c\u1EADp nh\u1EADt) l\xE0 b\u1EAFt bu\u1ED9c v\xE0 ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn d\u01B0\u01A1ng (> 0).");
|
|
3188
|
+
}
|
|
3189
|
+
if (!is32BitPositiveInteger(obj.oaId)) {
|
|
3190
|
+
errors.push("Tr\u01B0\u1EDDng 'oaId' l\xE0 b\u1EAFt bu\u1ED9c v\xE0 ph\u1EA3i l\xE0 m\xE3 pageId n\u1ED9i b\u1ED9 ki\u1EC3u s\u1ED1 nguy\xEAn 32-bit (<= 2,147,483,647).");
|
|
3191
|
+
}
|
|
3192
|
+
if (typeof obj.name !== "string" || obj.name.trim() === "") {
|
|
3193
|
+
errors.push("Tr\u01B0\u1EDDng 'name' (t\xEAn k\u1ECBch b\u1EA3n) l\xE0 b\u1EAFt bu\u1ED9c v\xE0 kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng.");
|
|
3194
|
+
} else if (obj.name.trim().length > 50) {
|
|
3195
|
+
errors.push(`T\xEAn k\u1ECBch b\u1EA3n kh\xF4ng \u0111\u01B0\u1EE3c v\u01B0\u1EE3t qu\xE1 50 k\xFD t\u1EF1 (hi\u1EC7n c\xF3 ${obj.name.trim().length} k\xFD t\u1EF1).`);
|
|
3196
|
+
}
|
|
3197
|
+
const cleanMessages = validateFlowMessages(obj.messages, errors);
|
|
3198
|
+
const cleanData = {
|
|
3199
|
+
id: toPositiveInteger(obj.id),
|
|
3200
|
+
oaId: toPositiveInteger(obj.oaId),
|
|
3201
|
+
name: String(obj.name ?? "").trim(),
|
|
3202
|
+
messages: cleanMessages
|
|
3203
|
+
};
|
|
3204
|
+
return {
|
|
3205
|
+
isValid: errors.length === 0,
|
|
3206
|
+
errors,
|
|
3207
|
+
data: errors.length === 0 ? cleanData : void 0
|
|
3208
|
+
};
|
|
3209
|
+
}
|
|
3210
|
+
var ZaloFlowsValidator = {
|
|
3211
|
+
listFlowsByOfficialAccount: validateListFlowsByOfficialAccountRequest,
|
|
3212
|
+
createFlow: validateCreateFlowRequest,
|
|
3213
|
+
updateFlow: validateUpdateFlowRequest
|
|
2112
3214
|
};
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
"
|
|
2119
|
-
"
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
"
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
3215
|
+
|
|
3216
|
+
// src/services/flows.service.ts
|
|
3217
|
+
var OP_ZaloAdsListFlowsByOfficialAccount = {
|
|
3218
|
+
operationId: "ZaloAds_listFlowsByOfficialAccount",
|
|
3219
|
+
method: "GET",
|
|
3220
|
+
endpoint: "/api/flow/getByOaId",
|
|
3221
|
+
baseUrl: "https://ads.zalo.me",
|
|
3222
|
+
binaryFields: [],
|
|
3223
|
+
pathFields: [],
|
|
3224
|
+
queryFields: ["oaId", "limit", "offset", "flowId"],
|
|
3225
|
+
headerFields: [],
|
|
3226
|
+
cookieFields: [],
|
|
3227
|
+
bodyFields: []
|
|
3228
|
+
};
|
|
3229
|
+
var OP_ZaloAdsCreateFlow = {
|
|
3230
|
+
operationId: "ZaloAds_createFlow",
|
|
3231
|
+
method: "POST",
|
|
3232
|
+
endpoint: "/api/flow/create",
|
|
3233
|
+
baseUrl: "https://ads.zalo.me",
|
|
3234
|
+
binaryFields: [],
|
|
3235
|
+
pathFields: [],
|
|
3236
|
+
queryFields: [],
|
|
3237
|
+
headerFields: [],
|
|
3238
|
+
cookieFields: [],
|
|
3239
|
+
bodyFields: ["oaId", "id", "name", "messages"]
|
|
3240
|
+
};
|
|
3241
|
+
var OP_ZaloAdsUpdateFlow = {
|
|
3242
|
+
operationId: "ZaloAds_updateFlow",
|
|
3243
|
+
method: "POST",
|
|
3244
|
+
endpoint: "/api/flow/update",
|
|
3245
|
+
baseUrl: "https://ads.zalo.me",
|
|
3246
|
+
binaryFields: [],
|
|
3247
|
+
pathFields: [],
|
|
3248
|
+
queryFields: [],
|
|
3249
|
+
headerFields: [],
|
|
3250
|
+
cookieFields: [],
|
|
3251
|
+
bodyFields: ["oaId", "id", "name", "messages"]
|
|
2129
3252
|
};
|
|
2130
|
-
var
|
|
3253
|
+
var ZaloFlowsService = class {
|
|
2131
3254
|
constructor(client) {
|
|
2132
3255
|
this.client = client;
|
|
2133
3256
|
}
|
|
2134
|
-
|
|
2135
|
-
|
|
3257
|
+
/**
|
|
3258
|
+
* Bộ công cụ kiểm tra tính hợp lệ dữ liệu (Standalone Validators) cho Message Flows APIs.
|
|
3259
|
+
* Dùng để validate dữ liệu đầu vào trước khi lưu DB hoặc gọi Zalo Ads.
|
|
3260
|
+
*/
|
|
3261
|
+
static validator = ZaloFlowsValidator;
|
|
3262
|
+
validator = ZaloFlowsValidator;
|
|
3263
|
+
listFlowsByOfficialAccount(request, options) {
|
|
3264
|
+
return this.client.requestWithoutBody(OP_ZaloAdsListFlowsByOfficialAccount, this.client.toTransportInput(OP_ZaloAdsListFlowsByOfficialAccount, request), options);
|
|
2136
3265
|
}
|
|
2137
3266
|
createFlow(request, options) {
|
|
2138
3267
|
return this.client.requestJson(OP_ZaloAdsCreateFlow, this.client.toTransportInput(OP_ZaloAdsCreateFlow, request), options);
|
|
@@ -2140,269 +3269,879 @@ var ZaloAdsService = class {
|
|
|
2140
3269
|
updateFlow(request, options) {
|
|
2141
3270
|
return this.client.requestJson(OP_ZaloAdsUpdateFlow, this.client.toTransportInput(OP_ZaloAdsUpdateFlow, request), options);
|
|
2142
3271
|
}
|
|
2143
|
-
|
|
2144
|
-
|
|
3272
|
+
};
|
|
3273
|
+
|
|
3274
|
+
// src/services/media.service.ts
|
|
3275
|
+
var OP_ZaloAdsGetApiMediaItems = {
|
|
3276
|
+
operationId: "ZaloAds_getApiMediaItems",
|
|
3277
|
+
method: "GET",
|
|
3278
|
+
endpoint: "/api/media/items",
|
|
3279
|
+
baseUrl: "https://ads.zalo.me",
|
|
3280
|
+
binaryFields: [],
|
|
3281
|
+
pathFields: [],
|
|
3282
|
+
queryFields: ["endDate", "startDate"],
|
|
3283
|
+
headerFields: [],
|
|
3284
|
+
cookieFields: [],
|
|
3285
|
+
bodyFields: []
|
|
3286
|
+
};
|
|
3287
|
+
var OP_ZaloAdsGetApiMemberFiles = {
|
|
3288
|
+
operationId: "ZaloAds_getApiMemberFiles",
|
|
3289
|
+
method: "GET",
|
|
3290
|
+
endpoint: "/api/member/files",
|
|
3291
|
+
baseUrl: "https://ads.zalo.me",
|
|
3292
|
+
binaryFields: [],
|
|
3293
|
+
pathFields: [],
|
|
3294
|
+
queryFields: [],
|
|
3295
|
+
headerFields: [],
|
|
3296
|
+
cookieFields: [],
|
|
3297
|
+
bodyFields: []
|
|
3298
|
+
};
|
|
3299
|
+
var OP_ZaloAdsGetApiFilegroups = {
|
|
3300
|
+
operationId: "ZaloAds_getApiFilegroups",
|
|
3301
|
+
method: "GET",
|
|
3302
|
+
endpoint: "/api/filegroups",
|
|
3303
|
+
baseUrl: "https://ads.zalo.me",
|
|
3304
|
+
binaryFields: [],
|
|
3305
|
+
pathFields: [],
|
|
3306
|
+
queryFields: [],
|
|
3307
|
+
headerFields: [],
|
|
3308
|
+
cookieFields: [],
|
|
3309
|
+
bodyFields: []
|
|
3310
|
+
};
|
|
3311
|
+
var OP_ZaloAdsPostApiMediaSave = {
|
|
3312
|
+
operationId: "ZaloAds_postApiMediaSave",
|
|
3313
|
+
method: "POST",
|
|
3314
|
+
endpoint: "/api/media/save",
|
|
3315
|
+
baseUrl: "https://ads.zalo.me",
|
|
3316
|
+
binaryFields: [],
|
|
3317
|
+
pathFields: [],
|
|
3318
|
+
queryFields: [],
|
|
3319
|
+
headerFields: [],
|
|
3320
|
+
cookieFields: [],
|
|
3321
|
+
bodyFields: ["data"]
|
|
3322
|
+
};
|
|
3323
|
+
var OP_ZaloAdsPostApiMemberUploadImage = {
|
|
3324
|
+
operationId: "ZaloAds_postApiMemberUploadImage",
|
|
3325
|
+
method: "POST",
|
|
3326
|
+
endpoint: "/api/member/upload-image",
|
|
3327
|
+
baseUrl: "https://ads.zalo.me",
|
|
3328
|
+
binaryFields: ["File"],
|
|
3329
|
+
pathFields: [],
|
|
3330
|
+
queryFields: [],
|
|
3331
|
+
headerFields: [],
|
|
3332
|
+
cookieFields: [],
|
|
3333
|
+
bodyFields: ["File"]
|
|
3334
|
+
};
|
|
3335
|
+
var OP_ZaloAdsUploadVideo = {
|
|
3336
|
+
operationId: "ZaloAds_uploadVideo",
|
|
3337
|
+
method: "POST",
|
|
3338
|
+
endpoint: "/api/member/upload-video",
|
|
3339
|
+
baseUrl: "https://ads.zalo.me",
|
|
3340
|
+
binaryFields: ["File"],
|
|
3341
|
+
pathFields: [],
|
|
3342
|
+
queryFields: [],
|
|
3343
|
+
headerFields: [],
|
|
3344
|
+
cookieFields: [],
|
|
3345
|
+
bodyFields: ["File"]
|
|
3346
|
+
};
|
|
3347
|
+
var OP_ZaloAdsUpdateNewAds2 = {
|
|
3348
|
+
operationId: "ZaloAds_UpdateNewAds",
|
|
3349
|
+
method: "POST",
|
|
3350
|
+
endpoint: "/zaapi/UploadCrop",
|
|
3351
|
+
baseUrl: "https://ads.zalo.me",
|
|
3352
|
+
binaryFields: ["File"],
|
|
3353
|
+
pathFields: [],
|
|
3354
|
+
queryFields: [],
|
|
3355
|
+
headerFields: [],
|
|
3356
|
+
cookieFields: [],
|
|
3357
|
+
bodyFields: ["File", "x", "y", "width", "height", "scale"]
|
|
3358
|
+
};
|
|
3359
|
+
function extractJpegDimensions(buffer) {
|
|
3360
|
+
let i = 2;
|
|
3361
|
+
while (i < buffer.length - 8) {
|
|
3362
|
+
if (buffer[i] !== 255) {
|
|
3363
|
+
i++;
|
|
3364
|
+
continue;
|
|
3365
|
+
}
|
|
3366
|
+
const marker = buffer[i + 1];
|
|
3367
|
+
if (marker === 192 || marker === 193 || marker === 194) {
|
|
3368
|
+
const height = buffer[i + 5] << 8 | buffer[i + 6];
|
|
3369
|
+
const width = buffer[i + 7] << 8 | buffer[i + 8];
|
|
3370
|
+
return { width, height };
|
|
3371
|
+
}
|
|
3372
|
+
const len = buffer[i + 2] << 8 | buffer[i + 3];
|
|
3373
|
+
i += 2 + len;
|
|
2145
3374
|
}
|
|
2146
|
-
|
|
2147
|
-
|
|
3375
|
+
return null;
|
|
3376
|
+
}
|
|
3377
|
+
function extractPngDimensions(buffer) {
|
|
3378
|
+
if (buffer.length >= 24 && buffer[0] === 137 && buffer[1] === 80 && buffer[2] === 78 && buffer[3] === 71) {
|
|
3379
|
+
const width = buffer[16] << 24 | buffer[17] << 16 | buffer[18] << 8 | buffer[19];
|
|
3380
|
+
const height = buffer[20] << 24 | buffer[21] << 16 | buffer[22] << 8 | buffer[23];
|
|
3381
|
+
return { width, height };
|
|
2148
3382
|
}
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
3383
|
+
return null;
|
|
3384
|
+
}
|
|
3385
|
+
function isUint8Array(val) {
|
|
3386
|
+
if (val instanceof Uint8Array) {
|
|
3387
|
+
return true;
|
|
2152
3388
|
}
|
|
2153
|
-
|
|
2154
|
-
return
|
|
3389
|
+
if (typeof val === "object" && val !== null && typeof val.constructor?.isBuffer === "function") {
|
|
3390
|
+
return val.constructor.isBuffer(val);
|
|
2155
3391
|
}
|
|
2156
|
-
|
|
2157
|
-
|
|
3392
|
+
return false;
|
|
3393
|
+
}
|
|
3394
|
+
function resolveFileName(input, defaultPrefix = "media") {
|
|
3395
|
+
if (typeof input === "string") {
|
|
3396
|
+
const clean = input.split(/[?#]/)[0];
|
|
3397
|
+
const match = clean.match(/[^/\\]+$/);
|
|
3398
|
+
if (match && match[0]) return match[0];
|
|
3399
|
+
}
|
|
3400
|
+
if (input && typeof input === "object") {
|
|
3401
|
+
const record = input;
|
|
3402
|
+
if (typeof record.name === "string" && record.name) return record.name;
|
|
3403
|
+
if (typeof record.originalname === "string" && record.originalname) return record.originalname;
|
|
3404
|
+
if (typeof record.fileName === "string" && record.fileName) return record.fileName;
|
|
3405
|
+
}
|
|
3406
|
+
return `${defaultPrefix}_${Date.now()}.jpg`;
|
|
3407
|
+
}
|
|
3408
|
+
var ZaloMediaService = class {
|
|
3409
|
+
constructor(client) {
|
|
3410
|
+
this.client = client;
|
|
2158
3411
|
}
|
|
2159
|
-
|
|
2160
|
-
|
|
3412
|
+
// ==========================================================================
|
|
3413
|
+
// 1. RAW API METHODS (Chuẩn theo OpenAPI spec media-and-assets, không validate)
|
|
3414
|
+
// ==========================================================================
|
|
3415
|
+
/**
|
|
3416
|
+
* Lấy danh sách ảnh, video trong thư viện Zalo Ads theo khoảng thời gian (`GET /api/media/items`).
|
|
3417
|
+
*/
|
|
3418
|
+
getApiMediaItems(request, options) {
|
|
3419
|
+
return this.client.requestWithoutBody(
|
|
3420
|
+
OP_ZaloAdsGetApiMediaItems,
|
|
3421
|
+
this.client.toTransportInput(OP_ZaloAdsGetApiMediaItems, request),
|
|
3422
|
+
options
|
|
3423
|
+
);
|
|
2161
3424
|
}
|
|
2162
|
-
|
|
2163
|
-
|
|
3425
|
+
/**
|
|
3426
|
+
* Alias cho `getApiMediaItems`.
|
|
3427
|
+
*/
|
|
3428
|
+
listMediaItems(request, options) {
|
|
3429
|
+
return this.getApiMediaItems(request, options);
|
|
3430
|
+
}
|
|
3431
|
+
/**
|
|
3432
|
+
* Lấy các tệp do thành viên hiện tại quản lý trong tài khoản quảng cáo (`GET /api/member/files`).
|
|
3433
|
+
*/
|
|
3434
|
+
getApiMemberFiles(request = {}, options) {
|
|
3435
|
+
return this.client.requestWithoutBody(
|
|
3436
|
+
OP_ZaloAdsGetApiMemberFiles,
|
|
3437
|
+
this.client.toTransportInput(OP_ZaloAdsGetApiMemberFiles, request),
|
|
3438
|
+
options
|
|
3439
|
+
);
|
|
2164
3440
|
}
|
|
2165
|
-
|
|
2166
|
-
|
|
3441
|
+
/**
|
|
3442
|
+
* Alias cho `getApiMemberFiles`.
|
|
3443
|
+
*/
|
|
3444
|
+
listMemberFiles(request = {}, options) {
|
|
3445
|
+
return this.getApiMemberFiles(request, options);
|
|
2167
3446
|
}
|
|
2168
|
-
|
|
2169
|
-
|
|
3447
|
+
/**
|
|
3448
|
+
* Lấy danh sách nhóm tệp trong kho media (`GET /api/filegroups`).
|
|
3449
|
+
*/
|
|
3450
|
+
getApiFilegroups(request = {}, options) {
|
|
3451
|
+
return this.client.requestWithoutBody(
|
|
3452
|
+
OP_ZaloAdsGetApiFilegroups,
|
|
3453
|
+
this.client.toTransportInput(OP_ZaloAdsGetApiFilegroups, request),
|
|
3454
|
+
options
|
|
3455
|
+
);
|
|
2170
3456
|
}
|
|
2171
|
-
|
|
2172
|
-
|
|
3457
|
+
/**
|
|
3458
|
+
* Alias cho `getApiFilegroups`.
|
|
3459
|
+
*/
|
|
3460
|
+
listFilegroups(request = {}, options) {
|
|
3461
|
+
return this.getApiFilegroups(request, options);
|
|
2173
3462
|
}
|
|
2174
|
-
/**
|
|
2175
|
-
|
|
2176
|
-
|
|
3463
|
+
/**
|
|
3464
|
+
* Lưu tài nguyên media vào thư viện Zalo Ads sau khi đã có URL ảnh/video và metadata (`POST /api/media/save`).
|
|
3465
|
+
* Phản hồi trả về `{ code: 0, data: <MediaId> }`.
|
|
3466
|
+
*/
|
|
3467
|
+
postApiMediaSave(request, options) {
|
|
3468
|
+
const normalized = {
|
|
3469
|
+
...request,
|
|
3470
|
+
data: typeof request.data === "string" ? request.data : JSON.stringify(request.data)
|
|
3471
|
+
};
|
|
3472
|
+
return this.client.requestFormUrlEncoded(
|
|
3473
|
+
OP_ZaloAdsPostApiMediaSave,
|
|
3474
|
+
this.client.toTransportInput(OP_ZaloAdsPostApiMediaSave, normalized),
|
|
3475
|
+
options
|
|
3476
|
+
);
|
|
2177
3477
|
}
|
|
2178
|
-
|
|
2179
|
-
|
|
3478
|
+
/**
|
|
3479
|
+
* Alias cho `postApiMediaSave`.
|
|
3480
|
+
*/
|
|
3481
|
+
saveMedia(request, options) {
|
|
3482
|
+
return this.postApiMediaSave(request, options);
|
|
2180
3483
|
}
|
|
2181
|
-
|
|
2182
|
-
|
|
3484
|
+
/**
|
|
3485
|
+
* Tải ảnh lên kho media của tài khoản quảng cáo (`POST /api/member/upload-image`).
|
|
3486
|
+
* Sử dụng multipart/form-data với trường `File` (chữ hoa). Trả về URL CDN Adtima.
|
|
3487
|
+
*/
|
|
3488
|
+
postApiMemberUploadImage(request, options) {
|
|
3489
|
+
const file = request.File ?? request.file;
|
|
3490
|
+
if (typeof file === "string" && !/^(https?:|data:)/i.test(file)) {
|
|
3491
|
+
throw new ZaloSdkError(
|
|
3492
|
+
"\u0110\u01B0\u1EDDng d\u1EABn t\u1EC7p c\u1EE5c b\u1ED9 tr\xEAn \u1ED5 c\u1EE9ng kh\xF4ng \u0111\u01B0\u1EE3c h\u1ED7 tr\u1EE3. Vui l\xF2ng truy\u1EC1n Buffer/Uint8Array (v\xED d\u1EE5: req.file.buffer t\u1EEB Multer), Web Blob/File ho\u1EB7c URL \u1EA3nh c\xF4ng khai (http/https).",
|
|
3493
|
+
400,
|
|
3494
|
+
"postApiMemberUploadImage",
|
|
3495
|
+
null
|
|
3496
|
+
);
|
|
3497
|
+
}
|
|
3498
|
+
const normalized = {
|
|
3499
|
+
File: file
|
|
3500
|
+
};
|
|
3501
|
+
return this.client.requestMultipart(
|
|
3502
|
+
OP_ZaloAdsPostApiMemberUploadImage,
|
|
3503
|
+
this.client.toTransportInput(OP_ZaloAdsPostApiMemberUploadImage, normalized),
|
|
3504
|
+
options
|
|
3505
|
+
);
|
|
2183
3506
|
}
|
|
2184
|
-
|
|
2185
|
-
|
|
3507
|
+
/**
|
|
3508
|
+
* Alias cho `postApiMemberUploadImage`.
|
|
3509
|
+
*/
|
|
3510
|
+
uploadImage(request, options) {
|
|
3511
|
+
return this.postApiMemberUploadImage(request, options);
|
|
2186
3512
|
}
|
|
2187
|
-
|
|
2188
|
-
|
|
3513
|
+
/**
|
|
3514
|
+
* Tải video lên kho media của tài khoản quảng cáo (`POST /api/member/upload-video`).
|
|
3515
|
+
* Định dạng chuẩn .MP4 (H.264), tối đa 150MB. Trả về URL video trên Adtima CDN.
|
|
3516
|
+
*/
|
|
3517
|
+
uploadVideo(request, options) {
|
|
3518
|
+
const file = request.File ?? request.file;
|
|
3519
|
+
if (typeof file === "string" && !/^(https?:|data:)/i.test(file)) {
|
|
3520
|
+
throw new ZaloSdkError(
|
|
3521
|
+
"\u0110\u01B0\u1EDDng d\u1EABn t\u1EC7p c\u1EE5c b\u1ED9 tr\xEAn \u1ED5 c\u1EE9ng kh\xF4ng \u0111\u01B0\u1EE3c h\u1ED7 tr\u1EE3. Vui l\xF2ng truy\u1EC1n Buffer/Uint8Array (v\xED d\u1EE5: req.file.buffer), Web Blob/File ho\u1EB7c URL video c\xF4ng khai (http/https).",
|
|
3522
|
+
400,
|
|
3523
|
+
"uploadVideo",
|
|
3524
|
+
null
|
|
3525
|
+
);
|
|
3526
|
+
}
|
|
3527
|
+
const normalized = {
|
|
3528
|
+
File: file
|
|
3529
|
+
};
|
|
3530
|
+
return this.client.requestMultipart(
|
|
3531
|
+
OP_ZaloAdsUploadVideo,
|
|
3532
|
+
this.client.toTransportInput(OP_ZaloAdsUploadVideo, normalized),
|
|
3533
|
+
options
|
|
3534
|
+
);
|
|
2189
3535
|
}
|
|
2190
|
-
/**
|
|
2191
|
-
|
|
2192
|
-
|
|
3536
|
+
/**
|
|
3537
|
+
* Tải ảnh và thiết lập vùng crop tạo asset dùng cho quảng cáo Zalo Ads (`POST /zaapi/UploadCrop`).
|
|
3538
|
+
*/
|
|
3539
|
+
updateNewAds(request, options) {
|
|
3540
|
+
return this.client.requestMultipart(
|
|
3541
|
+
OP_ZaloAdsUpdateNewAds2,
|
|
3542
|
+
this.client.toTransportInput(OP_ZaloAdsUpdateNewAds2, request),
|
|
3543
|
+
options
|
|
3544
|
+
);
|
|
2193
3545
|
}
|
|
2194
|
-
|
|
2195
|
-
|
|
3546
|
+
/**
|
|
3547
|
+
* Alias cho `updateNewAds` (`POST /zaapi/UploadCrop`).
|
|
3548
|
+
*/
|
|
3549
|
+
uploadCrop(request, options) {
|
|
3550
|
+
return this.updateNewAds(request, options);
|
|
2196
3551
|
}
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
3552
|
+
// ==========================================================================
|
|
3553
|
+
// 2. CONVENIENCE CUSTOM METHODS: UPLOAD + SAVE TRỌN GÓI
|
|
3554
|
+
// ==========================================================================
|
|
3555
|
+
/**
|
|
3556
|
+
* Method tiện ích trọn gói: Tự động tải ảnh lên CDN (`/api/member/upload-image`)
|
|
3557
|
+
* VÀ lưu vào Thư viện Zalo Ads (`/api/media/save`) trong cùng 1 lời gọi duy nhất.
|
|
3558
|
+
*
|
|
3559
|
+
* Trả về MediaId, URL CDN và kích thước để gắn ngay vào Creative/Quảng cáo.
|
|
3560
|
+
*/
|
|
3561
|
+
async uploadAndSaveImage(request, options) {
|
|
3562
|
+
if (!request.file) {
|
|
3563
|
+
throw new ZaloSdkError(
|
|
3564
|
+
"ZaloMediaService: `file` l\xE0 tham s\u1ED1 b\u1EAFt bu\u1ED9c trong uploadAndSaveImage.",
|
|
3565
|
+
400,
|
|
3566
|
+
"uploadAndSaveImage",
|
|
3567
|
+
null
|
|
3568
|
+
);
|
|
3569
|
+
}
|
|
3570
|
+
if (typeof request.file === "string" && !/^(https?:|data:)/i.test(request.file)) {
|
|
3571
|
+
throw new ZaloSdkError(
|
|
3572
|
+
"\u0110\u01B0\u1EDDng d\u1EABn t\u1EC7p c\u1EE5c b\u1ED9 tr\xEAn \u1ED5 c\u1EE9ng kh\xF4ng \u0111\u01B0\u1EE3c h\u1ED7 tr\u1EE3. Vui l\xF2ng truy\u1EC1n Buffer/Uint8Array (v\xED d\u1EE5: req.file.buffer t\u1EEB Multer), Web Blob/File ho\u1EB7c URL \u1EA3nh c\xF4ng khai (http/https).",
|
|
3573
|
+
400,
|
|
3574
|
+
"uploadAndSaveImage",
|
|
3575
|
+
null
|
|
3576
|
+
);
|
|
3577
|
+
}
|
|
3578
|
+
const fileName = request.fileName || resolveFileName(request.file, "image");
|
|
3579
|
+
let width = request.width;
|
|
3580
|
+
let height = request.height;
|
|
3581
|
+
if ((!width || !height) && isUint8Array(request.file)) {
|
|
3582
|
+
const dims = extractJpegDimensions(request.file) || extractPngDimensions(request.file);
|
|
3583
|
+
if (dims) {
|
|
3584
|
+
width = width || dims.width;
|
|
3585
|
+
height = height || dims.height;
|
|
3586
|
+
}
|
|
3587
|
+
}
|
|
3588
|
+
const resolvedWidth = width && width > 0 ? width : 1200;
|
|
3589
|
+
const resolvedHeight = height && height > 0 ? height : 710;
|
|
3590
|
+
const uploadRes = await this.postApiMemberUploadImage({ File: request.file }, options);
|
|
3591
|
+
if (!uploadRes || uploadRes.code !== 0 || !uploadRes.data) {
|
|
3592
|
+
throw new ZaloSdkError(
|
|
3593
|
+
uploadRes?.msg || "T\u1EA3i \u1EA3nh l\xEAn Zalo Ads th\u1EA5t b\u1EA1i \u1EDF b\u01B0\u1EDBc upload CDN.",
|
|
3594
|
+
uploadRes?.code || 500,
|
|
3595
|
+
"uploadAndSaveImage_upload",
|
|
3596
|
+
uploadRes
|
|
3597
|
+
);
|
|
3598
|
+
}
|
|
3599
|
+
const cdnUrl = uploadRes.data;
|
|
3600
|
+
const mediaType = request.type !== void 0 ? request.type : 1;
|
|
3601
|
+
const savePayload = {
|
|
3602
|
+
Name: fileName,
|
|
3603
|
+
Type: mediaType,
|
|
3604
|
+
Settings: {
|
|
3605
|
+
Url: cdnUrl,
|
|
3606
|
+
Width: resolvedWidth,
|
|
3607
|
+
Height: resolvedHeight,
|
|
3608
|
+
...request.thumbUrl ? { ThumbUrl: request.thumbUrl } : {}
|
|
3609
|
+
}
|
|
3610
|
+
};
|
|
3611
|
+
const saveRes = await this.postApiMediaSave({ data: savePayload }, options);
|
|
3612
|
+
if (!saveRes || saveRes.code !== 0 || typeof saveRes.data !== "number") {
|
|
3613
|
+
throw new ZaloSdkError(
|
|
3614
|
+
"L\u01B0u \u1EA3nh v\xE0o Th\u01B0 vi\u1EC7n Media Zalo Ads th\u1EA5t b\u1EA1i \u1EDF b\u01B0\u1EDBc save.",
|
|
3615
|
+
saveRes?.code || 500,
|
|
3616
|
+
"uploadAndSaveImage_save",
|
|
3617
|
+
saveRes
|
|
3618
|
+
);
|
|
3619
|
+
}
|
|
3620
|
+
return {
|
|
3621
|
+
code: 0,
|
|
3622
|
+
mediaId: saveRes.data,
|
|
3623
|
+
cdnUrl,
|
|
3624
|
+
name: fileName,
|
|
3625
|
+
width: resolvedWidth,
|
|
3626
|
+
height: resolvedHeight,
|
|
3627
|
+
type: mediaType,
|
|
3628
|
+
rawUploadResponse: uploadRes,
|
|
3629
|
+
rawSaveResponse: saveRes
|
|
3630
|
+
};
|
|
2200
3631
|
}
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
3632
|
+
/**
|
|
3633
|
+
* Method tiện ích trọn gói cho Video: Tự động tải video lên CDN (`/api/member/upload-video`)
|
|
3634
|
+
* VÀ lưu vào Thư viện Zalo Ads (`/api/media/save`) để cấp MediaId.
|
|
3635
|
+
*/
|
|
3636
|
+
async uploadAndSaveVideo(request, options) {
|
|
3637
|
+
if (!request.file) {
|
|
3638
|
+
throw new ZaloSdkError(
|
|
3639
|
+
"ZaloMediaService: `file` l\xE0 tham s\u1ED1 b\u1EAFt bu\u1ED9c trong uploadAndSaveVideo.",
|
|
3640
|
+
400,
|
|
3641
|
+
"uploadAndSaveVideo",
|
|
3642
|
+
null
|
|
3643
|
+
);
|
|
3644
|
+
}
|
|
3645
|
+
if (typeof request.file === "string" && !/^(https?:|data:)/i.test(request.file)) {
|
|
3646
|
+
throw new ZaloSdkError(
|
|
3647
|
+
"\u0110\u01B0\u1EDDng d\u1EABn t\u1EC7p c\u1EE5c b\u1ED9 tr\xEAn \u1ED5 c\u1EE9ng kh\xF4ng \u0111\u01B0\u1EE3c h\u1ED7 tr\u1EE3. Vui l\xF2ng truy\u1EC1n Buffer/Uint8Array, Web Blob/File ho\u1EB7c URL video c\xF4ng khai (http/https).",
|
|
3648
|
+
400,
|
|
3649
|
+
"uploadAndSaveVideo",
|
|
3650
|
+
null
|
|
3651
|
+
);
|
|
3652
|
+
}
|
|
3653
|
+
const fileName = request.fileName || resolveFileName(request.file, "video");
|
|
3654
|
+
const width = request.width || 1920;
|
|
3655
|
+
const height = request.height || 1080;
|
|
3656
|
+
const duration = request.duration || 30;
|
|
3657
|
+
const uploadRes = await this.uploadVideo({ File: request.file }, options);
|
|
3658
|
+
if (!uploadRes || uploadRes.code !== 0 || !uploadRes.data) {
|
|
3659
|
+
throw new ZaloSdkError(
|
|
3660
|
+
uploadRes?.msg || "T\u1EA3i video l\xEAn Zalo Ads th\u1EA5t b\u1EA1i \u1EDF b\u01B0\u1EDBc upload CDN.",
|
|
3661
|
+
uploadRes?.code || 500,
|
|
3662
|
+
"uploadAndSaveVideo_upload",
|
|
3663
|
+
uploadRes
|
|
3664
|
+
);
|
|
3665
|
+
}
|
|
3666
|
+
const cdnUrl = uploadRes.data;
|
|
3667
|
+
const savePayload = {
|
|
3668
|
+
Name: fileName,
|
|
3669
|
+
Type: 2,
|
|
3670
|
+
// 2 = Video
|
|
3671
|
+
Settings: {
|
|
3672
|
+
Url: cdnUrl,
|
|
3673
|
+
Width: width,
|
|
3674
|
+
Height: height,
|
|
3675
|
+
Duration: duration,
|
|
3676
|
+
...request.thumbUrl ? { ThumbUrl: request.thumbUrl } : {}
|
|
3677
|
+
}
|
|
3678
|
+
};
|
|
3679
|
+
const saveRes = await this.postApiMediaSave({ data: savePayload }, options);
|
|
3680
|
+
if (!saveRes || saveRes.code !== 0 || typeof saveRes.data !== "number") {
|
|
3681
|
+
throw new ZaloSdkError(
|
|
3682
|
+
"L\u01B0u video v\xE0o Th\u01B0 vi\u1EC7n Media Zalo Ads th\u1EA5t b\u1EA1i \u1EDF b\u01B0\u1EDBc save.",
|
|
3683
|
+
saveRes?.code || 500,
|
|
3684
|
+
"uploadAndSaveVideo_save",
|
|
3685
|
+
saveRes
|
|
3686
|
+
);
|
|
3687
|
+
}
|
|
3688
|
+
return {
|
|
3689
|
+
code: 0,
|
|
3690
|
+
mediaId: saveRes.data,
|
|
3691
|
+
cdnUrl,
|
|
3692
|
+
name: fileName,
|
|
3693
|
+
width,
|
|
3694
|
+
height,
|
|
3695
|
+
duration,
|
|
3696
|
+
type: 2,
|
|
3697
|
+
rawUploadResponse: uploadRes,
|
|
3698
|
+
rawSaveResponse: saveRes
|
|
3699
|
+
};
|
|
2204
3700
|
}
|
|
2205
|
-
|
|
2206
|
-
|
|
3701
|
+
// ==========================================================================
|
|
3702
|
+
// 3. STANDALONE VALIDATION METHODS (Cho Backend sử dụng độc lập, không chặn API)
|
|
3703
|
+
// ==========================================================================
|
|
3704
|
+
/**
|
|
3705
|
+
* Kiểm tra tính hợp lệ của tệp Ảnh theo quy chuẩn Zalo Ads:
|
|
3706
|
+
* - "No file chosen": Bắt buộc phải có tệp.
|
|
3707
|
+
* - Dung lượng: Tối đa 2MB (2 * 1024 * 1024 bytes).
|
|
3708
|
+
* - Kích thước: Tối thiểu 150x150 pixels.
|
|
3709
|
+
* - Định dạng: Hỗ trợ .JPG, .JPEG, .PNG.
|
|
3710
|
+
*
|
|
3711
|
+
* Trả về `{ isValid: boolean, status: 'VALID' | 'INVALID', errors: string[], metadata: {...} }`.
|
|
3712
|
+
*/
|
|
3713
|
+
validateImage(input) {
|
|
3714
|
+
const errors = [];
|
|
3715
|
+
let sizeBytes = input.sizeBytes;
|
|
3716
|
+
let fileName = input.fileName;
|
|
3717
|
+
let format = input.format;
|
|
3718
|
+
let width = input.width;
|
|
3719
|
+
let height = input.height;
|
|
3720
|
+
const file = input.file;
|
|
3721
|
+
const hasFile = Boolean(
|
|
3722
|
+
file !== null && file !== void 0 && (typeof file !== "string" || file.trim() !== "")
|
|
3723
|
+
);
|
|
3724
|
+
if (!hasFile && sizeBytes === void 0) {
|
|
3725
|
+
errors.push("No file chosen");
|
|
3726
|
+
return {
|
|
3727
|
+
isValid: false,
|
|
3728
|
+
status: "INVALID",
|
|
3729
|
+
errors,
|
|
3730
|
+
metadata: { fileDetected: false }
|
|
3731
|
+
};
|
|
3732
|
+
}
|
|
3733
|
+
if (file && typeof file === "object") {
|
|
3734
|
+
const rec = file;
|
|
3735
|
+
if (typeof rec.size === "number" && sizeBytes === void 0) {
|
|
3736
|
+
sizeBytes = rec.size;
|
|
3737
|
+
}
|
|
3738
|
+
if (typeof rec.originalname === "string" && !fileName) {
|
|
3739
|
+
fileName = rec.originalname;
|
|
3740
|
+
}
|
|
3741
|
+
if (typeof rec.mimetype === "string" && !format) {
|
|
3742
|
+
format = rec.mimetype;
|
|
3743
|
+
}
|
|
3744
|
+
if (isUint8Array(rec.buffer)) {
|
|
3745
|
+
if (sizeBytes === void 0) sizeBytes = rec.buffer.byteLength;
|
|
3746
|
+
const dims = extractJpegDimensions(rec.buffer) || extractPngDimensions(rec.buffer);
|
|
3747
|
+
if (dims) {
|
|
3748
|
+
width = width || dims.width;
|
|
3749
|
+
height = height || dims.height;
|
|
3750
|
+
}
|
|
3751
|
+
} else if (isUint8Array(file)) {
|
|
3752
|
+
if (sizeBytes === void 0) sizeBytes = file.byteLength;
|
|
3753
|
+
const dims = extractJpegDimensions(file) || extractPngDimensions(file);
|
|
3754
|
+
if (dims) {
|
|
3755
|
+
width = width || dims.width;
|
|
3756
|
+
height = height || dims.height;
|
|
3757
|
+
}
|
|
3758
|
+
}
|
|
3759
|
+
} else if (typeof file === "string" && !fileName) {
|
|
3760
|
+
fileName = resolveFileName(file);
|
|
3761
|
+
}
|
|
3762
|
+
if (sizeBytes !== void 0 && sizeBytes <= 0) {
|
|
3763
|
+
errors.push("No file chosen");
|
|
3764
|
+
}
|
|
3765
|
+
const MAX_IMAGE_BYTES = 2 * 1024 * 1024;
|
|
3766
|
+
if (sizeBytes !== void 0 && sizeBytes > MAX_IMAGE_BYTES) {
|
|
3767
|
+
const sizeMB = (sizeBytes / (1024 * 1024)).toFixed(2);
|
|
3768
|
+
errors.push(`Dung l\u01B0\u1EE3ng \u1EA3nh v\u01B0\u1EE3t qu\xE1 gi\u1EDBi h\u1EA1n t\u1ED1i \u0111a 2MB (dung l\u01B0\u1EE3ng hi\u1EC7n t\u1EA1i: ${sizeMB}MB).`);
|
|
3769
|
+
}
|
|
3770
|
+
if (width !== void 0 && height !== void 0) {
|
|
3771
|
+
if (width < 150 || height < 150) {
|
|
3772
|
+
errors.push(`K\xEDch th\u01B0\u1EDBc \u1EA3nh t\u1ED1i thi\u1EC3u 150x150 (k\xEDch th\u01B0\u1EDBc hi\u1EC7n t\u1EA1i: ${width}x${height} pixels).`);
|
|
3773
|
+
}
|
|
3774
|
+
}
|
|
3775
|
+
const nameToCheck = (fileName || format || "").toLowerCase();
|
|
3776
|
+
if (nameToCheck) {
|
|
3777
|
+
const isAllowedFormat = nameToCheck.endsWith(".jpg") || nameToCheck.endsWith(".jpeg") || nameToCheck.endsWith(".png") || nameToCheck.includes("image/jpeg") || nameToCheck.includes("image/jpg") || nameToCheck.includes("image/png");
|
|
3778
|
+
if (!isAllowedFormat) {
|
|
3779
|
+
errors.push("\u0110\u1ECBnh d\u1EA1ng \u1EA3nh kh\xF4ng h\u1EE3p l\u1EC7, y\xEAu c\u1EA7u \u0111\u1ECBnh d\u1EA1ng .JPG, .JPEG ho\u1EB7c .PNG.");
|
|
3780
|
+
}
|
|
3781
|
+
}
|
|
3782
|
+
const isValid = errors.length === 0;
|
|
3783
|
+
return {
|
|
3784
|
+
isValid,
|
|
3785
|
+
status: isValid ? "VALID" : "INVALID",
|
|
3786
|
+
errors,
|
|
3787
|
+
metadata: {
|
|
3788
|
+
fileDetected: true,
|
|
3789
|
+
sizeBytes,
|
|
3790
|
+
width,
|
|
3791
|
+
height,
|
|
3792
|
+
format: format || (fileName ? fileName.split(".").pop() : void 0)
|
|
3793
|
+
}
|
|
3794
|
+
};
|
|
2207
3795
|
}
|
|
2208
|
-
|
|
2209
|
-
|
|
3796
|
+
/**
|
|
3797
|
+
* Kiểm tra tính hợp lệ của tệp Video theo quy chuẩn Zalo Ads:
|
|
3798
|
+
* - "No file chosen": Bắt buộc phải có tệp.
|
|
3799
|
+
* - Định dạng: .MP4 H.264.
|
|
3800
|
+
* - Dung lượng: Tối đa 150MB (150 * 1024 * 1024 bytes).
|
|
3801
|
+
* - Thời lượng: Tối đa 60 giây.
|
|
3802
|
+
* - Tỉ lệ khung hình: 16:9, 9:16 hoặc 1:1.
|
|
3803
|
+
*
|
|
3804
|
+
* Trả về `{ isValid: boolean, status: 'VALID' | 'INVALID', errors: string[], metadata: {...} }`.
|
|
3805
|
+
*/
|
|
3806
|
+
validateVideo(input) {
|
|
3807
|
+
const errors = [];
|
|
3808
|
+
let sizeBytes = input.sizeBytes;
|
|
3809
|
+
let fileName = input.fileName;
|
|
3810
|
+
let format = input.format;
|
|
3811
|
+
const durationSeconds = input.durationSeconds;
|
|
3812
|
+
const width = input.width;
|
|
3813
|
+
const height = input.height;
|
|
3814
|
+
const file = input.file;
|
|
3815
|
+
const hasFile = Boolean(
|
|
3816
|
+
file !== null && file !== void 0 && (typeof file !== "string" || file.trim() !== "")
|
|
3817
|
+
);
|
|
3818
|
+
if (!hasFile && sizeBytes === void 0) {
|
|
3819
|
+
errors.push("No file chosen");
|
|
3820
|
+
return {
|
|
3821
|
+
isValid: false,
|
|
3822
|
+
status: "INVALID",
|
|
3823
|
+
errors,
|
|
3824
|
+
metadata: { fileDetected: false }
|
|
3825
|
+
};
|
|
3826
|
+
}
|
|
3827
|
+
if (file && typeof file === "object") {
|
|
3828
|
+
const rec = file;
|
|
3829
|
+
if (typeof rec.size === "number" && sizeBytes === void 0) {
|
|
3830
|
+
sizeBytes = rec.size;
|
|
3831
|
+
}
|
|
3832
|
+
if (typeof rec.originalname === "string" && !fileName) {
|
|
3833
|
+
fileName = rec.originalname;
|
|
3834
|
+
}
|
|
3835
|
+
if (typeof rec.mimetype === "string" && !format) {
|
|
3836
|
+
format = rec.mimetype;
|
|
3837
|
+
}
|
|
3838
|
+
if (isUint8Array(rec.buffer)) {
|
|
3839
|
+
if (sizeBytes === void 0) sizeBytes = rec.buffer.byteLength;
|
|
3840
|
+
} else if (isUint8Array(file)) {
|
|
3841
|
+
if (sizeBytes === void 0) sizeBytes = file.byteLength;
|
|
3842
|
+
}
|
|
3843
|
+
} else if (typeof file === "string" && !fileName) {
|
|
3844
|
+
fileName = resolveFileName(file);
|
|
3845
|
+
}
|
|
3846
|
+
if (sizeBytes !== void 0 && sizeBytes <= 0) {
|
|
3847
|
+
errors.push("No file chosen");
|
|
3848
|
+
}
|
|
3849
|
+
const nameToCheck = (fileName || format || "").toLowerCase();
|
|
3850
|
+
if (nameToCheck) {
|
|
3851
|
+
const isMp4 = nameToCheck.endsWith(".mp4") || nameToCheck.includes("video/mp4") || nameToCheck.includes("h264");
|
|
3852
|
+
if (!isMp4) {
|
|
3853
|
+
errors.push("\u0110\u1ECBnh d\u1EA1ng video kh\xF4ng h\u1EE3p l\u1EC7, y\xEAu c\u1EA7u \u0111\u1ECBnh d\u1EA1ng .MP4 (H.264).");
|
|
3854
|
+
}
|
|
3855
|
+
}
|
|
3856
|
+
const MAX_VIDEO_BYTES = 150 * 1024 * 1024;
|
|
3857
|
+
if (sizeBytes !== void 0 && sizeBytes > MAX_VIDEO_BYTES) {
|
|
3858
|
+
const sizeMB = (sizeBytes / (1024 * 1024)).toFixed(2);
|
|
3859
|
+
errors.push(`Dung l\u01B0\u1EE3ng video v\u01B0\u1EE3t qu\xE1 gi\u1EDBi h\u1EA1n t\u1ED1i \u0111a 150MB (dung l\u01B0\u1EE3ng hi\u1EC7n t\u1EA1i: ${sizeMB}MB).`);
|
|
3860
|
+
}
|
|
3861
|
+
if (durationSeconds !== void 0 && durationSeconds > 60) {
|
|
3862
|
+
errors.push(`Th\u1EDDi l\u01B0\u1EE3ng video v\u01B0\u1EE3t qu\xE1 gi\u1EDBi h\u1EA1n t\u1ED1i \u0111a 60 gi\xE2y (th\u1EDDi l\u01B0\u1EE3ng hi\u1EC7n t\u1EA1i: ${durationSeconds} gi\xE2y).`);
|
|
3863
|
+
}
|
|
3864
|
+
let ratioLabel;
|
|
3865
|
+
if (width !== void 0 && height !== void 0 && width > 0 && height > 0) {
|
|
3866
|
+
const ratio = width / height;
|
|
3867
|
+
const is16_9 = Math.abs(ratio - 16 / 9) <= 0.06;
|
|
3868
|
+
const is9_16 = Math.abs(ratio - 9 / 16) <= 0.04;
|
|
3869
|
+
const is1_1 = Math.abs(ratio - 1) <= 0.05;
|
|
3870
|
+
if (is16_9) ratioLabel = "16:9";
|
|
3871
|
+
else if (is9_16) ratioLabel = "9:16";
|
|
3872
|
+
else if (is1_1) ratioLabel = "1:1";
|
|
3873
|
+
else {
|
|
3874
|
+
ratioLabel = `${width}:${height} (~${ratio.toFixed(2)})`;
|
|
3875
|
+
errors.push(`T\u1EC9 l\u1EC7 khung h\xECnh video ph\u1EA3i l\xE0 16:9, 9:16 ho\u1EB7c 1:1 (t\u1EC9 l\u1EC7 hi\u1EC7n t\u1EA1i: ${width}x${height} - ${ratioLabel}).`);
|
|
3876
|
+
}
|
|
3877
|
+
}
|
|
3878
|
+
const isValid = errors.length === 0;
|
|
3879
|
+
return {
|
|
3880
|
+
isValid,
|
|
3881
|
+
status: isValid ? "VALID" : "INVALID",
|
|
3882
|
+
errors,
|
|
3883
|
+
metadata: {
|
|
3884
|
+
fileDetected: true,
|
|
3885
|
+
sizeBytes,
|
|
3886
|
+
width,
|
|
3887
|
+
height,
|
|
3888
|
+
durationSeconds,
|
|
3889
|
+
format: format || (fileName ? fileName.split(".").pop() : void 0),
|
|
3890
|
+
aspectRatio: ratioLabel
|
|
3891
|
+
}
|
|
3892
|
+
};
|
|
2210
3893
|
}
|
|
2211
|
-
|
|
2212
|
-
|
|
3894
|
+
};
|
|
3895
|
+
|
|
3896
|
+
// src/services/ads.service.ts
|
|
3897
|
+
var ZaloAdsService = class extends ZaloCampaignsService {
|
|
3898
|
+
account;
|
|
3899
|
+
audiences;
|
|
3900
|
+
targeting;
|
|
3901
|
+
reports;
|
|
3902
|
+
conversions;
|
|
3903
|
+
pixel;
|
|
3904
|
+
automatedRules;
|
|
3905
|
+
rules;
|
|
3906
|
+
flows;
|
|
3907
|
+
media;
|
|
3908
|
+
campaigns;
|
|
3909
|
+
constructor(client) {
|
|
3910
|
+
super(client);
|
|
3911
|
+
this.account = new ZaloAccountService(client);
|
|
3912
|
+
this.audiences = new ZaloAudiencesService(client);
|
|
3913
|
+
this.targeting = this.audiences;
|
|
3914
|
+
this.reports = new ZaloReportsService(client);
|
|
3915
|
+
this.conversions = new ZaloConversionsService(client);
|
|
3916
|
+
this.pixel = this.conversions;
|
|
3917
|
+
this.automatedRules = new ZaloAutomatedRulesService(client);
|
|
3918
|
+
this.rules = this.automatedRules;
|
|
3919
|
+
this.flows = new ZaloFlowsService(client);
|
|
3920
|
+
this.media = new ZaloMediaService(client);
|
|
3921
|
+
this.campaigns = this;
|
|
3922
|
+
}
|
|
3923
|
+
// =========================================================================
|
|
3924
|
+
// Delegations -> this.account
|
|
3925
|
+
// =========================================================================
|
|
3926
|
+
getApiWhoami(request = {}, options) {
|
|
3927
|
+
return this.account.getApiWhoami(request, options);
|
|
2213
3928
|
}
|
|
2214
|
-
|
|
2215
|
-
return this.
|
|
3929
|
+
getApiPaymentTransactionHistory(request, options) {
|
|
3930
|
+
return this.account.getApiPaymentTransactionHistory(request, options);
|
|
2216
3931
|
}
|
|
2217
|
-
|
|
2218
|
-
return this.
|
|
3932
|
+
getApiBaAccountAllaccessors(request = {}, options) {
|
|
3933
|
+
return this.account.getApiBaAccountAllaccessors(request, options);
|
|
2219
3934
|
}
|
|
2220
|
-
|
|
2221
|
-
return this.
|
|
3935
|
+
getApiBaAccountAllgrantedmembers(request = {}, options) {
|
|
3936
|
+
return this.account.getApiBaAccountAllgrantedmembers(request, options);
|
|
2222
3937
|
}
|
|
2223
|
-
|
|
2224
|
-
return this.
|
|
3938
|
+
listAgencyCustomersWithBudget(request = { limit: 15, offset: 0, joinDateAsc: true }, options) {
|
|
3939
|
+
return this.account.listAgencyCustomersWithBudget(request, options);
|
|
2225
3940
|
}
|
|
2226
|
-
|
|
2227
|
-
return this.
|
|
3941
|
+
getApiNotifiesHeader(request = {}, options) {
|
|
3942
|
+
return this.account.getApiNotifiesHeader(request, options);
|
|
2228
3943
|
}
|
|
2229
|
-
|
|
2230
|
-
return this.
|
|
3944
|
+
getApiLpNews(request = {}, options) {
|
|
3945
|
+
return this.account.getApiLpNews(request, options);
|
|
2231
3946
|
}
|
|
2232
|
-
|
|
2233
|
-
|
|
3947
|
+
// =========================================================================
|
|
3948
|
+
// Delegations -> this.audiences
|
|
3949
|
+
// =========================================================================
|
|
3950
|
+
postApiAdEstimateaudience(request, options) {
|
|
3951
|
+
return this.audiences.postApiAdEstimateaudience(request, options);
|
|
2234
3952
|
}
|
|
2235
3953
|
getApiAdGetlistadadvancetargeting(request = {}, options) {
|
|
2236
|
-
return this.
|
|
3954
|
+
return this.audiences.getApiAdGetlistadadvancetargeting(request, options);
|
|
2237
3955
|
}
|
|
2238
|
-
|
|
2239
|
-
return this.
|
|
3956
|
+
getApiCustomAudienceAll(request = {}, options) {
|
|
3957
|
+
return this.audiences.getApiCustomAudienceAll(request, options);
|
|
2240
3958
|
}
|
|
2241
|
-
|
|
2242
|
-
return this.
|
|
3959
|
+
createCustomAudience(request, options) {
|
|
3960
|
+
return this.audiences.createCustomAudience(request, options);
|
|
2243
3961
|
}
|
|
2244
|
-
|
|
2245
|
-
return this.
|
|
3962
|
+
deleteCustomAudience(request, options) {
|
|
3963
|
+
return this.audiences.deleteCustomAudience(request, options);
|
|
2246
3964
|
}
|
|
2247
|
-
|
|
2248
|
-
return this.
|
|
3965
|
+
uploadCustomAudiencePhoneList(request, options) {
|
|
3966
|
+
return this.audiences.uploadCustomAudiencePhoneList(request, options);
|
|
2249
3967
|
}
|
|
2250
|
-
|
|
2251
|
-
|
|
3968
|
+
/** Tạo mới 'Nhóm đối tượng đã lưu' (`caType = 1` - `DEFAULT`) trên Zalo Ads (`POST /api/ad/audience`). */
|
|
3969
|
+
createSavedAudience(request, options) {
|
|
3970
|
+
return this.audiences.createSavedAudience(request, options);
|
|
2252
3971
|
}
|
|
2253
|
-
|
|
2254
|
-
|
|
3972
|
+
/** Tạo mới Nhóm đối tượng từ danh sách Số điện thoại (`caType = 3` - `PHONE_LIST`). */
|
|
3973
|
+
createPhoneAudience(request, options) {
|
|
3974
|
+
return this.audiences.createPhoneAudience(request, options);
|
|
2255
3975
|
}
|
|
2256
|
-
|
|
2257
|
-
|
|
3976
|
+
/** Tạo mới Nhóm đối tượng tương tự Lookalike (`caType = 6` - `LOOKALIKE`). */
|
|
3977
|
+
createLookalikeAudience(request, options) {
|
|
3978
|
+
return this.audiences.createLookalikeAudience(request, options);
|
|
2258
3979
|
}
|
|
2259
|
-
|
|
2260
|
-
|
|
3980
|
+
/** Tạo mới Nhóm đối tượng phát sinh sự kiện trên Zalo Form (`caType = 12` - `FORM_EVENT_AUDIENCE`). */
|
|
3981
|
+
createFormEventAudience(request, options) {
|
|
3982
|
+
return this.audiences.createFormEventAudience(request, options);
|
|
2261
3983
|
}
|
|
2262
|
-
|
|
2263
|
-
|
|
3984
|
+
/** Tạo mới Nhóm đối tượng phát sinh sự kiện trên Kịch bản Tin nhắn OA (`caType = 11` - `MESSAGE_AUDIENCE`). */
|
|
3985
|
+
createMessageOaEventAudience(request, options) {
|
|
3986
|
+
return this.audiences.createMessageOaEventAudience(request, options);
|
|
2264
3987
|
}
|
|
2265
|
-
|
|
2266
|
-
|
|
3988
|
+
/** Tạo mới Nhóm đối tượng phát sinh sự kiện trên Kịch bản Tin nhắn cá nhân (`caType = 14` - `MESSAGE_PERSONAL_EVENT_AUDIENCE`). */
|
|
3989
|
+
createMessagePersonalEventAudience(request, options) {
|
|
3990
|
+
return this.audiences.createMessagePersonalEventAudience(request, options);
|
|
2267
3991
|
}
|
|
2268
|
-
|
|
2269
|
-
|
|
3992
|
+
/** Tạo mới Nhóm đối tượng từ Trung tâm Lead - Zalo Form (`caType = 10` - `FORM_AUDIENCE`). */
|
|
3993
|
+
createFormLeadAudience(request, options) {
|
|
3994
|
+
return this.audiences.createFormLeadAudience(request, options);
|
|
2270
3995
|
}
|
|
2271
|
-
|
|
2272
|
-
|
|
3996
|
+
/** Tạo mới Nhóm đối tượng từ Trung tâm Lead - Commerce Form (`caType = 15` - `COMMERCE_FORM_AUDIENCE`). */
|
|
3997
|
+
createCommerceFormAudience(request, options) {
|
|
3998
|
+
return this.audiences.createCommerceFormAudience(request, options);
|
|
2273
3999
|
}
|
|
2274
|
-
|
|
2275
|
-
|
|
4000
|
+
/** Tạo mới Nhóm đối tượng từ Trung tâm Lead - Kịch bản Tin nhắn OA (`caType = 13` - `MESSAGE_OA_AUDIENCE`). */
|
|
4001
|
+
createMessageOaLeadAudience(request, options) {
|
|
4002
|
+
return this.audiences.createMessageOaLeadAudience(request, options);
|
|
2276
4003
|
}
|
|
2277
|
-
|
|
2278
|
-
|
|
4004
|
+
/** Tạo mới Nhóm đối tượng từ Dữ liệu chuyển đổi Lead Signal (`caType = 16` - `LEAD_SIGNAL_AUDIENCE`). */
|
|
4005
|
+
createLeadSignalAudience(request, options) {
|
|
4006
|
+
return this.audiences.createLeadSignalAudience(request, options);
|
|
2279
4007
|
}
|
|
4008
|
+
// =========================================================================
|
|
4009
|
+
// Delegations -> this.reports
|
|
4010
|
+
// =========================================================================
|
|
2280
4011
|
getReportapiV2Ads(request, options) {
|
|
2281
|
-
return this.
|
|
4012
|
+
return this.reports.getReportapiV2Ads(request, options);
|
|
2282
4013
|
}
|
|
2283
4014
|
getReportapiV2Campaigns(request = {}, options) {
|
|
2284
|
-
return this.
|
|
4015
|
+
return this.reports.getReportapiV2Campaigns(request, options);
|
|
2285
4016
|
}
|
|
2286
|
-
getReportapiV2UniqueUser(request
|
|
2287
|
-
return this.
|
|
4017
|
+
getReportapiV2UniqueUser(request, options) {
|
|
4018
|
+
return this.reports.getReportapiV2UniqueUser(request, options);
|
|
2288
4019
|
}
|
|
2289
4020
|
getReportapiV3Campaigns(request, options) {
|
|
2290
|
-
|
|
2291
|
-
filter: "[]",
|
|
2292
|
-
agencyId: 0,
|
|
2293
|
-
...request
|
|
2294
|
-
};
|
|
2295
|
-
return this.client.requestWithoutBody(OP_ZaloAdsGetReportapiV3Campaigns, this.client.toTransportInput(OP_ZaloAdsGetReportapiV3Campaigns, normalized), options);
|
|
2296
|
-
}
|
|
2297
|
-
getZaapiCampaignReportcampaign(request = {}, options) {
|
|
2298
|
-
return this.client.requestWithoutBody(OP_ZaloAdsGetZaapiCampaignReportcampaign, this.client.toTransportInput(OP_ZaloAdsGetZaapiCampaignReportcampaign, request), options);
|
|
2299
|
-
}
|
|
2300
|
-
getZaapiCheckcamphasmanyads(request = {}, options) {
|
|
2301
|
-
return this.client.requestWithoutBody(OP_ZaloAdsGetZaapiCheckcamphasmanyads, this.client.toTransportInput(OP_ZaloAdsGetZaapiCheckcamphasmanyads, request), options);
|
|
2302
|
-
}
|
|
2303
|
-
getZaapiGetadsfromcampaignid(request = {}, options) {
|
|
2304
|
-
return this.client.requestWithoutBody(OP_ZaloAdsGetZaapiGetadsfromcampaignid, this.client.toTransportInput(OP_ZaloAdsGetZaapiGetadsfromcampaignid, request), options);
|
|
2305
|
-
}
|
|
2306
|
-
getZaapiGetallpages(request = {}, options) {
|
|
2307
|
-
return this.client.requestWithoutBody(OP_ZaloAdsGetZaapiGetallpages, this.client.toTransportInput(OP_ZaloAdsGetZaapiGetallpages, request), options);
|
|
4021
|
+
return this.reports.getReportapiV3Campaigns(request, options);
|
|
2308
4022
|
}
|
|
2309
|
-
|
|
2310
|
-
return this.
|
|
2311
|
-
}
|
|
2312
|
-
getZaapiGetownedarticles(request, options) {
|
|
2313
|
-
return this.client.requestWithoutBody(OP_ZaloAdsGetZaapiGetownedarticles, this.client.toTransportInput(OP_ZaloAdsGetZaapiGetownedarticles, request), options);
|
|
4023
|
+
getReportOverview(request, options) {
|
|
4024
|
+
return this.reports.getReportOverview(request, options);
|
|
2314
4025
|
}
|
|
2315
|
-
|
|
2316
|
-
return this.
|
|
4026
|
+
getDemographicsReport(request, options) {
|
|
4027
|
+
return this.reports.getDemographicsReport(request, options);
|
|
2317
4028
|
}
|
|
2318
|
-
|
|
2319
|
-
return this.
|
|
4029
|
+
getZaapiCampaignReportcampaign(request, options) {
|
|
4030
|
+
return this.reports.getZaapiCampaignReportcampaign(request, options);
|
|
2320
4031
|
}
|
|
2321
|
-
|
|
2322
|
-
return this.
|
|
4032
|
+
listCustomReports(request = {}, options) {
|
|
4033
|
+
return this.reports.listCustomReports(request, options);
|
|
2323
4034
|
}
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
limit: 15,
|
|
2327
|
-
offset: 0,
|
|
2328
|
-
joinDateAsc: true,
|
|
2329
|
-
...request
|
|
2330
|
-
};
|
|
2331
|
-
return this.client.requestWithoutBody(OP_ZaloAdsListAgencyCustomersWithBudget, this.client.toTransportInput(OP_ZaloAdsListAgencyCustomersWithBudget, normalized), options);
|
|
4035
|
+
upsertCustomReport(request, options) {
|
|
4036
|
+
return this.reports.upsertCustomReport(request, options);
|
|
2332
4037
|
}
|
|
2333
|
-
|
|
2334
|
-
return this.
|
|
4038
|
+
deleteCustomReport(request, options) {
|
|
4039
|
+
return this.reports.deleteCustomReport(request, options);
|
|
2335
4040
|
}
|
|
2336
|
-
|
|
2337
|
-
return this.
|
|
4041
|
+
listReportFilters(request, options) {
|
|
4042
|
+
return this.reports.listReportFilters(request, options);
|
|
2338
4043
|
}
|
|
2339
|
-
|
|
2340
|
-
|
|
4044
|
+
// =========================================================================
|
|
4045
|
+
// Delegations -> this.conversions
|
|
4046
|
+
// =========================================================================
|
|
4047
|
+
createConversion(request, options) {
|
|
4048
|
+
return this.conversions.createConversion(request, options);
|
|
4049
|
+
}
|
|
4050
|
+
deleteConversion(request, options) {
|
|
4051
|
+
return this.conversions.deleteConversion(request, options);
|
|
4052
|
+
}
|
|
4053
|
+
getApiConversionAll(request = {}, options) {
|
|
4054
|
+
return this.conversions.getApiConversionAll(request, options);
|
|
4055
|
+
}
|
|
4056
|
+
getApiConversionStandardEvents(request = {}, options) {
|
|
4057
|
+
return this.conversions.getApiConversionStandardEvents(request, options);
|
|
2341
4058
|
}
|
|
2342
4059
|
listPersonalPixelLabels(request = {}, options) {
|
|
2343
|
-
return this.
|
|
4060
|
+
return this.conversions.listPersonalPixelLabels(request, options);
|
|
2344
4061
|
}
|
|
2345
|
-
|
|
2346
|
-
|
|
4062
|
+
/** Lấy danh sách tài khoản Zalo Official Account (OA) có dữ liệu chuyển đổi (Lead Signal) (`GET /api/ad/audience/leadSignal/oas`). */
|
|
4063
|
+
listLeadSignalOas(options) {
|
|
4064
|
+
return this.conversions.listLeadSignalOas(options);
|
|
2347
4065
|
}
|
|
2348
|
-
|
|
2349
|
-
|
|
4066
|
+
/** Lấy danh sách rút gọn gồm ID và tên của toàn bộ các sự kiện chuyển đổi (Conversion) đã tạo trên tài khoản quảng cáo Zalo Ads (`GET /api/conversion/names`). */
|
|
4067
|
+
listConversionNames(request = {}, options) {
|
|
4068
|
+
return this.conversions.listConversionNames(request, options);
|
|
2350
4069
|
}
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
File: request.File ?? request.file
|
|
2355
|
-
};
|
|
2356
|
-
return this.client.requestMultipart(OP_ZaloAdsPostApiMemberUploadImage, this.client.toTransportInput(OP_ZaloAdsPostApiMemberUploadImage, normalized), options);
|
|
4070
|
+
/** Alias cho `listConversionNames` (`GET /api/conversion/names`). */
|
|
4071
|
+
getApiConversionNames(request = {}, options) {
|
|
4072
|
+
return this.conversions.getApiConversionNames(request, options);
|
|
2357
4073
|
}
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
4074
|
+
// =========================================================================
|
|
4075
|
+
// Delegations -> this.automatedRules
|
|
4076
|
+
// =========================================================================
|
|
4077
|
+
listAutomatedRules(request = {}, options) {
|
|
4078
|
+
return this.automatedRules.listAutomatedRules(request, options);
|
|
2361
4079
|
}
|
|
2362
|
-
|
|
2363
|
-
return this.
|
|
4080
|
+
createAutomatedRule(request, options) {
|
|
4081
|
+
return this.automatedRules.createAutomatedRule(request, options);
|
|
2364
4082
|
}
|
|
2365
|
-
|
|
2366
|
-
return this.
|
|
4083
|
+
updateAutomatedRule(request, options) {
|
|
4084
|
+
return this.automatedRules.updateAutomatedRule(request, options);
|
|
2367
4085
|
}
|
|
2368
|
-
|
|
2369
|
-
return this.
|
|
4086
|
+
changeAutomatedRuleStatus(request, options) {
|
|
4087
|
+
return this.automatedRules.changeAutomatedRuleStatus(request, options);
|
|
2370
4088
|
}
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
return this.updateEcommerceAd(request, options);
|
|
4089
|
+
getAutomatedRuleHistory(request, options) {
|
|
4090
|
+
return this.automatedRules.getAutomatedRuleHistory(request, options);
|
|
2374
4091
|
}
|
|
2375
|
-
|
|
2376
|
-
return this.
|
|
4092
|
+
deleteAutomatedRule(request, options) {
|
|
4093
|
+
return this.automatedRules.deleteAutomatedRule(request, options);
|
|
2377
4094
|
}
|
|
2378
|
-
|
|
2379
|
-
|
|
4095
|
+
// =========================================================================
|
|
4096
|
+
// Delegations -> this.flows
|
|
4097
|
+
// =========================================================================
|
|
4098
|
+
listFlowsByOfficialAccount(request, options) {
|
|
4099
|
+
return this.flows.listFlowsByOfficialAccount(request, options);
|
|
2380
4100
|
}
|
|
2381
|
-
|
|
2382
|
-
return this.
|
|
4101
|
+
createFlow(request, options) {
|
|
4102
|
+
return this.flows.createFlow(request, options);
|
|
2383
4103
|
}
|
|
2384
|
-
|
|
2385
|
-
return this.
|
|
4104
|
+
updateFlow(request, options) {
|
|
4105
|
+
return this.flows.updateFlow(request, options);
|
|
2386
4106
|
}
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
4107
|
+
// =========================================================================
|
|
4108
|
+
// Delegations -> this.media
|
|
4109
|
+
// =========================================================================
|
|
4110
|
+
getApiFilegroups(request = {}, options) {
|
|
4111
|
+
return this.media.getApiFilegroups(request, options);
|
|
2390
4112
|
}
|
|
2391
|
-
|
|
2392
|
-
return this.
|
|
4113
|
+
getApiMediaItems(request, options) {
|
|
4114
|
+
return this.media.getApiMediaItems(request, options);
|
|
2393
4115
|
}
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
return this.updatePostAd(request, options);
|
|
4116
|
+
getApiMemberFiles(request = {}, options) {
|
|
4117
|
+
return this.media.getApiMemberFiles(request, options);
|
|
2397
4118
|
}
|
|
2398
|
-
|
|
2399
|
-
return this.
|
|
4119
|
+
postApiMediaSave(request, options) {
|
|
4120
|
+
return this.media.postApiMediaSave(request, options);
|
|
4121
|
+
}
|
|
4122
|
+
postApiMemberUploadImage(request, options) {
|
|
4123
|
+
return this.media.postApiMemberUploadImage(request, options);
|
|
4124
|
+
}
|
|
4125
|
+
/** Alias tiện lợi cho `postApiMemberUploadImage` (`POST /api/member/upload-image`). */
|
|
4126
|
+
uploadImage(request, options) {
|
|
4127
|
+
return this.media.uploadImage(request, options);
|
|
2400
4128
|
}
|
|
2401
4129
|
uploadVideo(request, options) {
|
|
2402
|
-
return this.
|
|
4130
|
+
return this.media.uploadVideo(request, options);
|
|
2403
4131
|
}
|
|
2404
|
-
|
|
2405
|
-
|
|
4132
|
+
/**
|
|
4133
|
+
* Kiểm tra tính hợp lệ của tệp Ảnh theo quy chuẩn Zalo Ads (độc lập cho backend).
|
|
4134
|
+
* Tiêu chí: Có file, Dung lượng tối đa 2MB, Kích thước tối thiểu 150x150, Định dạng JPG/PNG.
|
|
4135
|
+
*/
|
|
4136
|
+
validateImage(input) {
|
|
4137
|
+
return this.media.validateImage(input);
|
|
4138
|
+
}
|
|
4139
|
+
/**
|
|
4140
|
+
* Kiểm tra tính hợp lệ của tệp Video theo quy chuẩn Zalo Ads (độc lập cho backend).
|
|
4141
|
+
* Tiêu chí: Có file, Định dạng .MP4 H.264, Dung lượng tối đa 150MB, Thời lượng tối đa 60s, Tỉ lệ 16:9, 9:16 hoặc 1:1.
|
|
4142
|
+
*/
|
|
4143
|
+
validateVideo(input) {
|
|
4144
|
+
return this.media.validateVideo(input);
|
|
2406
4145
|
}
|
|
2407
4146
|
};
|
|
2408
4147
|
|
|
@@ -2434,7 +4173,301 @@ var ZaloChatWidgetService = class {
|
|
|
2434
4173
|
}
|
|
2435
4174
|
};
|
|
2436
4175
|
|
|
4176
|
+
// src/validators/forms.validator.ts
|
|
4177
|
+
function isValidUrl(val) {
|
|
4178
|
+
if (typeof val !== "string" || val.trim() === "") return false;
|
|
4179
|
+
try {
|
|
4180
|
+
const url = new URL(val);
|
|
4181
|
+
return url.protocol === "http:" || url.protocol === "https:";
|
|
4182
|
+
} catch {
|
|
4183
|
+
return false;
|
|
4184
|
+
}
|
|
4185
|
+
}
|
|
4186
|
+
function validateCreateFormRequest(input) {
|
|
4187
|
+
const errors = [];
|
|
4188
|
+
if (!input || typeof input !== "object") {
|
|
4189
|
+
return {
|
|
4190
|
+
isValid: false,
|
|
4191
|
+
errors: ["D\u1EEF li\u1EC7u y\xEAu c\u1EA7u t\u1EA1o Form ph\u1EA3i l\xE0 m\u1ED9t object."],
|
|
4192
|
+
data: void 0
|
|
4193
|
+
};
|
|
4194
|
+
}
|
|
4195
|
+
let raw = input;
|
|
4196
|
+
if (typeof input.data === "string") {
|
|
4197
|
+
try {
|
|
4198
|
+
raw = JSON.parse(input.data);
|
|
4199
|
+
} catch {
|
|
4200
|
+
errors.push("Tr\u01B0\u1EDDng 'data' kh\xF4ng ph\u1EA3i l\xE0 chu\u1ED7i JSON h\u1EE3p l\u1EC7.");
|
|
4201
|
+
return { isValid: false, errors, data: void 0 };
|
|
4202
|
+
}
|
|
4203
|
+
} else if (typeof input.data === "object" && input.data !== null) {
|
|
4204
|
+
raw = input.data;
|
|
4205
|
+
}
|
|
4206
|
+
const oaIdRaw = raw.oaId;
|
|
4207
|
+
let cleanOaId = "";
|
|
4208
|
+
if (typeof oaIdRaw === "string" && /^[0-9]+$/.test(oaIdRaw.trim())) {
|
|
4209
|
+
cleanOaId = oaIdRaw.trim();
|
|
4210
|
+
} else if (typeof oaIdRaw === "number" && Number.isInteger(oaIdRaw) && oaIdRaw > 0) {
|
|
4211
|
+
cleanOaId = String(oaIdRaw);
|
|
4212
|
+
} else {
|
|
4213
|
+
errors.push("Tr\u01B0\u1EDDng 'oaId' b\u1EAFt bu\u1ED9c ph\u1EA3i l\xE0 chu\u1ED7i s\u1ED1 nguy\xEAn d\u01B0\u01A1ng \u0111\u1EA1i di\u1EC7n cho pageId n\u1ED9i b\u1ED9 c\u1EE7a OA (v\xED d\u1EE5: '429753475').");
|
|
4214
|
+
}
|
|
4215
|
+
const title = typeof raw.title === "string" ? raw.title.trim() : "";
|
|
4216
|
+
if (!title) {
|
|
4217
|
+
errors.push("Tr\u01B0\u1EDDng 'title' (ti\xEAu \u0111\u1EC1 form) l\xE0 b\u1EAFt bu\u1ED9c.");
|
|
4218
|
+
} else if (title.length < 2 || title.length > 40) {
|
|
4219
|
+
errors.push(`Tr\u01B0\u1EDDng 'title' ph\u1EA3i c\xF3 \u0111\u1ED9 d\xE0i t\u1EEB 2 \u0111\u1EBFn 40 k\xFD t\u1EF1 (hi\u1EC7n t\u1EA1i: ${title.length} k\xFD t\u1EF1).`);
|
|
4220
|
+
}
|
|
4221
|
+
const formName = typeof raw.formName === "string" ? raw.formName.trim() : "";
|
|
4222
|
+
if (!formName) {
|
|
4223
|
+
errors.push("Tr\u01B0\u1EDDng 'formName' (t\xEAn qu\u1EA3n tr\u1ECB form) l\xE0 b\u1EAFt bu\u1ED9c.");
|
|
4224
|
+
} else if (formName.length < 2 || formName.length > 100) {
|
|
4225
|
+
errors.push(`Tr\u01B0\u1EDDng 'formName' ph\u1EA3i c\xF3 \u0111\u1ED9 d\xE0i t\u1EEB 2 \u0111\u1EBFn 100 k\xFD t\u1EF1 (hi\u1EC7n t\u1EA1i: ${formName.length} k\xFD t\u1EF1).`);
|
|
4226
|
+
}
|
|
4227
|
+
let cleanDescription = void 0;
|
|
4228
|
+
if (raw.description !== void 0 && raw.description !== null) {
|
|
4229
|
+
const desc = String(raw.description).trim();
|
|
4230
|
+
if (desc.length > 600) {
|
|
4231
|
+
errors.push(`Tr\u01B0\u1EDDng 'description' kh\xF4ng \u0111\u01B0\u1EE3c v\u01B0\u1EE3t qu\xE1 600 k\xFD t\u1EF1 (hi\u1EC7n t\u1EA1i: ${desc.length} k\xFD t\u1EF1).`);
|
|
4232
|
+
} else {
|
|
4233
|
+
cleanDescription = desc;
|
|
4234
|
+
}
|
|
4235
|
+
}
|
|
4236
|
+
const coverPhoto = typeof raw.coverPhoto === "string" ? raw.coverPhoto.trim() : "";
|
|
4237
|
+
if (!coverPhoto) {
|
|
4238
|
+
errors.push("Tr\u01B0\u1EDDng 'coverPhoto' (\u1EA3nh b\xECa form) l\xE0 b\u1EAFt bu\u1ED9c.");
|
|
4239
|
+
} else if (!isValidUrl(coverPhoto)) {
|
|
4240
|
+
errors.push(`Tr\u01B0\u1EDDng 'coverPhoto' ph\u1EA3i l\xE0 URL h\u1EE3p l\u1EC7 (http:// ho\u1EB7c https://).`);
|
|
4241
|
+
}
|
|
4242
|
+
const submitTitle = typeof raw.submitTitle === "string" && raw.submitTitle.trim() !== "" ? raw.submitTitle.trim() : "G\u1EEDi th\xF4ng tin th\xE0nh c\xF4ng";
|
|
4243
|
+
if (submitTitle.length > 90) {
|
|
4244
|
+
errors.push(`Tr\u01B0\u1EDDng 'submitTitle' kh\xF4ng \u0111\u01B0\u1EE3c v\u01B0\u1EE3t qu\xE1 90 k\xFD t\u1EF1 (hi\u1EC7n t\u1EA1i: ${submitTitle.length} k\xFD t\u1EF1).`);
|
|
4245
|
+
}
|
|
4246
|
+
const thanks = typeof raw.thanks === "string" && raw.thanks.trim() !== "" ? raw.thanks.trim() : "C\u1EA3m \u01A1n b\u1EA1n \u0111\xE3 g\u1EEDi th\xF4ng tin. Ch\xFAng t\xF4i s\u1EBD li\xEAn h\u1EC7 trong th\u1EDDi gian s\u1EDBm nh\u1EA5t.";
|
|
4247
|
+
if (thanks.length > 255) {
|
|
4248
|
+
errors.push(`Tr\u01B0\u1EDDng 'thanks' kh\xF4ng \u0111\u01B0\u1EE3c v\u01B0\u1EE3t qu\xE1 255 k\xFD t\u1EF1 (hi\u1EC7n t\u1EA1i: ${thanks.length} k\xFD t\u1EF1).`);
|
|
4249
|
+
}
|
|
4250
|
+
const gotoActionType = raw.gotoActionType === 0 ? 0 : 1;
|
|
4251
|
+
const gotoText = typeof raw.gotoText === "string" && raw.gotoText.trim() !== "" ? raw.gotoText.trim() : gotoActionType === 1 ? "Xem trang Web" : "\u0110\xF3ng l\u1EA1i";
|
|
4252
|
+
let cleanWebsite = void 0;
|
|
4253
|
+
if (gotoActionType === 1) {
|
|
4254
|
+
if (!raw.website || !isValidUrl(raw.website)) {
|
|
4255
|
+
errors.push("Khi 'gotoActionType' = 1 (m\u1EDF website), tr\u01B0\u1EDDng 'website' l\xE0 b\u1EAFt bu\u1ED9c v\xE0 ph\u1EA3i l\xE0 URL h\u1EE3p l\u1EC7.");
|
|
4256
|
+
} else {
|
|
4257
|
+
cleanWebsite = String(raw.website).trim();
|
|
4258
|
+
}
|
|
4259
|
+
}
|
|
4260
|
+
const useCustomConsent = Boolean(raw.useCustomConsent);
|
|
4261
|
+
let cleanConsentName = void 0;
|
|
4262
|
+
let cleanConsentUrl = void 0;
|
|
4263
|
+
if (useCustomConsent) {
|
|
4264
|
+
const cName = typeof raw.consentName === "string" ? raw.consentName.trim() : "";
|
|
4265
|
+
if (!cName) {
|
|
4266
|
+
errors.push("Khi 'useCustomConsent' = true, tr\u01B0\u1EDDng 'consentName' (ti\xEAu \u0111\u1EC1 \u0111i\u1EC1u kho\u1EA3n) l\xE0 b\u1EAFt bu\u1ED9c.");
|
|
4267
|
+
} else if (cName.length > 255) {
|
|
4268
|
+
errors.push(`Tr\u01B0\u1EDDng 'consentName' kh\xF4ng \u0111\u01B0\u1EE3c v\u01B0\u1EE3t qu\xE1 255 k\xFD t\u1EF1 (hi\u1EC7n t\u1EA1i: ${cName.length} k\xFD t\u1EF1).`);
|
|
4269
|
+
} else {
|
|
4270
|
+
cleanConsentName = cName;
|
|
4271
|
+
}
|
|
4272
|
+
if (!raw.consentUrl || !isValidUrl(raw.consentUrl)) {
|
|
4273
|
+
errors.push("Khi 'useCustomConsent' = true, tr\u01B0\u1EDDng 'consentUrl' ph\u1EA3i l\xE0 URL h\u1EE3p l\u1EC7 ch\u1EE9a ch\xEDnh s\xE1ch b\u1EA3o m\u1EADt.");
|
|
4274
|
+
} else {
|
|
4275
|
+
cleanConsentUrl = String(raw.consentUrl).trim();
|
|
4276
|
+
}
|
|
4277
|
+
}
|
|
4278
|
+
if (!Array.isArray(raw.questions) || raw.questions.length === 0) {
|
|
4279
|
+
errors.push("Bi\u1EC3u m\u1EABu b\u1EAFt bu\u1ED9c ph\u1EA3i c\xF3 \xEDt nh\u1EA5t 1 c\xE2u h\u1ECFi trong m\u1EA3ng 'questions'.");
|
|
4280
|
+
}
|
|
4281
|
+
const cleanQuestions = [];
|
|
4282
|
+
let hasPhonePrimary = false;
|
|
4283
|
+
let hasPhoneSecondary = false;
|
|
4284
|
+
if (Array.isArray(raw.questions)) {
|
|
4285
|
+
raw.questions.forEach((q, idx) => {
|
|
4286
|
+
const qPrefix = `C\xE2u h\u1ECFi [${idx}]`;
|
|
4287
|
+
if (!q || typeof q !== "object") {
|
|
4288
|
+
errors.push(`${qPrefix} ph\u1EA3i l\xE0 m\u1ED9t object.`);
|
|
4289
|
+
return;
|
|
4290
|
+
}
|
|
4291
|
+
const qTitle = typeof q.title === "string" ? q.title.trim() : "";
|
|
4292
|
+
if (qTitle.length < 2 || qTitle.length > 180) {
|
|
4293
|
+
errors.push(`${qPrefix}: Ti\xEAu \u0111\u1EC1 'title' ph\u1EA3i c\xF3 \u0111\u1ED9 d\xE0i t\u1EEB 2 \u0111\u1EBFn 180 k\xFD t\u1EF1.`);
|
|
4294
|
+
}
|
|
4295
|
+
if (!Array.isArray(q.answers) || q.answers.length === 0) {
|
|
4296
|
+
errors.push(`${qPrefix}: Ph\u1EA3i c\xF3 \xEDt nh\u1EA5t 1 \u0111\xE1p \xE1n trong m\u1EA3ng 'answers'.`);
|
|
4297
|
+
return;
|
|
4298
|
+
}
|
|
4299
|
+
const cleanAnswers = [];
|
|
4300
|
+
q.answers.forEach((ans, aIdx) => {
|
|
4301
|
+
const aType = Number(ans?.type);
|
|
4302
|
+
if (![2, 7, 13].includes(aType)) {
|
|
4303
|
+
errors.push(`${qPrefix} \u0111\xE1p \xE1n [${aIdx}]: 'type' ph\u1EA3i l\xE0 7 (H\u1ECD t\xEAn), 13 (S\u0110T chu\u1EA9n), ho\u1EB7c 2 (S\u0110T ph\u1EE5).`);
|
|
4304
|
+
}
|
|
4305
|
+
if (aType === 13) hasPhonePrimary = true;
|
|
4306
|
+
if (aType === 2) hasPhoneSecondary = true;
|
|
4307
|
+
cleanAnswers.push({
|
|
4308
|
+
type: aType,
|
|
4309
|
+
placeHolder: ans?.placeHolder ? String(ans.placeHolder).trim() : void 0,
|
|
4310
|
+
value: ans?.value ? String(ans.value).trim() : null,
|
|
4311
|
+
priority: typeof ans?.priority === "number" ? ans.priority : 500
|
|
4312
|
+
});
|
|
4313
|
+
});
|
|
4314
|
+
cleanQuestions.push({
|
|
4315
|
+
title: qTitle,
|
|
4316
|
+
type: typeof q.type === "number" ? q.type : 1,
|
|
4317
|
+
isRequired: q.isRequired !== void 0 ? Boolean(q.isRequired) : true,
|
|
4318
|
+
editDisabled: Boolean(q.editDisabled),
|
|
4319
|
+
priority: typeof q.priority === "number" ? q.priority : (idx + 1) * 100,
|
|
4320
|
+
answers: cleanAnswers
|
|
4321
|
+
});
|
|
4322
|
+
});
|
|
4323
|
+
}
|
|
4324
|
+
if (hasPhoneSecondary) {
|
|
4325
|
+
cleanQuestions.forEach((q) => {
|
|
4326
|
+
if (q.answers.some((a) => a.type === 13)) {
|
|
4327
|
+
q.editDisabled = true;
|
|
4328
|
+
}
|
|
4329
|
+
});
|
|
4330
|
+
}
|
|
4331
|
+
const cleanSections = [];
|
|
4332
|
+
if (Array.isArray(raw.sections)) {
|
|
4333
|
+
raw.sections.forEach((sec, sIdx) => {
|
|
4334
|
+
const sPrefix = `Section [${sIdx}]`;
|
|
4335
|
+
const sType = Number(sec?.type);
|
|
4336
|
+
if (isNaN(sType) || sType < 0 || sType > 4) {
|
|
4337
|
+
errors.push(`${sPrefix}: 'type' ph\u1EA3i l\xE0 s\u1ED1 t\u1EEB 0 \u0111\u1EBFn 4 (0=t\u1ED5ng quan, 1=chi ti\u1EBFt, 2=b\u1EA3ng gi\xE1, 3=\u01B0u \u0111i\u1EC3m, 4=\u01B0u \u0111\xE3i).`);
|
|
4338
|
+
}
|
|
4339
|
+
const sTitle = typeof sec?.title === "string" ? sec.title.trim() : "";
|
|
4340
|
+
if (sTitle.length > 60) {
|
|
4341
|
+
errors.push(`${sPrefix}: 'title' kh\xF4ng \u0111\u01B0\u1EE3c v\u01B0\u1EE3t qu\xE1 60 k\xFD t\u1EF1.`);
|
|
4342
|
+
}
|
|
4343
|
+
cleanSections.push({
|
|
4344
|
+
type: sType,
|
|
4345
|
+
title: sTitle,
|
|
4346
|
+
disable: Boolean(sec?.disable),
|
|
4347
|
+
expand: Boolean(sec?.expand),
|
|
4348
|
+
content: sec?.content ? sec.content : {}
|
|
4349
|
+
});
|
|
4350
|
+
});
|
|
4351
|
+
}
|
|
4352
|
+
const cleanData = {
|
|
4353
|
+
oaId: cleanOaId,
|
|
4354
|
+
title,
|
|
4355
|
+
formName,
|
|
4356
|
+
description: cleanDescription,
|
|
4357
|
+
coverPhoto,
|
|
4358
|
+
submitTitle,
|
|
4359
|
+
thanks,
|
|
4360
|
+
gotoActionType,
|
|
4361
|
+
gotoText,
|
|
4362
|
+
website: cleanWebsite,
|
|
4363
|
+
reviewSubmit: raw.reviewSubmit !== void 0 ? Boolean(raw.reviewSubmit) : true,
|
|
4364
|
+
questions: cleanQuestions,
|
|
4365
|
+
sections: cleanSections.length > 0 ? cleanSections : void 0,
|
|
4366
|
+
useCustomConsent,
|
|
4367
|
+
consentName: cleanConsentName,
|
|
4368
|
+
consentUrl: cleanConsentUrl
|
|
4369
|
+
};
|
|
4370
|
+
return {
|
|
4371
|
+
isValid: errors.length === 0,
|
|
4372
|
+
errors,
|
|
4373
|
+
data: errors.length === 0 ? cleanData : void 0
|
|
4374
|
+
};
|
|
4375
|
+
}
|
|
4376
|
+
function validateListFormsByOfficialAccountRequest(input) {
|
|
4377
|
+
const errors = [];
|
|
4378
|
+
if (!input || typeof input !== "object") {
|
|
4379
|
+
return { isValid: false, errors: ["Input ph\u1EA3i l\xE0 m\u1ED9t object."], data: void 0 };
|
|
4380
|
+
}
|
|
4381
|
+
const raw = input;
|
|
4382
|
+
let cleanOaId = "";
|
|
4383
|
+
if (typeof raw.oaId === "string" && /^[0-9]+$/.test(raw.oaId.trim())) {
|
|
4384
|
+
cleanOaId = raw.oaId.trim();
|
|
4385
|
+
} else if (typeof raw.oaId === "number" && Number.isInteger(raw.oaId) && raw.oaId > 0) {
|
|
4386
|
+
cleanOaId = String(raw.oaId);
|
|
4387
|
+
} else {
|
|
4388
|
+
errors.push("Tr\u01B0\u1EDDng 'oaId' b\u1EAFt bu\u1ED9c ph\u1EA3i l\xE0 chu\u1ED7i s\u1ED1 nguy\xEAn d\u01B0\u01A1ng \u0111\u1EA1i di\u1EC7n cho pageId c\u1EE7a OA.");
|
|
4389
|
+
}
|
|
4390
|
+
return {
|
|
4391
|
+
isValid: errors.length === 0,
|
|
4392
|
+
errors,
|
|
4393
|
+
data: errors.length === 0 ? { oaId: cleanOaId, isAll: raw.isAll !== void 0 ? Boolean(raw.isAll) : true } : void 0
|
|
4394
|
+
};
|
|
4395
|
+
}
|
|
4396
|
+
function validateListFormLeadsRequest(input) {
|
|
4397
|
+
const errors = [];
|
|
4398
|
+
if (!input || typeof input !== "object") {
|
|
4399
|
+
return { isValid: false, errors: ["Input ph\u1EA3i l\xE0 m\u1ED9t object."], data: void 0 };
|
|
4400
|
+
}
|
|
4401
|
+
const raw = input;
|
|
4402
|
+
const oaId = typeof raw.oaId === "string" ? raw.oaId.trim() : "";
|
|
4403
|
+
if (!oaId) {
|
|
4404
|
+
errors.push("Tr\u01B0\u1EDDng 'oaId' l\xE0 b\u1EAFt bu\u1ED9c (m\xE3 ch\u1EEF t\u1EEB getAuthSession, v\xED d\u1EE5 'J4UB9MRE497YDQKKK').");
|
|
4405
|
+
} else if (/^[0-9]+$/.test(oaId)) {
|
|
4406
|
+
errors.push("Tr\u01B0\u1EDDng 'oaId' tr\xEAn Lead Center ph\u1EA3i l\xE0 m\xE3 ch\u1EEF alphanumeric t\u1EEB getAuthSession, kh\xF4ng d\xF9ng chu\u1ED7i s\u1ED1 pageId (s\u1EBD b\u1ECB l\u1ED7i 403 Forbidden).");
|
|
4407
|
+
}
|
|
4408
|
+
const type = Number(raw.type);
|
|
4409
|
+
if (![1, 5].includes(type)) {
|
|
4410
|
+
errors.push("Tr\u01B0\u1EDDng 'type' ph\u1EA3i l\xE0 1 (ZALOFORM) ho\u1EB7c 5 (COMMERCE).");
|
|
4411
|
+
}
|
|
4412
|
+
const limit = typeof raw.limit === "number" && raw.limit > 0 ? Math.floor(raw.limit) : 20;
|
|
4413
|
+
const offset = typeof raw.offset === "number" && raw.offset >= 0 ? Math.floor(raw.offset) : 0;
|
|
4414
|
+
const status = typeof raw.status === "string" && raw.status.trim() !== "" ? raw.status.trim() : "2,6,1,0,7,4,5,3";
|
|
4415
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
4416
|
+
const fromTime = typeof raw.fromTime === "number" && raw.fromTime >= 0 ? Math.floor(raw.fromTime) : now - 90 * 86400;
|
|
4417
|
+
const toTime = typeof raw.toTime === "number" && raw.toTime >= 0 ? Math.floor(raw.toTime) : now;
|
|
4418
|
+
if (toTime < fromTime) {
|
|
4419
|
+
errors.push("M\u1ED1c th\u1EDDi gian k\u1EBFt th\xFAc 'toTime' ph\u1EA3i l\u1EDBn h\u01A1n ho\u1EB7c b\u1EB1ng 'fromTime'.");
|
|
4420
|
+
}
|
|
4421
|
+
return {
|
|
4422
|
+
isValid: errors.length === 0,
|
|
4423
|
+
errors,
|
|
4424
|
+
data: errors.length === 0 ? {
|
|
4425
|
+
oaId,
|
|
4426
|
+
type,
|
|
4427
|
+
limit,
|
|
4428
|
+
offset,
|
|
4429
|
+
status,
|
|
4430
|
+
fromTime,
|
|
4431
|
+
toTime,
|
|
4432
|
+
formIds: raw.formIds ? String(raw.formIds).trim() : void 0,
|
|
4433
|
+
keyword: raw.keyword ? String(raw.keyword).trim() : void 0,
|
|
4434
|
+
reason: raw.reason ? String(raw.reason).trim() : void 0,
|
|
4435
|
+
labelIds: raw.labelIds ? String(raw.labelIds).trim() : void 0,
|
|
4436
|
+
isCommerce: raw.isCommerce !== void 0 ? Boolean(raw.isCommerce) : false
|
|
4437
|
+
} : void 0
|
|
4438
|
+
};
|
|
4439
|
+
}
|
|
4440
|
+
var ZaloFormsValidator = {
|
|
4441
|
+
createForm: validateCreateFormRequest,
|
|
4442
|
+
listFormsByOfficialAccount: validateListFormsByOfficialAccountRequest,
|
|
4443
|
+
listFormLeads: validateListFormLeadsRequest
|
|
4444
|
+
};
|
|
4445
|
+
|
|
2437
4446
|
// src/services/forms.service.ts
|
|
4447
|
+
var OP_ZaloAdsCreateForm2 = {
|
|
4448
|
+
operationId: "zalo_ads_create_form",
|
|
4449
|
+
method: "POST",
|
|
4450
|
+
endpoint: "/api/form/create",
|
|
4451
|
+
baseUrl: "https://ads.zalo.me",
|
|
4452
|
+
binaryFields: [],
|
|
4453
|
+
pathFields: [],
|
|
4454
|
+
queryFields: [],
|
|
4455
|
+
headerFields: [],
|
|
4456
|
+
cookieFields: [],
|
|
4457
|
+
bodyFields: ["data"]
|
|
4458
|
+
};
|
|
4459
|
+
var OP_ZaloAdsListFormsByOfficialAccount2 = {
|
|
4460
|
+
operationId: "zalo_ads_list_forms_by_official_account",
|
|
4461
|
+
method: "GET",
|
|
4462
|
+
endpoint: "/api/form/getByOaId",
|
|
4463
|
+
baseUrl: "https://ads.zalo.me",
|
|
4464
|
+
binaryFields: [],
|
|
4465
|
+
pathFields: [],
|
|
4466
|
+
queryFields: ["oaId", "isAll"],
|
|
4467
|
+
headerFields: [],
|
|
4468
|
+
cookieFields: [],
|
|
4469
|
+
bodyFields: []
|
|
4470
|
+
};
|
|
2438
4471
|
var OP_ZaloFormsDisableFormLeadNotification = {
|
|
2439
4472
|
"operationId": "ZaloForms_disableFormLeadNotification",
|
|
2440
4473
|
"method": "POST",
|
|
@@ -2508,7 +4541,8 @@ var OP_ZaloFormsListConversationLeads = {
|
|
|
2508
4541
|
"keyword",
|
|
2509
4542
|
"fromTime",
|
|
2510
4543
|
"labelIds",
|
|
2511
|
-
"sceneIds"
|
|
4544
|
+
"sceneIds",
|
|
4545
|
+
"reason"
|
|
2512
4546
|
],
|
|
2513
4547
|
"headerFields": [],
|
|
2514
4548
|
"cookieFields": [],
|
|
@@ -2532,7 +4566,8 @@ var OP_ZaloFormsListFormLeads = {
|
|
|
2532
4566
|
"keyword",
|
|
2533
4567
|
"fromTime",
|
|
2534
4568
|
"labelIds",
|
|
2535
|
-
"isCommerce"
|
|
4569
|
+
"isCommerce",
|
|
4570
|
+
"reason"
|
|
2536
4571
|
],
|
|
2537
4572
|
"headerFields": [],
|
|
2538
4573
|
"cookieFields": [],
|
|
@@ -2572,6 +4607,20 @@ var OP_ZaloFormsListSimpleFormsByOfficialAccount = {
|
|
|
2572
4607
|
"cookieFields": [],
|
|
2573
4608
|
"bodyFields": []
|
|
2574
4609
|
};
|
|
4610
|
+
var OP_ZaloFormsListScenariosByOfficialAccount = {
|
|
4611
|
+
"operationId": "ZaloForms_listScenariosByOfficialAccount",
|
|
4612
|
+
"method": "GET",
|
|
4613
|
+
"endpoint": "/client/manage/api/manageConversation/getScenariosByOaId",
|
|
4614
|
+
"baseUrl": "https://form.ads.zalo.me",
|
|
4615
|
+
"binaryFields": [],
|
|
4616
|
+
"pathFields": [],
|
|
4617
|
+
"queryFields": [
|
|
4618
|
+
"oaId"
|
|
4619
|
+
],
|
|
4620
|
+
"headerFields": [],
|
|
4621
|
+
"cookieFields": [],
|
|
4622
|
+
"bodyFields": []
|
|
4623
|
+
};
|
|
2575
4624
|
var OP_ZaloFormsUpdateFormLeadNotificationInterval = {
|
|
2576
4625
|
"operationId": "ZaloForms_updateFormLeadNotificationInterval",
|
|
2577
4626
|
"method": "POST",
|
|
@@ -2600,10 +4649,59 @@ var OP_ZaloFormsGetAuthSession = {
|
|
|
2600
4649
|
"cookieFields": [],
|
|
2601
4650
|
"bodyFields": []
|
|
2602
4651
|
};
|
|
4652
|
+
var OP_ZaloFormsTrackManageFormEvent = {
|
|
4653
|
+
operationId: "zalo_forms_track_manage_form_event",
|
|
4654
|
+
method: "GET",
|
|
4655
|
+
endpoint: "/client/manage/api/manageForm/tracking",
|
|
4656
|
+
baseUrl: "https://form.ads.zalo.me",
|
|
4657
|
+
binaryFields: [],
|
|
4658
|
+
pathFields: [],
|
|
4659
|
+
queryFields: ["eventId", "oaId", "formId"],
|
|
4660
|
+
headerFields: [],
|
|
4661
|
+
cookieFields: [],
|
|
4662
|
+
bodyFields: []
|
|
4663
|
+
};
|
|
2603
4664
|
var ZaloFormsService = class {
|
|
2604
4665
|
constructor(client) {
|
|
2605
4666
|
this.client = client;
|
|
2606
4667
|
}
|
|
4668
|
+
validator = ZaloFormsValidator;
|
|
4669
|
+
static validator = ZaloFormsValidator;
|
|
4670
|
+
/**
|
|
4671
|
+
* Tạo biểu mẫu mới gắn với Official Account (POST https://ads.zalo.me/api/form/create).
|
|
4672
|
+
* Hỗ trợ truyền thẳng Typed Payload (tự động validate qua ZaloFormsValidator và mã hóa urlencoded)
|
|
4673
|
+
* hoặc object dạng `{ data: JSON.stringify(...) }`.
|
|
4674
|
+
*/
|
|
4675
|
+
async createForm(request, options) {
|
|
4676
|
+
let payloadStr;
|
|
4677
|
+
if (typeof request.data === "string") {
|
|
4678
|
+
payloadStr = request.data;
|
|
4679
|
+
} else {
|
|
4680
|
+
const val = ZaloFormsValidator.createForm(request);
|
|
4681
|
+
if (!val.isValid || !val.data) {
|
|
4682
|
+
throw new Error(`[ZaloFormsValidator] D\u1EEF li\u1EC7u t\u1EA1o form kh\xF4ng h\u1EE3p l\u1EC7:
|
|
4683
|
+
- ${val.errors.join("\n - ")}`);
|
|
4684
|
+
}
|
|
4685
|
+
payloadStr = JSON.stringify(val.data);
|
|
4686
|
+
}
|
|
4687
|
+
return this.client.requestFormUrlEncoded(
|
|
4688
|
+
OP_ZaloAdsCreateForm2,
|
|
4689
|
+
this.client.toTransportInput(OP_ZaloAdsCreateForm2, { data: payloadStr }),
|
|
4690
|
+
options
|
|
4691
|
+
);
|
|
4692
|
+
}
|
|
4693
|
+
/**
|
|
4694
|
+
* Lấy danh sách biểu mẫu Zalo Ads theo Official Account (GET https://ads.zalo.me/api/form/getByOaId).
|
|
4695
|
+
*/
|
|
4696
|
+
listFormsByOfficialAccount(request, options) {
|
|
4697
|
+
const val = ZaloFormsValidator.listFormsByOfficialAccount(request);
|
|
4698
|
+
const cleanInput = val.isValid && val.data ? val.data : request;
|
|
4699
|
+
return this.client.requestWithoutBody(
|
|
4700
|
+
OP_ZaloAdsListFormsByOfficialAccount2,
|
|
4701
|
+
this.client.toTransportInput(OP_ZaloAdsListFormsByOfficialAccount2, cleanInput),
|
|
4702
|
+
options
|
|
4703
|
+
);
|
|
4704
|
+
}
|
|
2607
4705
|
getAuthSession(options) {
|
|
2608
4706
|
return this.client.requestWithoutBody(OP_ZaloFormsGetAuthSession, void 0, options);
|
|
2609
4707
|
}
|
|
@@ -2631,9 +4729,411 @@ var ZaloFormsService = class {
|
|
|
2631
4729
|
listSimpleFormsByOfficialAccount(request, options) {
|
|
2632
4730
|
return this.client.requestWithoutBody(OP_ZaloFormsListSimpleFormsByOfficialAccount, this.client.toTransportInput(OP_ZaloFormsListSimpleFormsByOfficialAccount, request), options);
|
|
2633
4731
|
}
|
|
4732
|
+
listScenariosByOfficialAccount(request, options) {
|
|
4733
|
+
return this.client.requestWithoutBody(OP_ZaloFormsListScenariosByOfficialAccount, this.client.toTransportInput(OP_ZaloFormsListScenariosByOfficialAccount, request), options);
|
|
4734
|
+
}
|
|
2634
4735
|
updateFormLeadNotificationInterval(request, options) {
|
|
2635
4736
|
return this.client.requestJson(OP_ZaloFormsUpdateFormLeadNotificationInterval, this.client.toTransportInput(OP_ZaloFormsUpdateFormLeadNotificationInterval, request), options);
|
|
2636
4737
|
}
|
|
4738
|
+
/**
|
|
4739
|
+
* Ghi nhận sự kiện tương tác trên Lead Center (GET /client/manage/api/manageForm/tracking).
|
|
4740
|
+
*/
|
|
4741
|
+
trackManageFormEvent(request, options) {
|
|
4742
|
+
return this.client.requestWithoutBody(
|
|
4743
|
+
OP_ZaloFormsTrackManageFormEvent,
|
|
4744
|
+
this.client.toTransportInput(OP_ZaloFormsTrackManageFormEvent, request),
|
|
4745
|
+
options
|
|
4746
|
+
);
|
|
4747
|
+
}
|
|
4748
|
+
};
|
|
4749
|
+
|
|
4750
|
+
// src/validators/instant-pages.validator.ts
|
|
4751
|
+
function isPositiveInteger2(val) {
|
|
4752
|
+
if (typeof val === "number") return Number.isInteger(val) && val > 0;
|
|
4753
|
+
if (typeof val === "string" && val.trim() !== "") {
|
|
4754
|
+
const num = Number(val);
|
|
4755
|
+
return Number.isInteger(num) && num > 0;
|
|
4756
|
+
}
|
|
4757
|
+
return false;
|
|
4758
|
+
}
|
|
4759
|
+
function toPositiveInteger2(val) {
|
|
4760
|
+
return typeof val === "number" ? Math.floor(val) : parseInt(String(val), 10);
|
|
4761
|
+
}
|
|
4762
|
+
function validateCloneInstantPageRequest(input) {
|
|
4763
|
+
const errors = [];
|
|
4764
|
+
if (!input || typeof input !== "object") {
|
|
4765
|
+
return { isValid: false, errors: ["D\u1EEF li\u1EC7u y\xEAu c\u1EA7u sao ch\xE9p Instant Page ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng (object)."] };
|
|
4766
|
+
}
|
|
4767
|
+
const obj = input;
|
|
4768
|
+
if (!isPositiveInteger2(obj.instantPageId)) {
|
|
4769
|
+
errors.push("Tr\u01B0\u1EDDng 'instantPageId' l\xE0 b\u1EAFt bu\u1ED9c v\xE0 ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn d\u01B0\u01A1ng (> 0).");
|
|
4770
|
+
}
|
|
4771
|
+
return {
|
|
4772
|
+
isValid: errors.length === 0,
|
|
4773
|
+
errors,
|
|
4774
|
+
data: errors.length === 0 ? { instantPageId: toPositiveInteger2(obj.instantPageId) } : void 0
|
|
4775
|
+
};
|
|
4776
|
+
}
|
|
4777
|
+
function validateGetInstantPageDetailRequest(input) {
|
|
4778
|
+
const errors = [];
|
|
4779
|
+
if (!input || typeof input !== "object") {
|
|
4780
|
+
return { isValid: false, errors: ["D\u1EEF li\u1EC7u y\xEAu c\u1EA7u l\u1EA5y chi ti\u1EBFt Instant Page ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng (object)."] };
|
|
4781
|
+
}
|
|
4782
|
+
const obj = input;
|
|
4783
|
+
if (!isPositiveInteger2(obj.instantPageId)) {
|
|
4784
|
+
errors.push("Tr\u01B0\u1EDDng 'instantPageId' l\xE0 b\u1EAFt bu\u1ED9c v\xE0 ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn d\u01B0\u01A1ng (> 0).");
|
|
4785
|
+
}
|
|
4786
|
+
return {
|
|
4787
|
+
isValid: errors.length === 0,
|
|
4788
|
+
errors,
|
|
4789
|
+
data: errors.length === 0 ? { instantPageId: toPositiveInteger2(obj.instantPageId) } : void 0
|
|
4790
|
+
};
|
|
4791
|
+
}
|
|
4792
|
+
function validateGetInstantPageSharedUserRequest(input) {
|
|
4793
|
+
const errors = [];
|
|
4794
|
+
if (!input || typeof input !== "object") {
|
|
4795
|
+
return { isValid: false, errors: ["D\u1EEF li\u1EC7u y\xEAu c\u1EA7u l\u1EA5y th\xF4ng tin ng\u01B0\u1EDDi d\xF9ng chia s\u1EBB ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng (object)."] };
|
|
4796
|
+
}
|
|
4797
|
+
const obj = input;
|
|
4798
|
+
if (!isPositiveInteger2(obj.instantPageId)) {
|
|
4799
|
+
errors.push("Tr\u01B0\u1EDDng 'instantPageId' l\xE0 b\u1EAFt bu\u1ED9c v\xE0 ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn d\u01B0\u01A1ng (> 0).");
|
|
4800
|
+
}
|
|
4801
|
+
if (!isPositiveInteger2(obj.userId)) {
|
|
4802
|
+
errors.push("Tr\u01B0\u1EDDng 'userId' l\xE0 b\u1EAFt bu\u1ED9c v\xE0 ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn d\u01B0\u01A1ng (> 0).");
|
|
4803
|
+
}
|
|
4804
|
+
return {
|
|
4805
|
+
isValid: errors.length === 0,
|
|
4806
|
+
errors,
|
|
4807
|
+
data: errors.length === 0 ? {
|
|
4808
|
+
instantPageId: toPositiveInteger2(obj.instantPageId),
|
|
4809
|
+
userId: toPositiveInteger2(obj.userId)
|
|
4810
|
+
} : void 0
|
|
4811
|
+
};
|
|
4812
|
+
}
|
|
4813
|
+
function validateListInstantPageEditHistoryRequest(input) {
|
|
4814
|
+
const errors = [];
|
|
4815
|
+
if (!input || typeof input !== "object") {
|
|
4816
|
+
return { isValid: false, errors: ["D\u1EEF li\u1EC7u y\xEAu c\u1EA7u l\u1EA5y l\u1ECBch s\u1EED ch\u1EC9nh s\u1EEDa ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng (object)."] };
|
|
4817
|
+
}
|
|
4818
|
+
const obj = input;
|
|
4819
|
+
if (!isPositiveInteger2(obj.instantPageId)) {
|
|
4820
|
+
errors.push("Tr\u01B0\u1EDDng 'instantPageId' l\xE0 b\u1EAFt bu\u1ED9c v\xE0 ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn d\u01B0\u01A1ng (> 0).");
|
|
4821
|
+
}
|
|
4822
|
+
let limit = void 0;
|
|
4823
|
+
if (obj.limit !== void 0 && obj.limit !== null) {
|
|
4824
|
+
if (!isPositiveInteger2(obj.limit)) {
|
|
4825
|
+
errors.push("Tr\u01B0\u1EDDng 'limit' n\u1EBFu c\xF3 ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn >= 1.");
|
|
4826
|
+
} else {
|
|
4827
|
+
limit = toPositiveInteger2(obj.limit);
|
|
4828
|
+
}
|
|
4829
|
+
}
|
|
4830
|
+
let offset = void 0;
|
|
4831
|
+
if (obj.offset !== void 0 && obj.offset !== null) {
|
|
4832
|
+
const num = Number(obj.offset);
|
|
4833
|
+
if (!Number.isInteger(num) || num < 0) {
|
|
4834
|
+
errors.push("Tr\u01B0\u1EDDng 'offset' n\u1EBFu c\xF3 ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn >= 0.");
|
|
4835
|
+
} else {
|
|
4836
|
+
offset = num;
|
|
4837
|
+
}
|
|
4838
|
+
}
|
|
4839
|
+
return {
|
|
4840
|
+
isValid: errors.length === 0,
|
|
4841
|
+
errors,
|
|
4842
|
+
data: errors.length === 0 ? {
|
|
4843
|
+
instantPageId: toPositiveInteger2(obj.instantPageId),
|
|
4844
|
+
...limit !== void 0 ? { limit } : {},
|
|
4845
|
+
...offset !== void 0 ? { offset } : {}
|
|
4846
|
+
} : void 0
|
|
4847
|
+
};
|
|
4848
|
+
}
|
|
4849
|
+
function validateListInstantPageFormRecordsRequest(input) {
|
|
4850
|
+
const errors = [];
|
|
4851
|
+
if (!input || typeof input !== "object") {
|
|
4852
|
+
return { isValid: false, errors: ["D\u1EEF li\u1EC7u y\xEAu c\u1EA7u t\u1EA3i b\u1EA3n ghi form ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng (object)."] };
|
|
4853
|
+
}
|
|
4854
|
+
const obj = input;
|
|
4855
|
+
if (!isPositiveInteger2(obj.instantPageId)) {
|
|
4856
|
+
errors.push("Tr\u01B0\u1EDDng 'instantPageId' l\xE0 b\u1EAFt bu\u1ED9c v\xE0 ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn d\u01B0\u01A1ng (> 0).");
|
|
4857
|
+
}
|
|
4858
|
+
return {
|
|
4859
|
+
isValid: errors.length === 0,
|
|
4860
|
+
errors,
|
|
4861
|
+
data: errors.length === 0 ? { instantPageId: toPositiveInteger2(obj.instantPageId) } : void 0
|
|
4862
|
+
};
|
|
4863
|
+
}
|
|
4864
|
+
function validateListInstantPageSharesRequest(input) {
|
|
4865
|
+
const errors = [];
|
|
4866
|
+
if (!input || typeof input !== "object") {
|
|
4867
|
+
return { isValid: false, errors: ["D\u1EEF li\u1EC7u y\xEAu c\u1EA7u l\u1EA5y danh s\xE1ch ng\u01B0\u1EDDi \u0111\u01B0\u1EE3c chia s\u1EBB ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng (object)."] };
|
|
4868
|
+
}
|
|
4869
|
+
const obj = input;
|
|
4870
|
+
if (!isPositiveInteger2(obj.instantPageId)) {
|
|
4871
|
+
errors.push("Tr\u01B0\u1EDDng 'instantPageId' l\xE0 b\u1EAFt bu\u1ED9c v\xE0 ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn d\u01B0\u01A1ng (> 0).");
|
|
4872
|
+
}
|
|
4873
|
+
return {
|
|
4874
|
+
isValid: errors.length === 0,
|
|
4875
|
+
errors,
|
|
4876
|
+
data: errors.length === 0 ? { instantPageId: toPositiveInteger2(obj.instantPageId) } : void 0
|
|
4877
|
+
};
|
|
4878
|
+
}
|
|
4879
|
+
function validateListInstantPageUsersRequest(input) {
|
|
4880
|
+
if (input !== void 0 && input !== null && typeof input !== "object") {
|
|
4881
|
+
return { isValid: false, errors: ["D\u1EEF li\u1EC7u y\xEAu c\u1EA7u l\u1EA5y danh s\xE1ch ng\u01B0\u1EDDi d\xF9ng ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng ho\u1EB7c \u0111\u1EC3 tr\u1ED1ng."] };
|
|
4882
|
+
}
|
|
4883
|
+
return { isValid: true, errors: [], data: {} };
|
|
4884
|
+
}
|
|
4885
|
+
function validateListMiniPageTemplatesRequest(input) {
|
|
4886
|
+
if (input !== void 0 && input !== null && typeof input !== "object") {
|
|
4887
|
+
return { isValid: false, errors: ["D\u1EEF li\u1EC7u y\xEAu c\u1EA7u l\u1EA5y m\u1EABu giao di\u1EC7n ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng ho\u1EB7c \u0111\u1EC3 tr\u1ED1ng."] };
|
|
4888
|
+
}
|
|
4889
|
+
return { isValid: true, errors: [], data: {} };
|
|
4890
|
+
}
|
|
4891
|
+
function validateSearchInstantPagesRequest(input) {
|
|
4892
|
+
const errors = [];
|
|
4893
|
+
if (input === void 0 || input === null) {
|
|
4894
|
+
return { isValid: true, errors: [], data: {} };
|
|
4895
|
+
}
|
|
4896
|
+
if (typeof input !== "object") {
|
|
4897
|
+
return { isValid: false, errors: ["D\u1EEF li\u1EC7u t\xECm ki\u1EBFm Instant Page ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng."] };
|
|
4898
|
+
}
|
|
4899
|
+
const obj = input;
|
|
4900
|
+
const data = {};
|
|
4901
|
+
if (obj.id !== void 0 && obj.id !== null && obj.id !== "") {
|
|
4902
|
+
if (!isPositiveInteger2(obj.id)) {
|
|
4903
|
+
errors.push("B\u1ED9 l\u1ECDc 'id' n\u1EBFu c\xF3 ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn d\u01B0\u01A1ng (> 0).");
|
|
4904
|
+
} else {
|
|
4905
|
+
data.id = toPositiveInteger2(obj.id);
|
|
4906
|
+
}
|
|
4907
|
+
}
|
|
4908
|
+
if (obj.name !== void 0 && obj.name !== null) {
|
|
4909
|
+
if (typeof obj.name !== "string") {
|
|
4910
|
+
errors.push("B\u1ED9 l\u1ECDc 'name' n\u1EBFu c\xF3 ph\u1EA3i l\xE0 chu\u1ED7i k\xFD t\u1EF1.");
|
|
4911
|
+
} else {
|
|
4912
|
+
data.name = obj.name;
|
|
4913
|
+
}
|
|
4914
|
+
}
|
|
4915
|
+
if (obj.group !== void 0 && obj.group !== null && obj.group !== "") {
|
|
4916
|
+
const grp = Number(obj.group);
|
|
4917
|
+
if (grp !== 1 && grp !== 2) {
|
|
4918
|
+
errors.push("B\u1ED9 l\u1ECDc 'group' ch\u1EC9 nh\u1EADn gi\xE1 tr\u1ECB 1 (Trang s\u1EA3n ph\u1EA9m) ho\u1EB7c 2 (K\u1ECBch b\u1EA3n tin nh\u1EAFn).");
|
|
4919
|
+
} else {
|
|
4920
|
+
data.group = grp;
|
|
4921
|
+
}
|
|
4922
|
+
}
|
|
4923
|
+
return {
|
|
4924
|
+
isValid: errors.length === 0,
|
|
4925
|
+
errors,
|
|
4926
|
+
data: errors.length === 0 ? data : void 0
|
|
4927
|
+
};
|
|
4928
|
+
}
|
|
4929
|
+
function validateUpdateInstantPageRequest(input) {
|
|
4930
|
+
const errors = [];
|
|
4931
|
+
if (!input || typeof input !== "object") {
|
|
4932
|
+
return { isValid: false, errors: ["D\u1EEF li\u1EC7u c\u1EADp nh\u1EADt Instant Page ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng (object)."] };
|
|
4933
|
+
}
|
|
4934
|
+
const obj = input;
|
|
4935
|
+
const instantPageId = obj.instantPageId ?? obj.id;
|
|
4936
|
+
if (!isPositiveInteger2(instantPageId)) {
|
|
4937
|
+
errors.push("Tr\u01B0\u1EDDng 'instantPageId' (ho\u1EB7c 'id') l\xE0 b\u1EAFt bu\u1ED9c v\xE0 ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn d\u01B0\u01A1ng (> 0).");
|
|
4938
|
+
}
|
|
4939
|
+
const numericId = toPositiveInteger2(instantPageId);
|
|
4940
|
+
const data = {
|
|
4941
|
+
instantPageId: numericId,
|
|
4942
|
+
id: numericId
|
|
4943
|
+
};
|
|
4944
|
+
if (obj.name !== void 0 && obj.name !== null) {
|
|
4945
|
+
if (typeof obj.name !== "string") {
|
|
4946
|
+
errors.push("Tr\u01B0\u1EDDng 'name' ph\u1EA3i l\xE0 chu\u1ED7i k\xFD t\u1EF1.");
|
|
4947
|
+
} else {
|
|
4948
|
+
data.name = obj.name;
|
|
4949
|
+
}
|
|
4950
|
+
}
|
|
4951
|
+
if (obj.oaId !== void 0 && obj.oaId !== null) {
|
|
4952
|
+
if (typeof obj.oaId !== "string") {
|
|
4953
|
+
errors.push(`Tr\u01B0\u1EDDng 'oaId' ph\u1EA3i l\xE0 chu\u1ED7i k\xFD t\u1EF1 (ho\u1EB7c chu\u1ED7i r\u1ED7ng "").`);
|
|
4954
|
+
} else {
|
|
4955
|
+
data.oaId = obj.oaId;
|
|
4956
|
+
}
|
|
4957
|
+
}
|
|
4958
|
+
if (obj.active !== void 0 && obj.active !== null) {
|
|
4959
|
+
if (typeof obj.active === "boolean") {
|
|
4960
|
+
errors.push("Tr\u01B0\u1EDDng 'active' b\u1EAFt bu\u1ED9c l\xE0 s\u1ED1 nguy\xEAn 0 (T\u1EAFt) ho\u1EB7c 1 (B\u1EADt), kh\xF4ng \u0111\u01B0\u1EE3c truy\u1EC1n ki\u1EC3u boolean (true/false) v\xEC Zalo Ads API s\u1EBD tr\u1EA3 v\u1EC1 l\u1ED7i HTTP 400.");
|
|
4961
|
+
} else if (obj.active !== 0 && obj.active !== 1) {
|
|
4962
|
+
errors.push("Tr\u01B0\u1EDDng 'active' ch\u1EC9 nh\u1EADn gi\xE1 tr\u1ECB s\u1ED1 nguy\xEAn 0 (T\u1EAFt) ho\u1EB7c 1 (B\u1EADt).");
|
|
4963
|
+
} else {
|
|
4964
|
+
data.active = obj.active;
|
|
4965
|
+
}
|
|
4966
|
+
}
|
|
4967
|
+
if (obj.status !== void 0 && obj.status !== null) {
|
|
4968
|
+
const st = Number(obj.status);
|
|
4969
|
+
if (![0, 1, 2, 3].includes(st)) {
|
|
4970
|
+
errors.push("Tr\u01B0\u1EDDng 'status' ph\u1EA3i l\xE0 m\u1ED9t trong c\xE1c m\xE3: 0 (B\u1EA3n sao m\u1EDBi), 1 (B\u1EA3n nh\xE1p), 2 (\u0110\xE3 xu\u1EA5t b\u1EA3n), 3 (L\u01B0u tr\u1EEF).");
|
|
4971
|
+
} else {
|
|
4972
|
+
data.status = st;
|
|
4973
|
+
}
|
|
4974
|
+
}
|
|
4975
|
+
if (obj.draft !== void 0 && obj.draft !== null) {
|
|
4976
|
+
if (typeof obj.draft !== "string") {
|
|
4977
|
+
errors.push("Tr\u01B0\u1EDDng 'draft' ph\u1EA3i l\xE0 chu\u1ED7i JSON (JSON-encoded string).");
|
|
4978
|
+
} else if (obj.draft.trim() !== "") {
|
|
4979
|
+
try {
|
|
4980
|
+
JSON.parse(obj.draft);
|
|
4981
|
+
data.draft = obj.draft;
|
|
4982
|
+
} catch (err) {
|
|
4983
|
+
errors.push(`Tr\u01B0\u1EDDng 'draft' kh\xF4ng ph\u1EA3i l\xE0 chu\u1ED7i JSON h\u1EE3p l\u1EC7: ${err.message}`);
|
|
4984
|
+
}
|
|
4985
|
+
} else {
|
|
4986
|
+
data.draft = "";
|
|
4987
|
+
}
|
|
4988
|
+
}
|
|
4989
|
+
if (obj.content !== void 0 && obj.content !== null) {
|
|
4990
|
+
if (typeof obj.content !== "string") {
|
|
4991
|
+
errors.push("Tr\u01B0\u1EDDng 'content' ph\u1EA3i l\xE0 chu\u1ED7i JSON (JSON-encoded string).");
|
|
4992
|
+
} else if (obj.content.trim() !== "") {
|
|
4993
|
+
try {
|
|
4994
|
+
JSON.parse(obj.content);
|
|
4995
|
+
data.content = obj.content;
|
|
4996
|
+
} catch (err) {
|
|
4997
|
+
errors.push(`Tr\u01B0\u1EDDng 'content' kh\xF4ng ph\u1EA3i l\xE0 chu\u1ED7i JSON h\u1EE3p l\u1EC7: ${err.message}`);
|
|
4998
|
+
}
|
|
4999
|
+
} else {
|
|
5000
|
+
data.content = "";
|
|
5001
|
+
}
|
|
5002
|
+
}
|
|
5003
|
+
const hasUpdateField = data.name !== void 0 || data.oaId !== void 0 || data.active !== void 0 || data.status !== void 0 || data.draft !== void 0 || data.content !== void 0;
|
|
5004
|
+
if (!hasUpdateField) {
|
|
5005
|
+
errors.push("Y\xEAu c\u1EA7u c\u1EADp nh\u1EADt Instant Page ph\u1EA3i c\xF3 \xEDt nh\u1EA5t m\u1ED9t tr\u01B0\u1EDDng thay \u0111\u1ED5i: 'name', 'oaId', 'active', 'status', 'draft', ho\u1EB7c 'content'.");
|
|
5006
|
+
}
|
|
5007
|
+
return {
|
|
5008
|
+
isValid: errors.length === 0,
|
|
5009
|
+
errors,
|
|
5010
|
+
data: errors.length === 0 ? data : void 0
|
|
5011
|
+
};
|
|
5012
|
+
}
|
|
5013
|
+
function validateListInstantPageLeadsRequest(input) {
|
|
5014
|
+
const errors = [];
|
|
5015
|
+
if (!input || typeof input !== "object") {
|
|
5016
|
+
return { isValid: false, errors: ["D\u1EEF li\u1EC7u y\xEAu c\u1EA7u l\u1EA5y th\u1ED1ng k\xEA leads ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng."] };
|
|
5017
|
+
}
|
|
5018
|
+
const obj = input;
|
|
5019
|
+
let idsString = "";
|
|
5020
|
+
if (typeof obj.ids === "string" && obj.ids.trim() !== "") {
|
|
5021
|
+
idsString = obj.ids.trim();
|
|
5022
|
+
} else if (Array.isArray(obj.ids) && obj.ids.length > 0) {
|
|
5023
|
+
idsString = obj.ids.join(",");
|
|
5024
|
+
} else {
|
|
5025
|
+
errors.push("Tr\u01B0\u1EDDng 'ids' l\xE0 b\u1EAFt bu\u1ED9c v\xE0 ph\u1EA3i l\xE0 chu\u1ED7i c\xE1c ID ph\xE2n t\xE1ch b\u1EB1ng d\u1EA5u ph\u1EA9y (v\xED d\u1EE5: '81433,76292') ho\u1EB7c m\u1EA3ng c\xE1c ID.");
|
|
5026
|
+
}
|
|
5027
|
+
if (idsString) {
|
|
5028
|
+
const idParts = idsString.split(",").map((s) => s.trim()).filter(Boolean);
|
|
5029
|
+
if (idParts.length === 0) {
|
|
5030
|
+
errors.push("Tr\u01B0\u1EDDng 'ids' kh\xF4ng ch\u1EE9a b\u1EA5t k\u1EF3 ID h\u1EE3p l\u1EC7 n\xE0o.");
|
|
5031
|
+
} else {
|
|
5032
|
+
for (const id of idParts) {
|
|
5033
|
+
if (!isPositiveInteger2(id)) {
|
|
5034
|
+
errors.push(`M\xE3 trang '${id}' trong danh s\xE1ch 'ids' kh\xF4ng ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn d\u01B0\u01A1ng h\u1EE3p l\u1EC7.`);
|
|
5035
|
+
}
|
|
5036
|
+
}
|
|
5037
|
+
}
|
|
5038
|
+
}
|
|
5039
|
+
return {
|
|
5040
|
+
isValid: errors.length === 0,
|
|
5041
|
+
errors,
|
|
5042
|
+
data: errors.length === 0 ? { ids: idsString } : void 0
|
|
5043
|
+
};
|
|
5044
|
+
}
|
|
5045
|
+
function validateListOfficialAccountsRequest(input) {
|
|
5046
|
+
if (input !== void 0 && input !== null && typeof input !== "object") {
|
|
5047
|
+
return { isValid: false, errors: ["D\u1EEF li\u1EC7u y\xEAu c\u1EA7u l\u1EA5y danh s\xE1ch Official Accounts ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng ho\u1EB7c \u0111\u1EC3 tr\u1ED1ng."] };
|
|
5048
|
+
}
|
|
5049
|
+
return { isValid: true, errors: [], data: {} };
|
|
5050
|
+
}
|
|
5051
|
+
function validateUpsertInstantPageFormRequest(input) {
|
|
5052
|
+
const errors = [];
|
|
5053
|
+
if (!input || typeof input !== "object") {
|
|
5054
|
+
return { isValid: false, errors: ["D\u1EEF li\u1EC7u c\u1EA5u h\xECnh bi\u1EC3u m\u1EABu Instant Page ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng."] };
|
|
5055
|
+
}
|
|
5056
|
+
const obj = input;
|
|
5057
|
+
if (!isPositiveInteger2(obj.instantPageId)) {
|
|
5058
|
+
errors.push("Tr\u01B0\u1EDDng 'instantPageId' l\xE0 b\u1EAFt bu\u1ED9c v\xE0 ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn d\u01B0\u01A1ng (> 0).");
|
|
5059
|
+
}
|
|
5060
|
+
if (!obj.oaId || typeof obj.oaId !== "string" || !/^\d+$/.test(obj.oaId.trim())) {
|
|
5061
|
+
errors.push("Tr\u01B0\u1EDDng 'oaId' l\xE0 b\u1EAFt bu\u1ED9c v\xE0 ph\u1EA3i l\xE0 chu\u1ED7i s\u1ED1 \u0111\u1ECBnh danh Zalo Official Account.");
|
|
5062
|
+
}
|
|
5063
|
+
if (!obj.formName || typeof obj.formName !== "string" || obj.formName.trim() === "") {
|
|
5064
|
+
errors.push("Tr\u01B0\u1EDDng 'formName' l\xE0 b\u1EAFt bu\u1ED9c v\xE0 kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng.");
|
|
5065
|
+
}
|
|
5066
|
+
if (!Array.isArray(obj.questions) || obj.questions.length === 0) {
|
|
5067
|
+
errors.push("Tr\u01B0\u1EDDng 'questions' l\xE0 b\u1EAFt bu\u1ED9c v\xE0 ph\u1EA3i ch\u1EE9a \xEDt nh\u1EA5t m\u1ED9t c\xE2u h\u1ECFi (minItems: 1).");
|
|
5068
|
+
} else {
|
|
5069
|
+
obj.questions.forEach((q, idx) => {
|
|
5070
|
+
if (!q || typeof q !== "object") {
|
|
5071
|
+
errors.push(`C\xE2u h\u1ECFi s\u1ED1 ${idx + 1} ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng.`);
|
|
5072
|
+
return;
|
|
5073
|
+
}
|
|
5074
|
+
const question = q;
|
|
5075
|
+
if (question.type !== 1 && question.type !== 2) {
|
|
5076
|
+
errors.push(`C\xE2u h\u1ECFi s\u1ED1 ${idx + 1}: Tr\u01B0\u1EDDng 'type' b\u1EAFt bu\u1ED9c l\xE0 1 (nh\u1EADp li\u1EC7u) ho\u1EB7c 2 (l\u1EF1a ch\u1ECDn ph\u01B0\u01A1ng \xE1n).`);
|
|
5077
|
+
}
|
|
5078
|
+
if (!question.title || typeof question.title !== "string" || question.title.trim() === "") {
|
|
5079
|
+
errors.push(`C\xE2u h\u1ECFi s\u1ED1 ${idx + 1}: Tr\u01B0\u1EDDng 'title' kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng.`);
|
|
5080
|
+
}
|
|
5081
|
+
if (!Array.isArray(question.answers) || question.answers.length === 0) {
|
|
5082
|
+
errors.push(`C\xE2u h\u1ECFi s\u1ED1 ${idx + 1}: Tr\u01B0\u1EDDng 'answers' ph\u1EA3i ch\u1EE9a \xEDt nh\u1EA5t m\u1ED9t ph\u01B0\u01A1ng \xE1n/\xF4 nh\u1EADp li\u1EC7u.`);
|
|
5083
|
+
} else {
|
|
5084
|
+
question.answers.forEach((ans, ansIdx) => {
|
|
5085
|
+
if (!ans || typeof ans !== "object") {
|
|
5086
|
+
errors.push(`C\xE2u h\u1ECFi s\u1ED1 ${idx + 1}, ph\u01B0\u01A1ng \xE1n ${ansIdx + 1}: Ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng.`);
|
|
5087
|
+
return;
|
|
5088
|
+
}
|
|
5089
|
+
const answer = ans;
|
|
5090
|
+
if (answer.type === void 0 || typeof answer.type !== "number") {
|
|
5091
|
+
errors.push(`C\xE2u h\u1ECFi s\u1ED1 ${idx + 1}, ph\u01B0\u01A1ng \xE1n ${ansIdx + 1}: Tr\u01B0\u1EDDng 'type' b\u1EAFt bu\u1ED9c l\xE0 s\u1ED1 nguy\xEAn.`);
|
|
5092
|
+
}
|
|
5093
|
+
});
|
|
5094
|
+
}
|
|
5095
|
+
});
|
|
5096
|
+
}
|
|
5097
|
+
const useCustomConsent = typeof obj.useCustomConsent === "boolean" ? obj.useCustomConsent : false;
|
|
5098
|
+
let consentConfig = obj.consentConfig;
|
|
5099
|
+
if (useCustomConsent) {
|
|
5100
|
+
if (!consentConfig || typeof consentConfig !== "object") {
|
|
5101
|
+
errors.push("Khi 'useCustomConsent' = true, tr\u01B0\u1EDDng 'consentConfig' l\xE0 b\u1EAFt bu\u1ED9c.");
|
|
5102
|
+
} else {
|
|
5103
|
+
if (!consentConfig.address || typeof consentConfig.address !== "string") errors.push("C\u1EA5u h\xECnh \u0111i\u1EC1u kho\u1EA3n: 'address' kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng.");
|
|
5104
|
+
if (!consentConfig.ownerName || typeof consentConfig.ownerName !== "string") errors.push("C\u1EA5u h\xECnh \u0111i\u1EC1u kho\u1EA3n: 'ownerName' kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng.");
|
|
5105
|
+
if (!consentConfig.ownerEmail || typeof consentConfig.ownerEmail !== "string") errors.push("C\u1EA5u h\xECnh \u0111i\u1EC1u kho\u1EA3n: 'ownerEmail' kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng.");
|
|
5106
|
+
if (!consentConfig.ownerPhone || typeof consentConfig.ownerPhone !== "string") errors.push("C\u1EA5u h\xECnh \u0111i\u1EC1u kho\u1EA3n: 'ownerPhone' kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng.");
|
|
5107
|
+
}
|
|
5108
|
+
}
|
|
5109
|
+
const data = {
|
|
5110
|
+
instantPageId: toPositiveInteger2(obj.instantPageId),
|
|
5111
|
+
oaId: String(obj.oaId).trim(),
|
|
5112
|
+
formName: String(obj.formName).trim(),
|
|
5113
|
+
questions: obj.questions ?? [],
|
|
5114
|
+
useCustomConsent,
|
|
5115
|
+
consentConfig
|
|
5116
|
+
};
|
|
5117
|
+
return {
|
|
5118
|
+
isValid: errors.length === 0,
|
|
5119
|
+
errors,
|
|
5120
|
+
data: errors.length === 0 ? data : void 0
|
|
5121
|
+
};
|
|
5122
|
+
}
|
|
5123
|
+
var ZaloInstantPagesValidator = {
|
|
5124
|
+
validateCloneInstantPage: validateCloneInstantPageRequest,
|
|
5125
|
+
validateGetInstantPageDetail: validateGetInstantPageDetailRequest,
|
|
5126
|
+
validateGetInstantPageSharedUser: validateGetInstantPageSharedUserRequest,
|
|
5127
|
+
validateListInstantPageEditHistory: validateListInstantPageEditHistoryRequest,
|
|
5128
|
+
validateListInstantPageFormRecords: validateListInstantPageFormRecordsRequest,
|
|
5129
|
+
validateListInstantPageShares: validateListInstantPageSharesRequest,
|
|
5130
|
+
validateListInstantPageUsers: validateListInstantPageUsersRequest,
|
|
5131
|
+
validateListMiniPageTemplates: validateListMiniPageTemplatesRequest,
|
|
5132
|
+
validateSearchInstantPages: validateSearchInstantPagesRequest,
|
|
5133
|
+
validateUpdateInstantPage: validateUpdateInstantPageRequest,
|
|
5134
|
+
validateListInstantPageLeads: validateListInstantPageLeadsRequest,
|
|
5135
|
+
validateListOfficialAccounts: validateListOfficialAccountsRequest,
|
|
5136
|
+
validateUpsertInstantPageForm: validateUpsertInstantPageFormRequest
|
|
2637
5137
|
};
|
|
2638
5138
|
|
|
2639
5139
|
// src/services/instant-pages.service.ts
|
|
@@ -2838,8 +5338,13 @@ var ZaloInstantPagesService = class {
|
|
|
2838
5338
|
constructor(client) {
|
|
2839
5339
|
this.client = client;
|
|
2840
5340
|
}
|
|
5341
|
+
/**
|
|
5342
|
+
* Bộ công cụ kiểm tra tính hợp lệ dữ liệu (Standalone Validators) cho 13 API Instant Pages.
|
|
5343
|
+
* Dùng ở backend (NestJS/Express/Fastify), middleware hoặc AI Agent để verify payload trước khi gọi SDK.
|
|
5344
|
+
*/
|
|
5345
|
+
static validator = ZaloInstantPagesValidator;
|
|
2841
5346
|
cloneInstantPage(request, options) {
|
|
2842
|
-
return this.client.
|
|
5347
|
+
return this.client.requestJson(OP_ZaloInstantPagesCloneInstantPage, this.client.toTransportInput(OP_ZaloInstantPagesCloneInstantPage, request), options);
|
|
2843
5348
|
}
|
|
2844
5349
|
getInstantPageDetail(request, options) {
|
|
2845
5350
|
return this.client.requestWithoutBody(OP_ZaloInstantPagesGetInstantPageDetail, this.client.toTransportInput(OP_ZaloInstantPagesGetInstantPageDetail, request), options);
|
|
@@ -3116,6 +5621,17 @@ var ZaloWidgetApiService = class {
|
|
|
3116
5621
|
var ZaloAdsSdk = class {
|
|
3117
5622
|
client;
|
|
3118
5623
|
ads;
|
|
5624
|
+
campaigns;
|
|
5625
|
+
account;
|
|
5626
|
+
audiences;
|
|
5627
|
+
targeting;
|
|
5628
|
+
reports;
|
|
5629
|
+
conversions;
|
|
5630
|
+
pixel;
|
|
5631
|
+
automatedRules;
|
|
5632
|
+
rules;
|
|
5633
|
+
flows;
|
|
5634
|
+
media;
|
|
3119
5635
|
forms;
|
|
3120
5636
|
instantPages;
|
|
3121
5637
|
profileAds;
|
|
@@ -3126,6 +5642,17 @@ var ZaloAdsSdk = class {
|
|
|
3126
5642
|
const resolvedOptions = typeof options === "string" ? { zpsid: options } : options;
|
|
3127
5643
|
this.client = new ZaloSdkHttpClient(resolvedOptions);
|
|
3128
5644
|
this.ads = new ZaloAdsService(this.client);
|
|
5645
|
+
this.campaigns = this.ads;
|
|
5646
|
+
this.account = this.ads.account;
|
|
5647
|
+
this.audiences = this.ads.audiences;
|
|
5648
|
+
this.targeting = this.ads.audiences;
|
|
5649
|
+
this.reports = this.ads.reports;
|
|
5650
|
+
this.conversions = this.ads.conversions;
|
|
5651
|
+
this.pixel = this.ads.conversions;
|
|
5652
|
+
this.automatedRules = this.ads.automatedRules;
|
|
5653
|
+
this.rules = this.ads.automatedRules;
|
|
5654
|
+
this.flows = this.ads.flows;
|
|
5655
|
+
this.media = this.ads.media;
|
|
3129
5656
|
this.forms = new ZaloFormsService(this.client);
|
|
3130
5657
|
this.instantPages = new ZaloInstantPagesService(this.client);
|
|
3131
5658
|
this.profileAds = new ZaloProfileAdsService(this.client);
|
|
@@ -3390,8 +5917,10 @@ var ZaloAdsCreateFlowRequest = class {
|
|
|
3390
5917
|
messages;
|
|
3391
5918
|
};
|
|
3392
5919
|
var ZaloAdsCreateFlowResponse = class {
|
|
3393
|
-
/** 0 khi tạo thành công. */
|
|
5920
|
+
/** 0 khi tạo thành công; 1 khi lỗi (ví dụ: đã tới hạn mức 20 kịch bản). */
|
|
3394
5921
|
code;
|
|
5922
|
+
/** Thông báo lỗi từ Zalo Ads khi code khác 0. */
|
|
5923
|
+
msg;
|
|
3395
5924
|
/** ID kịch bản mới, truyền vào data.ZaloFlowId khi cập nhật quảng cáo Tin nhắn. */
|
|
3396
5925
|
data;
|
|
3397
5926
|
};
|
|
@@ -3451,11 +5980,35 @@ var ZaloAdsUpdateMessageAdResponse = class {
|
|
|
3451
5980
|
code;
|
|
3452
5981
|
data;
|
|
3453
5982
|
};
|
|
5983
|
+
|
|
5984
|
+
// src/dtos/instant-pages.dto.ts
|
|
5985
|
+
var ZaloInstantPageBlockType = /* @__PURE__ */ ((ZaloInstantPageBlockType2) => {
|
|
5986
|
+
ZaloInstantPageBlockType2[ZaloInstantPageBlockType2["CAROUSEL_SLIDER"] = 1] = "CAROUSEL_SLIDER";
|
|
5987
|
+
ZaloInstantPageBlockType2[ZaloInstantPageBlockType2["COUNTDOWN"] = 2] = "COUNTDOWN";
|
|
5988
|
+
ZaloInstantPageBlockType2[ZaloInstantPageBlockType2["RICH_TEXT"] = 4] = "RICH_TEXT";
|
|
5989
|
+
ZaloInstantPageBlockType2[ZaloInstantPageBlockType2["HERO_IMAGE"] = 6] = "HERO_IMAGE";
|
|
5990
|
+
ZaloInstantPageBlockType2[ZaloInstantPageBlockType2["FORM_NAME"] = 7] = "FORM_NAME";
|
|
5991
|
+
ZaloInstantPageBlockType2[ZaloInstantPageBlockType2["ORDER_CTA_BUTTON"] = 8] = "ORDER_CTA_BUTTON";
|
|
5992
|
+
ZaloInstantPageBlockType2[ZaloInstantPageBlockType2["FORM_PHONE"] = 9] = "FORM_PHONE";
|
|
5993
|
+
ZaloInstantPageBlockType2[ZaloInstantPageBlockType2["FORM_ADDRESS"] = 10] = "FORM_ADDRESS";
|
|
5994
|
+
ZaloInstantPageBlockType2[ZaloInstantPageBlockType2["FOOTER"] = 14] = "FOOTER";
|
|
5995
|
+
ZaloInstantPageBlockType2[ZaloInstantPageBlockType2["FORM_QUANTITY"] = 16] = "FORM_QUANTITY";
|
|
5996
|
+
ZaloInstantPageBlockType2[ZaloInstantPageBlockType2["PRODUCT_VARIANT"] = 18] = "PRODUCT_VARIANT";
|
|
5997
|
+
ZaloInstantPageBlockType2[ZaloInstantPageBlockType2["PRODUCT_TITLE_PRICE"] = 19] = "PRODUCT_TITLE_PRICE";
|
|
5998
|
+
ZaloInstantPageBlockType2[ZaloInstantPageBlockType2["QUICK_QUESTIONS"] = 20] = "QUICK_QUESTIONS";
|
|
5999
|
+
ZaloInstantPageBlockType2[ZaloInstantPageBlockType2["MESSAGE_CTA_BUTTON"] = 21] = "MESSAGE_CTA_BUTTON";
|
|
6000
|
+
ZaloInstantPageBlockType2[ZaloInstantPageBlockType2["SECTION_HEADING"] = 22] = "SECTION_HEADING";
|
|
6001
|
+
ZaloInstantPageBlockType2[ZaloInstantPageBlockType2["CALL_HOTLINE_BUTTON"] = 23] = "CALL_HOTLINE_BUTTON";
|
|
6002
|
+
ZaloInstantPageBlockType2[ZaloInstantPageBlockType2["KEY_VALUE_TABLE"] = 25] = "KEY_VALUE_TABLE";
|
|
6003
|
+
ZaloInstantPageBlockType2[ZaloInstantPageBlockType2["CONSENT_NOTICE"] = 27] = "CONSENT_NOTICE";
|
|
6004
|
+
return ZaloInstantPageBlockType2;
|
|
6005
|
+
})(ZaloInstantPageBlockType || {});
|
|
3454
6006
|
export {
|
|
3455
6007
|
ALL_ZALO_ADS_DOMAINS,
|
|
3456
6008
|
MemoryZaloSessionStore,
|
|
3457
6009
|
RedisZaloSessionStore,
|
|
3458
6010
|
TieredZaloSessionStore,
|
|
6011
|
+
ZaloAccountService,
|
|
3459
6012
|
ZaloAdsIntegrationManager as ZaloAdsAccountPool,
|
|
3460
6013
|
ZaloAdsCreateFlowRequest,
|
|
3461
6014
|
ZaloAdsCreateFlowResponse,
|
|
@@ -3472,11 +6025,23 @@ export {
|
|
|
3472
6025
|
ZaloAdsUpdateMessageAdResponse,
|
|
3473
6026
|
ZaloAdsUpdateVideoAdRequest,
|
|
3474
6027
|
ZaloAdsUpdateVideoAdResponse,
|
|
6028
|
+
ZaloAudiencesService,
|
|
6029
|
+
ZaloAudiencesValidator,
|
|
3475
6030
|
ZaloAuthManager,
|
|
6031
|
+
ZaloAutomatedRulesService,
|
|
6032
|
+
ZaloCampaignsService,
|
|
3476
6033
|
ZaloChatWidgetService,
|
|
6034
|
+
ZaloConversionsService,
|
|
6035
|
+
ZaloFlowsService,
|
|
6036
|
+
ZaloFlowsValidator,
|
|
3477
6037
|
ZaloFormsService,
|
|
6038
|
+
ZaloFormsValidator,
|
|
6039
|
+
ZaloInstantPageBlockType,
|
|
3478
6040
|
ZaloInstantPagesService,
|
|
6041
|
+
ZaloInstantPagesValidator,
|
|
6042
|
+
ZaloMediaService,
|
|
3479
6043
|
ZaloProfileAdsService,
|
|
6044
|
+
ZaloReportsService,
|
|
3480
6045
|
ZaloSdkError,
|
|
3481
6046
|
ZaloSdkHttpClient,
|
|
3482
6047
|
ZaloWidgetApiService,
|
|
@@ -3486,6 +6051,32 @@ export {
|
|
|
3486
6051
|
ZaloAdsSdk as default,
|
|
3487
6052
|
defaultSharedMemorySessionStore,
|
|
3488
6053
|
deriveAccountKeyFromZpsid,
|
|
3489
|
-
parseZaloCookieInput
|
|
6054
|
+
parseZaloCookieInput,
|
|
6055
|
+
validateCloneInstantPageRequest,
|
|
6056
|
+
validateCreateFlowRequest,
|
|
6057
|
+
validateCreateFormEventAudienceRequest,
|
|
6058
|
+
validateCreateFormRequest,
|
|
6059
|
+
validateCreateLookalikeAudienceRequest,
|
|
6060
|
+
validateCreateMessageOaEventAudienceRequest,
|
|
6061
|
+
validateCreateMessagePersonalEventAudienceRequest,
|
|
6062
|
+
validateCreatePhoneAudienceRequest,
|
|
6063
|
+
validateCreateSavedAudienceRequest,
|
|
6064
|
+
validateEstimateAudienceRequest,
|
|
6065
|
+
validateGetInstantPageDetailRequest,
|
|
6066
|
+
validateGetInstantPageSharedUserRequest,
|
|
6067
|
+
validateListFlowsByOfficialAccountRequest,
|
|
6068
|
+
validateListFormLeadsRequest,
|
|
6069
|
+
validateListFormsByOfficialAccountRequest,
|
|
6070
|
+
validateListInstantPageEditHistoryRequest,
|
|
6071
|
+
validateListInstantPageFormRecordsRequest,
|
|
6072
|
+
validateListInstantPageLeadsRequest,
|
|
6073
|
+
validateListInstantPageSharesRequest,
|
|
6074
|
+
validateListInstantPageUsersRequest,
|
|
6075
|
+
validateListMiniPageTemplatesRequest,
|
|
6076
|
+
validateListOfficialAccountsRequest,
|
|
6077
|
+
validateSearchInstantPagesRequest,
|
|
6078
|
+
validateUpdateFlowRequest,
|
|
6079
|
+
validateUpdateInstantPageRequest,
|
|
6080
|
+
validateUpsertInstantPageFormRequest
|
|
3490
6081
|
};
|
|
3491
6082
|
//# sourceMappingURL=index.mjs.map
|