@redonvn/zalo-ads-sdk 0.2.25 → 0.2.29

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.mjs CHANGED
@@ -1774,11 +1774,15 @@ var ZaloAdsActionType = {
1774
1774
  MUA_NGAY: 2,
1775
1775
  THU_NGAY: 3,
1776
1776
  TAI_NGAY: 4,
1777
+ /** Nút "Xem thêm" trên Quảng cáo Form (Type 18) gửi mã 4 */
1778
+ XEM_THEM_FORM: 4,
1777
1779
  XEM_THEM: 5,
1778
1780
  NGHE_NGAY: 6,
1779
1781
  CHOI_NGAY: 7,
1780
1782
  DANG_KY: 8,
1781
1783
  GOI_DIEN: 9,
1784
+ /** Nút bấm "Gửi tin nhắn" / "Nhắn tin" dành cho Quảng cáo Tin nhắn (Type 19/30) */
1785
+ NHAN_TIN: 10,
1782
1786
  /** Dành riêng cho Quảng cáo Official Account (Type 2) */
1783
1787
  QUAN_TAM_OA: 6
1784
1788
  };
@@ -1789,6 +1793,12 @@ var ZaloAdsVideoSrc = {
1789
1793
  /** Tự tải video lên hoặc chọn từ Thư viện Media */
1790
1794
  SELF_UPLOAD: 2
1791
1795
  };
1796
+ var ZaloAdsVideoPlatform = {
1797
+ /** Nền tảng Video (toàn màn hình như ZVideo, Báo Mới; sàn CPM 7,300đ) */
1798
+ VIDEO_NETWORK: 1,
1799
+ /** Nhật ký Zalo (Feed xen giữa tin bạn bè; sàn CPM 6,000đ) */
1800
+ ZALO_FEED: 2
1801
+ };
1792
1802
  var ZaloAdsBudgetScheduleType = {
1793
1803
  /** Toàn lịch chạy */
1794
1804
  TOTAL_SCHEDULE: 1,
@@ -2042,7 +2052,10 @@ var VALID_CAMPAIGN_TYPES = {
2042
2052
  var VALID_AD_TYPES = {
2043
2053
  WEBSITE: 5,
2044
2054
  FORM: 18,
2045
- MESSAGE: 30,
2055
+ MESSAGE: 19,
2056
+ // Mã chuẩn của máy chủ Zalo Ads khi UpdateAd
2057
+ MESSAGE_LEGACY: 30,
2058
+ // Hỗ trợ tương thích ngược
2046
2059
  OA: 2,
2047
2060
  VIDEO: 11,
2048
2061
  COMMERCE: 28,
@@ -2101,22 +2114,37 @@ var ALLOWED_CTAS_PER_AD_TYPE = {
2101
2114
  ZaloAdsActionType.CHOI_NGAY,
2102
2115
  ZaloAdsActionType.DANG_KY
2103
2116
  ],
2104
- // Form (Type 18): 5 CTAs
2117
+ // Form (Type 18): 5 CTAs (Đặt ngay: 1, Mua ngay: 2, Thử ngay: 3, Xem thêm: 4/5, Đăng ký: 8)
2105
2118
  [VALID_AD_TYPES.FORM]: [
2106
2119
  ZaloAdsActionType.DAT_NGAY,
2107
2120
  ZaloAdsActionType.MUA_NGAY,
2108
2121
  ZaloAdsActionType.THU_NGAY,
2122
+ 4,
2109
2123
  ZaloAdsActionType.XEM_THEM,
2110
2124
  ZaloAdsActionType.DANG_KY
2111
2125
  ],
2112
- // Commerce (Type 28): 3 CTAs
2126
+ // Commerce (Type 28): 3 CTAs (Đặt ngay: 1, Mua ngay: 2, Xem thêm: 4/5)
2113
2127
  [VALID_AD_TYPES.COMMERCE]: [
2114
2128
  ZaloAdsActionType.DAT_NGAY,
2115
2129
  ZaloAdsActionType.MUA_NGAY,
2130
+ 4,
2116
2131
  ZaloAdsActionType.XEM_THEM
2117
2132
  ],
2118
2133
  // OA (Type 2): Cố định Quan tâm OA (6)
2119
2134
  [VALID_AD_TYPES.OA]: [ZaloAdsActionType.QUAN_TAM_OA],
2135
+ // Message (Type 19 & Type 30 legacy):
2136
+ [VALID_AD_TYPES.MESSAGE]: [
2137
+ ZaloAdsActionType.NHAN_TIN,
2138
+ ZaloAdsActionType.XEM_THEM,
2139
+ ZaloAdsActionType.DANG_KY,
2140
+ ZaloAdsActionType.GOI_DIEN
2141
+ ],
2142
+ [VALID_AD_TYPES.MESSAGE_LEGACY]: [
2143
+ ZaloAdsActionType.NHAN_TIN,
2144
+ ZaloAdsActionType.XEM_THEM,
2145
+ ZaloAdsActionType.DANG_KY,
2146
+ ZaloAdsActionType.GOI_DIEN
2147
+ ],
2120
2148
  // Display (Type 21) & Display Halfpage (Type 26): Hỗ trợ các hành động cơ bản
2121
2149
  [VALID_AD_TYPES.DISPLAY]: [
2122
2150
  ZaloAdsActionType.DAT_NGAY,
@@ -2186,8 +2214,9 @@ function validateCreateCampaignPayload(payload, options = {}) {
2186
2214
  }
2187
2215
  switch (payload.campaignType) {
2188
2216
  case VALID_CAMPAIGN_TYPES.WEBSITE:
2217
+ case VALID_CAMPAIGN_TYPES.VIDEO:
2189
2218
  if (!payload.targetUrl || typeof payload.targetUrl !== "string" || !payload.targetUrl.trim()) {
2190
- errors.push("targetUrl l\xE0 b\u1EAFt bu\u1ED9c \u0111\u1ED1i v\u1EDBi Qu\u1EA3ng c\xE1o Website.");
2219
+ errors.push("targetUrl l\xE0 b\u1EAFt bu\u1ED9c \u0111\u1ED1i v\u1EDBi Qu\u1EA3ng c\xE1o Website / Video.");
2191
2220
  } else if (!/^https?:\/\/.+/i.test(payload.targetUrl)) {
2192
2221
  errors.push("targetUrl ph\u1EA3i l\xE0 m\u1ED9t \u0111\u01B0\u1EDDng link h\u1EE3p l\u1EC7 b\u1EAFt \u0111\u1EA7u b\u1EB1ng http:// ho\u1EB7c https://.");
2193
2222
  }
@@ -2313,20 +2342,149 @@ function validateUpdateAdPayload(payload, options = {}) {
2313
2342
  } else if (payload.Type === VALID_AD_TYPES.VIDEO) {
2314
2343
  if (price.Type !== 1 && price.Type !== 7) {
2315
2344
  errors.push(
2316
- "\u0110\u1ED1i v\u1EDBi Qu\u1EA3ng c\xE1o Video (Type 11) tr\xEAn Video Platform, Price.Type b\u1EAFt bu\u1ED9c l\xE0 1 (CPM - L\u01B0\u1EE3t hi\u1EC3n th\u1ECB) ho\u1EB7c 7 (CPV - L\u01B0\u1EE3t xem). N\u1EBFu truy\u1EC1n 2 (CPC), form ch\u1EC9nh s\u1EEDa c\u1EE7a Zalo Ads s\u1EBD kh\xF4ng hi\u1EC3n th\u1ECB \u0111\u01B0\u1EE3c gi\xE1 v\xE0 s\u1ED1 l\u01B0\u1EE3ng."
2345
+ "\u0110\u1ED1i v\u1EDBi Qu\u1EA3ng c\xE1o Video (Type 11), Price.Type b\u1EAFt bu\u1ED9c l\xE0 1 (CPM - L\u01B0\u1EE3t hi\u1EC3n th\u1ECB) ho\u1EB7c 7 (CPV - L\u01B0\u1EE3t xem). N\u1EBFu truy\u1EC1n 2 (CPC), form ch\u1EC9nh s\u1EEDa c\u1EE7a Zalo Ads s\u1EBD kh\xF4ng hi\u1EC3n th\u1ECB \u0111\u01B0\u1EE3c gi\xE1 v\xE0 s\u1ED1 l\u01B0\u1EE3ng."
2317
2346
  );
2318
2347
  }
2319
- if (price.Type === 1 && (price.Limit ?? 0) < 50) {
2348
+ if (price.Type === 1) {
2349
+ if ((price.Limit ?? 0) < 50) {
2350
+ errors.push(
2351
+ "\u0110\u1ED1i v\u1EDBi Qu\u1EA3ng c\xE1o Video CPM, s\u1ED1 l\u01B0\u1EE3ng hi\u1EC3n th\u1ECB t\u1ED1i thi\u1EC3u (Price.Limit) l\xE0 50 (t\u01B0\u01A1ng \u1EE9ng 50,000 l\u01B0\u1EE3t hi\u1EC3n th\u1ECB)."
2352
+ );
2353
+ }
2354
+ const videoPlatform = payload.Settings?.VideoPlatform;
2355
+ if (videoPlatform === ZaloAdsVideoPlatform.VIDEO_NETWORK) {
2356
+ if (price.Bid !== void 0 && price.Bid < 7300) {
2357
+ errors.push(
2358
+ `Gi\xE1 \u0111\u1EB7t m\u1ED7i 1,000 l\u01B0\u1EE3t hi\u1EC3n th\u1ECB (Price.Bid) cho N\u1EC1n t\u1EA3ng Video (ZVideo, B\xE1o M\u1EDBi) t\u1ED1i thi\u1EC3u l\xE0 7,300 VN\u0110. Hi\u1EC7n t\u1EA1i \u0111ang truy\u1EC1n: ${price.Bid}\u0111.`
2359
+ );
2360
+ }
2361
+ } else if (videoPlatform === ZaloAdsVideoPlatform.ZALO_FEED) {
2362
+ if (price.Bid !== void 0 && price.Bid < 6e3) {
2363
+ errors.push(
2364
+ `Gi\xE1 \u0111\u1EB7t m\u1ED7i 1,000 l\u01B0\u1EE3t hi\u1EC3n th\u1ECB (Price.Bid) cho Video tr\xEAn Nh\u1EADt k\xFD Zalo t\u1ED1i thi\u1EC3u l\xE0 6,000 VN\u0110. Hi\u1EC7n t\u1EA1i \u0111ang truy\u1EC1n: ${price.Bid}\u0111.`
2365
+ );
2366
+ }
2367
+ } else {
2368
+ if (price.Bid !== void 0 && price.Bid < 6e3) {
2369
+ errors.push(
2370
+ `Gi\xE1 \u0111\u1EB7t m\u1ED7i 1,000 l\u01B0\u1EE3t hi\u1EC3n th\u1ECB (Price.Bid) cho Qu\u1EA3ng c\xE1o Video t\u1ED1i thi\u1EC3u l\xE0 6,000 VN\u0110. Hi\u1EC7n t\u1EA1i \u0111ang truy\u1EC1n: ${price.Bid}\u0111.`
2371
+ );
2372
+ }
2373
+ }
2374
+ }
2375
+ } else if (payload.Type === VALID_AD_TYPES.COMMERCE) {
2376
+ if (price.Type !== 2 && price.Type !== 5) {
2320
2377
  errors.push(
2321
- "\u0110\u1ED1i v\u1EDBi Qu\u1EA3ng c\xE1o Video CPM, s\u1ED1 l\u01B0\u1EE3ng hi\u1EC3n th\u1ECB t\u1ED1i thi\u1EC3u (Price.Limit) l\xE0 50 (t\u01B0\u01A1ng \u1EE9ng 50,000 l\u01B0\u1EE3t hi\u1EC3n th\u1ECB)."
2378
+ "\u0110\u1ED1i v\u1EDBi Qu\u1EA3ng c\xE1o Commerce (Type 28), Price.Type ch\u1EC9 h\u1ED7 tr\u1EE3 2 (CPC - L\u01B0\u1EE3t nh\u1EA5n) ho\u1EB7c 5 (CPA - L\u01B0\u1EE3t \u0111\u1EB7t h\xE0ng)."
2322
2379
  );
2323
2380
  }
2324
- } else if (payload.Type === VALID_AD_TYPES.COMMERCE || payload.Type === VALID_AD_TYPES.ARTICLE || payload.Type === VALID_AD_TYPES.FORM) {
2381
+ if (price.Type === 2) {
2382
+ if (price.SpendingMethod === 1) {
2383
+ if (price.Limit !== void 0 && price.Limit > 0 && price.Limit < 6e5) {
2384
+ errors.push(
2385
+ `T\u1ED5ng ng\xE2n s\xE1ch cho Qu\u1EA3ng c\xE1o Commerce CPC t\u1ED1i thi\u1EC3u l\xE0 600,000 VN\u0110 (Price.Limit >= 600000). Hi\u1EC7n t\u1EA1i \u0111ang truy\u1EC1n: ${price.Limit}\u0111.`
2386
+ );
2387
+ }
2388
+ } else if (price.SpendingMethod === 0) {
2389
+ if (price.Bid !== void 0 && price.Bid < 650) {
2390
+ errors.push(
2391
+ `Gi\xE1 \u0111\u1EB7t m\u1ED7i l\u01B0\u1EE3t nh\u1EA5n (Price.Bid) t\u1ED1i thi\u1EC3u l\xE0 650 VN\u0110. Hi\u1EC7n t\u1EA1i \u0111ang truy\u1EC1n: ${price.Bid}\u0111.`
2392
+ );
2393
+ }
2394
+ if (price.Limit !== void 0 && price.Limit < 50) {
2395
+ errors.push(
2396
+ `S\u1ED1 l\u01B0\u1EE3ng l\u01B0\u1EE3t nh\u1EA5n t\u1ED1i thi\u1EC3u (Price.Limit) m\u1ED7i ng\xE0y l\xE0 50 l\u01B0\u1EE3t. Hi\u1EC7n t\u1EA1i \u0111ang truy\u1EC1n: ${price.Limit}.`
2397
+ );
2398
+ }
2399
+ }
2400
+ } else if (price.Type === 5) {
2401
+ if (price.SpendingMethod === 1) {
2402
+ if (price.Bid !== void 0 && price.Bid !== 0) {
2403
+ errors.push(
2404
+ "Khi ch\u1ECDn 'T\u1ED5ng ng\xE2n s\xE1ch qu\u1EA3ng c\xE1o' (SpendingMethod = 1) cho L\u01B0\u1EE3t \u0111\u1EB7t h\xE0ng (CPA), tr\u01B0\u1EDDng Bid b\u1EAFt bu\u1ED9c ph\u1EA3i b\u1EB1ng 0 (h\u1EC7 th\u1ED1ng t\u1EF1 \u0111\u1ED9ng \u0111\u1EA5u th\u1EA7u)."
2405
+ );
2406
+ }
2407
+ if (price.Limit !== void 0 && price.Limit > 0 && price.Limit < 15e5) {
2408
+ errors.push(
2409
+ `T\u1ED5ng ng\xE2n s\xE1ch cho Qu\u1EA3ng c\xE1o Commerce CPA (L\u01B0\u1EE3t \u0111\u1EB7t h\xE0ng t\u1EF1 \u0111\u1ED9ng) t\u1ED1i thi\u1EC3u l\xE0 1,500,000 VN\u0110 (Price.Limit >= 1500000). Hi\u1EC7n t\u1EA1i \u0111ang truy\u1EC1n: ${price.Limit}\u0111.`
2410
+ );
2411
+ }
2412
+ } else if (price.SpendingMethod === 0) {
2413
+ if (price.Bid !== void 0 && price.Bid < 6e4) {
2414
+ errors.push(
2415
+ `Gi\xE1 \u0111\u1EB7t m\u1ED7i l\u01B0\u1EE3t \u0111\u1EB7t h\xE0ng (Price.Bid) t\u1ED1i thi\u1EC3u l\xE0 60,000 VN\u0110 / l\u01B0\u1EE3t \u0111\u1EB7t h\xE0ng. Hi\u1EC7n t\u1EA1i \u0111ang truy\u1EC1n: ${price.Bid}\u0111.`
2416
+ );
2417
+ }
2418
+ if (price.Limit !== void 0 && price.Limit < 10) {
2419
+ errors.push(
2420
+ `S\u1ED1 l\u01B0\u1EE3ng l\u01B0\u1EE3t \u0111\u1EB7t h\xE0ng t\u1ED1i thi\u1EC3u (Price.Limit) l\xE0 10 \u0111\u01A1n h\xE0ng (Limit >= 10). Hi\u1EC7n t\u1EA1i \u0111ang truy\u1EC1n: ${price.Limit}.`
2421
+ );
2422
+ }
2423
+ } else if (price.SpendingMethod !== void 0) {
2424
+ errors.push(
2425
+ "C\xE1ch \u0111\u1EB7t gi\xE1 SpendingMethod cho Qu\u1EA3ng c\xE1o Commerce CPA ch\u1EC9 ch\u1EA5p nh\u1EADn 1 (T\u1ED5ng ng\xE2n s\xE1ch qu\u1EA3ng c\xE1o) ho\u1EB7c 0 (T\u1EF1 \u0111\u1EB7t gi\xE1)."
2426
+ );
2427
+ }
2428
+ }
2429
+ } else if (payload.Type === VALID_AD_TYPES.ARTICLE) {
2325
2430
  if (price.Type !== 2) {
2326
2431
  errors.push(
2327
2432
  `\u0110\u1ED1i v\u1EDBi Ad Type ${payload.Type}, Price.Type b\u1EAFt bu\u1ED9c ph\u1EA3i b\u1EB1ng 2 (CPC).`
2328
2433
  );
2329
2434
  }
2435
+ } else if (payload.Type === VALID_AD_TYPES.FORM) {
2436
+ if (price.Type !== 1 && price.Type !== 2 && price.Type !== 5) {
2437
+ errors.push(
2438
+ "\u0110\u1ED1i v\u1EDBi Qu\u1EA3ng c\xE1o Form (Type 18), Price.Type ch\u1EC9 h\u1ED7 tr\u1EE3 1 (CPM - L\u01B0\u1EE3t hi\u1EC3n th\u1ECB), 2 (CPC - L\u01B0\u1EE3t nh\u1EA5n) ho\u1EB7c 5 (CPA - L\u01B0\u1EE3t li\xEAn h\u1EC7)."
2439
+ );
2440
+ }
2441
+ if (price.Type === 1) {
2442
+ if (price.Bid !== void 0 && price.Bid < 7300) {
2443
+ errors.push(
2444
+ `Gi\xE1 \u0111\u1EB7t m\u1ED7i 1,000 l\u01B0\u1EE3t hi\u1EC3n th\u1ECB (Price.Bid) cho Qu\u1EA3ng c\xE1o Form t\u1ED1i thi\u1EC3u l\xE0 7,300 VN\u0110. Hi\u1EC7n t\u1EA1i \u0111ang truy\u1EC1n: ${price.Bid}\u0111.`
2445
+ );
2446
+ }
2447
+ if (price.Limit !== void 0 && price.Limit < 50) {
2448
+ errors.push(
2449
+ `S\u1ED1 l\u01B0\u1EE3ng hi\u1EC3n th\u1ECB t\u1ED1i thi\u1EC3u (Price.Limit) cho Qu\u1EA3ng c\xE1o Form CPM l\xE0 50 (t\u01B0\u01A1ng \u1EE9ng 50,000 l\u01B0\u1EE3t hi\u1EC3n th\u1ECB). Hi\u1EC7n t\u1EA1i \u0111ang truy\u1EC1n: ${price.Limit}.`
2450
+ );
2451
+ }
2452
+ } else if (price.Type === 2) {
2453
+ if (price.SpendingMethod === 1) {
2454
+ if (price.Limit !== void 0 && price.Limit > 0 && price.Limit < 2e5) {
2455
+ errors.push(
2456
+ `Ng\xE2n s\xE1ch m\u1ED7i ng\xE0y cho Qu\u1EA3ng c\xE1o Form CPC t\u1ED1i thi\u1EC3u l\xE0 200,000 VN\u0110 (Price.Limit >= 200000). Hi\u1EC7n t\u1EA1i \u0111ang truy\u1EC1n: ${price.Limit}\u0111.`
2457
+ );
2458
+ }
2459
+ } else if (price.SpendingMethod === 0) {
2460
+ if (price.Bid !== void 0 && price.Bid < 650) {
2461
+ errors.push(
2462
+ `Gi\xE1 \u0111\u1EB7t m\u1ED7i l\u01B0\u1EE3t nh\u1EA5n (Price.Bid) t\u1ED1i thi\u1EC3u l\xE0 650 VN\u0110. Hi\u1EC7n t\u1EA1i \u0111ang truy\u1EC1n: ${price.Bid}\u0111.`
2463
+ );
2464
+ }
2465
+ if (price.Limit !== void 0 && price.Limit < 50) {
2466
+ errors.push(
2467
+ `S\u1ED1 l\u01B0\u1EE3ng l\u01B0\u1EE3t nh\u1EA5n t\u1ED1i thi\u1EC3u (Price.Limit) m\u1ED7i ng\xE0y l\xE0 50 l\u01B0\u1EE3t. Hi\u1EC7n t\u1EA1i \u0111ang truy\u1EC1n: ${price.Limit}.`
2468
+ );
2469
+ }
2470
+ }
2471
+ } else if (price.Type === 5) {
2472
+ if (price.SpendingMethod !== 1) {
2473
+ errors.push(
2474
+ "Khi t\xEDnh ti\u1EC1n theo L\u01B0\u1EE3t li\xEAn h\u1EC7 (Price.Type = 5 / CPA), SpendingMethod b\u1EAFt bu\u1ED9c ph\u1EA3i b\u1EB1ng 1 (T\u1ED1i \u01B0u t\u1EF1 \u0111\u1ED9ng theo ng\xE2n s\xE1ch)."
2475
+ );
2476
+ }
2477
+ if (price.Bid !== void 0 && price.Bid !== 0) {
2478
+ errors.push(
2479
+ "Khi t\xEDnh ti\u1EC1n theo L\u01B0\u1EE3t li\xEAn h\u1EC7 (Price.Type = 5 / CPA), tr\u01B0\u1EDDng Bid b\u1EAFt bu\u1ED9c ph\u1EA3i b\u1EB1ng 0 (Zalo Ads t\u1EF1 \u0111\u1ED9ng t\u1ED1i \u01B0u gi\xE1 th\u1EA7u, n\u1EBFu truy\u1EC1n > 0 m\xE1y ch\u1EE7 s\u1EBD b\xE1o l\u1ED7i code 13: Gi\xE1 \u0111\u1EB7t kh\xF4ng h\u1EE3p l\u1EC7)."
2480
+ );
2481
+ }
2482
+ if (price.Limit !== void 0 && price.Limit > 0 && price.Limit < 5e5) {
2483
+ errors.push(
2484
+ `Ng\xE2n s\xE1ch m\u1ED7i ng\xE0y cho Qu\u1EA3ng c\xE1o Form CPA (L\u01B0\u1EE3t li\xEAn h\u1EC7) t\u1ED1i thi\u1EC3u l\xE0 500,000 VN\u0110 (Price.Limit >= 500000). Hi\u1EC7n t\u1EA1i \u0111ang truy\u1EC1n: ${price.Limit}\u0111.`
2485
+ );
2486
+ }
2487
+ }
2330
2488
  } else if (payload.Type === VALID_AD_TYPES.OA) {
2331
2489
  if (price.Type !== 2 && price.Type !== 5) {
2332
2490
  errors.push(
@@ -2386,13 +2544,43 @@ function validateUpdateAdPayload(payload, options = {}) {
2386
2544
  );
2387
2545
  }
2388
2546
  }
2389
- } else if (payload.Type === VALID_AD_TYPES.MESSAGE) {
2390
- if (price.Type !== 2 && price.Type !== 5) {
2547
+ } else if (payload.Type === VALID_AD_TYPES.MESSAGE || payload.Type === VALID_AD_TYPES.MESSAGE_LEGACY || Number(payload.Type) === 19 || Number(payload.Type) === 30) {
2548
+ if (price.Type !== 1 && price.Type !== 2 && price.Type !== 5) {
2391
2549
  errors.push(
2392
- "\u0110\u1ED1i v\u1EDBi Qu\u1EA3ng c\xE1o Tin nh\u1EAFn (Type 30), Price.Type ch\u1EC9 h\u1ED7 tr\u1EE3 2 (L\u01B0\u1EE3t nh\u1EA5n - CPC) ho\u1EB7c 5 (L\u01B0\u1EE3t li\xEAn h\u1EC7 - CPA)."
2550
+ "\u0110\u1ED1i v\u1EDBi Qu\u1EA3ng c\xE1o Tin nh\u1EAFn (Type 19), Price.Type ch\u1EC9 h\u1ED7 tr\u1EE3 1 (CPM - L\u01B0\u1EE3t hi\u1EC3n th\u1ECB), 2 (CPC - L\u01B0\u1EE3t nh\u1EA5n) ho\u1EB7c 5 (CPA - L\u01B0\u1EE3t li\xEAn h\u1EC7)."
2393
2551
  );
2394
2552
  }
2395
- if (price.Type === 5) {
2553
+ if (price.Type === 1) {
2554
+ if (price.Bid !== void 0 && price.Bid < 7300) {
2555
+ errors.push(
2556
+ `Gi\xE1 \u0111\u1EB7t m\u1ED7i 1,000 l\u01B0\u1EE3t hi\u1EC3n th\u1ECB (Price.Bid) cho Qu\u1EA3ng c\xE1o Tin nh\u1EAFn t\u1ED1i thi\u1EC3u l\xE0 7,300 VN\u0110. Hi\u1EC7n t\u1EA1i \u0111ang truy\u1EC1n: ${price.Bid}\u0111.`
2557
+ );
2558
+ }
2559
+ if (price.Limit !== void 0 && price.Limit < 50) {
2560
+ errors.push(
2561
+ `S\u1ED1 l\u01B0\u1EE3ng hi\u1EC3n th\u1ECB t\u1ED1i thi\u1EC3u (Price.Limit) cho Qu\u1EA3ng c\xE1o Tin nh\u1EAFn CPM l\xE0 50 (t\u01B0\u01A1ng \u1EE9ng 50,000 l\u01B0\u1EE3t hi\u1EC3n th\u1ECB). Hi\u1EC7n t\u1EA1i \u0111ang truy\u1EC1n: ${price.Limit}.`
2562
+ );
2563
+ }
2564
+ } else if (price.Type === 2) {
2565
+ if (price.SpendingMethod === 1) {
2566
+ if (price.Limit !== void 0 && price.Limit > 0 && price.Limit < 2e5) {
2567
+ errors.push(
2568
+ `Ng\xE2n s\xE1ch m\u1ED7i ng\xE0y cho Qu\u1EA3ng c\xE1o Tin nh\u1EAFn CPC t\u1ED1i thi\u1EC3u l\xE0 200,000 VN\u0110 (Price.Limit >= 200000). Hi\u1EC7n t\u1EA1i \u0111ang truy\u1EC1n: ${price.Limit}\u0111.`
2569
+ );
2570
+ }
2571
+ } else if (price.SpendingMethod === 0) {
2572
+ if (price.Bid !== void 0 && price.Bid < 650) {
2573
+ errors.push(
2574
+ `Gi\xE1 \u0111\u1EB7t m\u1ED7i l\u01B0\u1EE3t nh\u1EA5n (Price.Bid) t\u1ED1i thi\u1EC3u l\xE0 650 VN\u0110. Hi\u1EC7n t\u1EA1i \u0111ang truy\u1EC1n: ${price.Bid}\u0111.`
2575
+ );
2576
+ }
2577
+ if (price.Limit !== void 0 && price.Limit < 50) {
2578
+ errors.push(
2579
+ `S\u1ED1 l\u01B0\u1EE3ng l\u01B0\u1EE3t nh\u1EA5n t\u1ED1i thi\u1EC3u (Price.Limit) m\u1ED7i ng\xE0y l\xE0 50 l\u01B0\u1EE3t. Hi\u1EC7n t\u1EA1i \u0111ang truy\u1EC1n: ${price.Limit}.`
2580
+ );
2581
+ }
2582
+ }
2583
+ } else if (price.Type === 5) {
2396
2584
  if (price.SpendingMethod !== 1) {
2397
2585
  errors.push(
2398
2586
  "Khi t\xEDnh ti\u1EC1n theo L\u01B0\u1EE3t li\xEAn h\u1EC7 (Price.Type = 5 / CPA), SpendingMethod b\u1EAFt bu\u1ED9c ph\u1EA3i b\u1EB1ng 1 (T\u1ED1i \u01B0u t\u1EF1 \u0111\u1ED9ng theo ng\xE2n s\xE1ch)."
@@ -2403,11 +2591,11 @@ function validateUpdateAdPayload(payload, options = {}) {
2403
2591
  "Khi t\xEDnh ti\u1EC1n theo L\u01B0\u1EE3t li\xEAn h\u1EC7 (Price.Type = 5 / CPA), tr\u01B0\u1EDDng Bid b\u1EAFt bu\u1ED9c ph\u1EA3i b\u1EB1ng 0 (Zalo Ads t\u1EF1 \u0111\u1ED9ng t\u1ED1i \u01B0u gi\xE1 th\u1EA7u, n\u1EBFu truy\u1EC1n > 0 m\xE1y ch\u1EE7 s\u1EBD b\xE1o l\u1ED7i code 13: Gi\xE1 \u0111\u1EB7t kh\xF4ng h\u1EE3p l\u1EC7)."
2404
2592
  );
2405
2593
  }
2406
- }
2407
- if (price.Limit !== void 0 && price.Limit > 0 && price.Limit < 6e5) {
2408
- errors.push(
2409
- "Ng\xE2n s\xE1ch t\u1ED1i thi\u1EC3u cho Qu\u1EA3ng c\xE1o Tin nh\u1EAFn l\xE0 600,000 VN\u0110 (Price.Limit >= 600000). N\u1EBFu \u0111\u1EB7t d\u01B0\u1EDBi 600k m\xE1y ch\u1EE7 s\u1EBD t\u1EEB ch\u1ED1i."
2410
- );
2594
+ if (price.Limit !== void 0 && price.Limit > 0 && price.Limit < 5e5) {
2595
+ errors.push(
2596
+ `Ng\xE2n s\xE1ch m\u1ED7i ng\xE0y cho Qu\u1EA3ng c\xE1o Tin nh\u1EAFn CPA (L\u01B0\u1EE3t li\xEAn h\u1EC7) t\u1ED1i thi\u1EC3u l\xE0 500,000 VN\u0110 (Price.Limit >= 500000). Hi\u1EC7n t\u1EA1i \u0111ang truy\u1EC1n: ${price.Limit}\u0111.`
2597
+ );
2598
+ }
2411
2599
  }
2412
2600
  } else if (Number(payload.Type) === 21 || Number(payload.Type) === 23 || Number(payload.Type) === 26 || payload.Type === VALID_AD_TYPES.DISPLAY || payload.Type === VALID_AD_TYPES.DISPLAY_HALFPAGE || payload.Type === VALID_AD_TYPES.DISPLAY_MEDIUM_RECTANGLE) {
2413
2601
  const adFormat = payload.Settings?.AdInfo?.AdFormat;
@@ -2522,6 +2710,14 @@ function validateUpdateAdPayload(payload, options = {}) {
2522
2710
  errors.push(`M\xE3 h\u1EC7 \u0111i\u1EC1u h\xE0nh kh\xF4ng h\u1EE3p l\u1EC7: ${invalidOs.join(", ")}. H\u1EE3p l\u1EC7: 0 (Android), 1 (iOS), 3 (PC).`);
2523
2711
  }
2524
2712
  }
2713
+ const videoPlatform = payload.Settings?.VideoPlatform;
2714
+ if (videoPlatform !== void 0 && videoPlatform !== null) {
2715
+ if (![1, 2].includes(Number(videoPlatform))) {
2716
+ warnings.push(
2717
+ `VideoPlatform (${videoPlatform}) kh\xF4ng h\u1EE3p l\u1EC7. Gi\xE1 tr\u1ECB chu\u1EA9n: 1 (N\u1EC1n t\u1EA3ng Video - ZVideo, B\xE1o M\u1EDBi) ho\u1EB7c 2 (Nh\u1EADt k\xFD Zalo - Feed).`
2718
+ );
2719
+ }
2720
+ }
2525
2721
  const deliveryType = payload.Settings?.DeliveryType;
2526
2722
  if (deliveryType !== void 0 && deliveryType !== ZaloAdsDeliveryType.STANDARD && deliveryType !== ZaloAdsDeliveryType.SPEED_UP) {
2527
2723
  warnings.push(
@@ -2589,21 +2785,15 @@ function validateUpdateAdPayload(payload, options = {}) {
2589
2785
  if (!payload.ZaloFormId || !payload.ZaloFormId.trim()) {
2590
2786
  errors.push("ZaloFormId l\xE0 b\u1EAFt bu\u1ED9c \u0111\u1ED1i v\u1EDBi Qu\u1EA3ng c\xE1o Form (Ad Type 18).");
2591
2787
  }
2592
- } else if (payload.Type === VALID_AD_TYPES.MESSAGE) {
2788
+ } else if (payload.Type === VALID_AD_TYPES.MESSAGE || payload.Type === VALID_AD_TYPES.MESSAGE_LEGACY || Number(payload.Type) === 19 || Number(payload.Type) === 30) {
2593
2789
  if (!payload.Settings?.Image?.LogoUrl) {
2594
- errors.push("Settings.Image.LogoUrl l\xE0 b\u1EAFt bu\u1ED9c \u0111\u1ED1i v\u1EDBi Qu\u1EA3ng c\xE1o Tin Nh\u1EAFn (Ad Type 30).");
2595
- }
2596
- if (!payload.MiniPageId || payload.MiniPageId <= 0) {
2597
- errors.push(
2598
- "MiniPageId l\xE0 b\u1EAFt bu\u1ED9c \u0111\u1ED1i v\u1EDBi Qu\u1EA3ng c\xE1o Tin Nh\u1EAFn (Ad Type 30, Template 4 - K\u1ECBch b\u1EA3n gi\u1EDBi thi\u1EC7u th\u01B0\u01A1ng hi\u1EC7u / Tin nh\u1EAFn). N\u1EBFu thi\u1EBFu ho\u1EB7c = 0, m\xE1y ch\u1EE7 Zalo Ads s\u1EBD t\u1EEB ch\u1ED1i v\u1EDBi l\u1ED7i: 'Mini Page kh\xF4ng h\u1EE3p l\u1EC7.'."
2599
- );
2600
- }
2601
- if (!payload.ZaloFlowId) {
2602
- warnings.push("Qu\u1EA3ng c\xE1o Tin Nh\u1EAFn n\xEAn g\u1EAFn ZaloFlowId \u0111\u1EC3 t\u1EF1 \u0111\u1ED9ng k\xEDch ho\u1EA1t k\u1ECBch b\u1EA3n chatbot t\u01B0\u01A1ng t\xE1c khi ng\u01B0\u1EDDi d\xF9ng m\u1EDF tin nh\u1EAFn.");
2790
+ errors.push("Settings.Image.LogoUrl l\xE0 b\u1EAFt bu\u1ED9c \u0111\u1ED1i v\u1EDBi Qu\u1EA3ng c\xE1o Tin Nh\u1EAFn (Ad Type 19/30).");
2603
2791
  }
2604
- if (payload.Settings?.Image?.ExtraImgs && payload.Settings?.Image?.ExtraImgs.length > 0) {
2792
+ const hasFlow = payload.ZaloFlowId && Number(payload.ZaloFlowId) > 0;
2793
+ const hasMiniPage = payload.MiniPageId && Number(payload.MiniPageId) > 0;
2794
+ if (!hasFlow && !hasMiniPage) {
2605
2795
  errors.push(
2606
- "Qu\u1EA3ng c\xE1o Tin Nh\u1EAFn \u0111\u1ECBnh d\u1EA1ng \u1EA3nh \u0111\u01A1n (Landscape Cover) kh\xF4ng \u0111\u01B0\u1EE3c truy\u1EC1n m\u1EA3ng 'ExtraImgs'. N\u1EBFu truy\u1EC1n th\u1EEBa s\u1EBD b\u1ECB m\xE1y ch\u1EE7 b\xE1o l\u1ED7i 'D\u1EEF li\u1EC7u kh\xF4ng h\u1EE3p l\u1EC7'."
2796
+ "Qu\u1EA3ng c\xE1o Tin Nh\u1EAFn y\xEAu c\u1EA7u ph\u1EA3i ch\u1ECDn K\u1ECBch b\u1EA3n tin nh\u1EAFn (ZaloFlowId > 0) ho\u1EB7c Trang gi\u1EDBi thi\u1EC7u th\u01B0\u01A1ng hi\u1EC7u (MiniPageId > 0)."
2607
2797
  );
2608
2798
  }
2609
2799
  } else if (payload.Type === VALID_AD_TYPES.COMMERCE) {
@@ -9064,6 +9254,7 @@ export {
9064
9254
  ZaloAdsUpdateVideoAdRequest,
9065
9255
  ZaloAdsUpdateVideoAdResponse,
9066
9256
  ZaloAdsUseConversion,
9257
+ ZaloAdsVideoPlatform,
9067
9258
  ZaloAdsVideoSrc,
9068
9259
  ZaloAdsXTemplates,
9069
9260
  ZaloAudiencesService,