@redonvn/zalo-ads-sdk 0.1.0 → 0.2.0

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.js CHANGED
@@ -44,6 +44,7 @@ __export(index_exports, {
44
44
  ZaloChatWidgetService: () => ZaloChatWidgetService,
45
45
  ZaloFormsService: () => ZaloFormsService,
46
46
  ZaloInstantPagesService: () => ZaloInstantPagesService,
47
+ ZaloProfileAdsService: () => ZaloProfileAdsService,
47
48
  ZaloSdkError: () => ZaloSdkError,
48
49
  ZaloSdkHttpClient: () => ZaloSdkHttpClient,
49
50
  ZaloWidgetApiService: () => ZaloWidgetApiService,
@@ -316,7 +317,9 @@ function decodePlaySessionJwt(playSessionCookie) {
316
317
  const base64Url = parts[1];
317
318
  const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
318
319
  const padded = base64.padEnd(base64.length + (4 - base64.length % 4) % 4, "=");
319
- const jsonStr = typeof Buffer !== "undefined" ? Buffer.from(padded, "base64").toString("utf8") : globalThis.atob(padded);
320
+ const binaryStr = globalThis.atob(padded);
321
+ const bytes = Uint8Array.from(binaryStr, (ch) => ch.charCodeAt(0));
322
+ const jsonStr = new TextDecoder("utf-8").decode(bytes);
320
323
  return JSON.parse(jsonStr);
321
324
  } catch {
322
325
  return void 0;
@@ -714,14 +717,23 @@ var ZaloAuthManager = class {
714
717
  formProfile = sessionJson.data;
715
718
  }
716
719
  } else if (domain === "profile.ads.zalo.me") {
717
- await this.followOAuthRedirects("https://profile.ads.zalo.me/", cookies, false);
720
+ const profileRes = await this.followOAuthRedirects("https://profile.ads.zalo.me/", cookies, false);
721
+ if (profileRes) {
722
+ const html = await profileRes.text().catch(() => "");
723
+ const csrfMatch = html.match(/CSRF_TOKEN\s*=\s*['"]([^'"]+)['"]/);
724
+ if (csrfMatch?.[1]) {
725
+ cookies["CSRF_TOKEN"] = csrfMatch[1];
726
+ }
727
+ }
728
+ headers["Origin"] = "https://profile.ads.zalo.me";
729
+ headers["Referer"] = "https://profile.ads.zalo.me/";
718
730
  } else if (domain === "api.widget.zalo.me" || domain === "widget.chat.zalo.me") {
719
731
  headers["Origin"] = "https://ads.zalo.me";
720
732
  headers["Referer"] = "https://ads.zalo.me/";
721
733
  }
722
- const xsrfToken = cookies["XSRF-TOKEN"];
723
- if (xsrfToken) {
724
- headers["x-xsrf-token"] = xsrfToken;
734
+ const xsrfToken = cookies["XSRF-TOKEN"] ?? cookies["CSRF_TOKEN"];
735
+ if (cookies["XSRF-TOKEN"]) {
736
+ headers["x-xsrf-token"] = cookies["XSRF-TOKEN"];
725
737
  }
726
738
  const bearerToken = formProfile?.token;
727
739
  if (bearerToken) {
@@ -754,7 +766,8 @@ var ZaloAuthManager = class {
754
766
  }
755
767
  async followOAuthRedirects(startUrl, cookies, stripSelectAccount) {
756
768
  let currentUrl = startUrl;
757
- for (let step = 1; step <= 6; step++) {
769
+ let lastResponse;
770
+ for (let step = 1; step <= 7; step++) {
758
771
  const res = await this.fetchImpl(currentUrl, {
759
772
  method: "GET",
760
773
  headers: {
@@ -764,9 +777,52 @@ var ZaloAuthManager = class {
764
777
  },
765
778
  redirect: "manual"
766
779
  });
780
+ lastResponse = res;
767
781
  this.mergeSetCookies(res, cookies);
768
782
  let location = res.headers.get("location");
769
- if (!location || res.status < 300 || res.status >= 400) {
783
+ if (!location && res.status === 200 && currentUrl.includes("oauth.zaloapp.com/v4/permission")) {
784
+ const html = await res.text().catch(() => "");
785
+ const csrfMatch = html.match(/name="csrf_token"[^>]*value="([^"]+)"/);
786
+ if (csrfMatch && html.includes("zid_consent_form")) {
787
+ const stateMatch = html.match(/name="state"[^>]*value="([^"]+)"/);
788
+ const parsedOAuthUrl = new URL(currentUrl);
789
+ const consentForm = new URLSearchParams({
790
+ csrf_token: csrfMatch[1],
791
+ app_id: parsedOAuthUrl.searchParams.get("app_id") ?? "",
792
+ redirect_uri: parsedOAuthUrl.searchParams.get("redirect_uri") ?? "",
793
+ bndl_id: "",
794
+ pkg_name: "",
795
+ sign_key: "",
796
+ wp_guid: "",
797
+ mac: "",
798
+ ref: "",
799
+ token_login_post: "",
800
+ state: stateMatch ? stateMatch[1] : parsedOAuthUrl.searchParams.get("state") ?? "",
801
+ ext_info: "",
802
+ enable_qgpf: ""
803
+ });
804
+ const consentRes = await this.fetchImpl(currentUrl, {
805
+ method: "POST",
806
+ headers: {
807
+ Cookie: this.formatCookieHeader(cookies),
808
+ "User-Agent": this.userAgent,
809
+ "Content-Type": "application/x-www-form-urlencoded",
810
+ Origin: "https://oauth.zaloapp.com",
811
+ Referer: currentUrl
812
+ },
813
+ body: consentForm.toString(),
814
+ redirect: "manual"
815
+ });
816
+ lastResponse = consentRes;
817
+ this.mergeSetCookies(consentRes, cookies);
818
+ location = consentRes.headers.get("location");
819
+ if (!location || consentRes.status < 300 || consentRes.status >= 400) {
820
+ break;
821
+ }
822
+ } else {
823
+ break;
824
+ }
825
+ } else if (!location || res.status < 300 || res.status >= 400) {
770
826
  break;
771
827
  }
772
828
  if (stripSelectAccount && location.includes("oauth.zaloapp.com") && location.includes("select_account=true")) {
@@ -777,6 +833,7 @@ var ZaloAuthManager = class {
777
833
  }
778
834
  currentUrl = location.startsWith("http") ? location : new URL(location, currentUrl).toString();
779
835
  }
836
+ return lastResponse;
780
837
  }
781
838
  mergeSetCookies(res, target) {
782
839
  const headersWithSetCookie = res.headers;
@@ -827,6 +884,7 @@ var DEFAULT_BASE_URLS = {
827
884
  ads: "https://ads.zalo.me",
828
885
  forms: "https://form.ads.zalo.me",
829
886
  instantPages: "https://page.ads.zalo.me",
887
+ profileAds: "https://profile.ads.zalo.me",
830
888
  widget: "https://api.widget.zalo.me",
831
889
  chatWidget: "https://widget.chat.zalo.me"
832
890
  };
@@ -1036,6 +1094,18 @@ var OP_ZaloAdsCreateFlow = {
1036
1094
  cookieFields: [],
1037
1095
  bodyFields: ["oaId", "id", "name", "messages"]
1038
1096
  };
1097
+ var OP_ZaloAdsUpdateFlow = {
1098
+ operationId: "ZaloAds_updateFlow",
1099
+ method: "POST",
1100
+ endpoint: "/api/flow/update",
1101
+ baseUrl: "https://ads.zalo.me",
1102
+ binaryFields: [],
1103
+ pathFields: [],
1104
+ queryFields: [],
1105
+ headerFields: [],
1106
+ cookieFields: [],
1107
+ bodyFields: ["oaId", "id", "name", "messages"]
1108
+ };
1039
1109
  var OP_ZaloAdsUpdateVideoAd = {
1040
1110
  operationId: "ZaloAds_updateVideoAd",
1041
1111
  method: "POST",
@@ -1163,6 +1233,26 @@ var OP_ZaloAdsCreatePostCampaign = {
1163
1233
  "data"
1164
1234
  ]
1165
1235
  };
1236
+ var OP_ZaloAdsCreateConversion = {
1237
+ "operationId": "ZaloAds_createConversion",
1238
+ "method": "POST",
1239
+ "endpoint": "/api/conversion/add",
1240
+ "baseUrl": "https://ads.zalo.me",
1241
+ "binaryFields": [],
1242
+ "pathFields": [],
1243
+ "queryFields": [],
1244
+ "headerFields": [],
1245
+ "cookieFields": [],
1246
+ "bodyFields": [
1247
+ "name",
1248
+ "landingPage",
1249
+ "urlType",
1250
+ "labelId",
1251
+ "buttonIds",
1252
+ "elements",
1253
+ "keywords"
1254
+ ]
1255
+ };
1166
1256
  var OP_ZaloAdsDeleteConversion = {
1167
1257
  "operationId": "ZaloAds_deleteConversion",
1168
1258
  "method": "DELETE",
@@ -1198,7 +1288,9 @@ var OP_ZaloAdsGetAdById = {
1198
1288
  "baseUrl": "https://ads.zalo.me",
1199
1289
  "binaryFields": [],
1200
1290
  "pathFields": [],
1201
- "queryFields": [],
1291
+ "queryFields": [
1292
+ "adId"
1293
+ ],
1202
1294
  "headerFields": [],
1203
1295
  "cookieFields": [],
1204
1296
  "bodyFields": []
@@ -1434,8 +1526,14 @@ var OP_ZaloAdsGetReportapiV2Campaigns = {
1434
1526
  "endpoint": "/reportapi/v2/campaigns/{campaignId}",
1435
1527
  "baseUrl": "https://ads.zalo.me",
1436
1528
  "binaryFields": [],
1437
- "pathFields": [],
1438
- "queryFields": [],
1529
+ "pathFields": [
1530
+ "campaignId"
1531
+ ],
1532
+ "queryFields": [
1533
+ "startDate",
1534
+ "endDate",
1535
+ "refresh"
1536
+ ],
1439
1537
  "headerFields": [],
1440
1538
  "cookieFields": [],
1441
1539
  "bodyFields": []
@@ -1460,8 +1558,11 @@ var OP_ZaloAdsGetReportapiV3Campaigns = {
1460
1558
  "binaryFields": [],
1461
1559
  "pathFields": [],
1462
1560
  "queryFields": [
1561
+ "filter",
1463
1562
  "endDate",
1464
1563
  "refresh",
1564
+ "agencyId",
1565
+ "createdBy",
1465
1566
  "startDate"
1466
1567
  ],
1467
1568
  "headerFields": [],
@@ -1475,7 +1576,10 @@ var OP_ZaloAdsGetZaapiCampaignReportcampaign = {
1475
1576
  "baseUrl": "https://ads.zalo.me",
1476
1577
  "binaryFields": [],
1477
1578
  "pathFields": [],
1478
- "queryFields": [],
1579
+ "queryFields": [
1580
+ "campaignId",
1581
+ "campId"
1582
+ ],
1479
1583
  "headerFields": [],
1480
1584
  "cookieFields": [],
1481
1585
  "bodyFields": []
@@ -1487,7 +1591,10 @@ var OP_ZaloAdsGetZaapiCheckcamphasmanyads = {
1487
1591
  "baseUrl": "https://ads.zalo.me",
1488
1592
  "binaryFields": [],
1489
1593
  "pathFields": [],
1490
- "queryFields": [],
1594
+ "queryFields": [
1595
+ "campaignId",
1596
+ "campId"
1597
+ ],
1491
1598
  "headerFields": [],
1492
1599
  "cookieFields": [],
1493
1600
  "bodyFields": []
@@ -1499,7 +1606,10 @@ var OP_ZaloAdsGetZaapiGetadsfromcampaignid = {
1499
1606
  "baseUrl": "https://ads.zalo.me",
1500
1607
  "binaryFields": [],
1501
1608
  "pathFields": [],
1502
- "queryFields": [],
1609
+ "queryFields": [
1610
+ "campaignId",
1611
+ "campId"
1612
+ ],
1503
1613
  "headerFields": [],
1504
1614
  "cookieFields": [],
1505
1615
  "bodyFields": []
@@ -1523,7 +1633,10 @@ var OP_ZaloAdsGetZaapiGetownedarticles = {
1523
1633
  "baseUrl": "https://ads.zalo.me",
1524
1634
  "binaryFields": [],
1525
1635
  "pathFields": [],
1526
- "queryFields": [],
1636
+ "queryFields": [
1637
+ "pageId",
1638
+ "oaId"
1639
+ ],
1527
1640
  "headerFields": [],
1528
1641
  "cookieFields": [],
1529
1642
  "bodyFields": []
@@ -1668,10 +1781,14 @@ var OP_ZaloAdsPostZaapiDeletead = {
1668
1781
  "baseUrl": "https://ads.zalo.me",
1669
1782
  "binaryFields": [],
1670
1783
  "pathFields": [],
1671
- "queryFields": [],
1784
+ "queryFields": [
1785
+ "adId"
1786
+ ],
1672
1787
  "headerFields": [],
1673
1788
  "cookieFields": [],
1674
- "bodyFields": []
1789
+ "bodyFields": [
1790
+ "adId"
1791
+ ]
1675
1792
  };
1676
1793
  var OP_ZaloAdsRenameCampaign = {
1677
1794
  "operationId": "ZaloAds_renameCampaign",
@@ -1744,12 +1861,21 @@ var OP_ZaloAdsUpdateNewAds = {
1744
1861
  "method": "POST",
1745
1862
  "endpoint": "/zaapi/UploadCrop",
1746
1863
  "baseUrl": "https://ads.zalo.me",
1747
- "binaryFields": [],
1864
+ "binaryFields": [
1865
+ "File"
1866
+ ],
1748
1867
  "pathFields": [],
1749
1868
  "queryFields": [],
1750
1869
  "headerFields": [],
1751
1870
  "cookieFields": [],
1752
- "bodyFields": []
1871
+ "bodyFields": [
1872
+ "File",
1873
+ "x",
1874
+ "y",
1875
+ "width",
1876
+ "height",
1877
+ "scale"
1878
+ ]
1753
1879
  };
1754
1880
  var OP_ZaloAdsUpdateOfficialAccountAd = {
1755
1881
  "operationId": "ZaloAds_updateOfficialAccountAd",
@@ -1901,10 +2027,13 @@ var OP_ZaloAdsCreateAutomatedRule = {
1901
2027
  "headerFields": [],
1902
2028
  "cookieFields": [],
1903
2029
  "bodyFields": [
2030
+ "scope",
1904
2031
  "appliedTo",
1905
2032
  "ruleName",
1906
2033
  "action",
1907
2034
  "conditions",
2035
+ "frequency",
2036
+ "appliedIds",
1908
2037
  "schedule",
1909
2038
  "campaignIds",
1910
2039
  "adIds"
@@ -1935,7 +2064,7 @@ var OP_ZaloAdsUpdateAutomatedRule = {
1935
2064
  var OP_ZaloAdsChangeAutomatedRuleStatus = {
1936
2065
  "operationId": "ZaloAds_changeAutomatedRuleStatus",
1937
2066
  "method": "POST",
1938
- "endpoint": "/api/automatedrules/status",
2067
+ "endpoint": "/api/automatedrules/change-status",
1939
2068
  "baseUrl": "https://ads.zalo.me",
1940
2069
  "binaryFields": [],
1941
2070
  "pathFields": [],
@@ -1943,10 +2072,25 @@ var OP_ZaloAdsChangeAutomatedRuleStatus = {
1943
2072
  "headerFields": [],
1944
2073
  "cookieFields": [],
1945
2074
  "bodyFields": [
2075
+ "automatedRuleId",
1946
2076
  "automatedRuleIds",
1947
2077
  "status"
1948
2078
  ]
1949
2079
  };
2080
+ var OP_ZaloAdsGetAutomatedRuleHistory = {
2081
+ "operationId": "ZaloAds_getAutomatedRuleHistory",
2082
+ "method": "GET",
2083
+ "endpoint": "/api/automatedrules/history/{automatedRuleId}",
2084
+ "baseUrl": "https://ads.zalo.me",
2085
+ "binaryFields": [],
2086
+ "pathFields": [
2087
+ "automatedRuleId"
2088
+ ],
2089
+ "queryFields": [],
2090
+ "headerFields": [],
2091
+ "cookieFields": [],
2092
+ "bodyFields": []
2093
+ };
1950
2094
  var OP_ZaloAdsDeleteAutomatedRule = {
1951
2095
  "operationId": "ZaloAds_deleteAutomatedRule",
1952
2096
  "method": "POST",
@@ -2021,6 +2165,9 @@ var ZaloAdsService = class {
2021
2165
  createFlow(request, options) {
2022
2166
  return this.client.requestJson(OP_ZaloAdsCreateFlow, this.client.toTransportInput(OP_ZaloAdsCreateFlow, request), options);
2023
2167
  }
2168
+ updateFlow(request, options) {
2169
+ return this.client.requestJson(OP_ZaloAdsUpdateFlow, this.client.toTransportInput(OP_ZaloAdsUpdateFlow, request), options);
2170
+ }
2024
2171
  listFlowsByOfficialAccount(request, options) {
2025
2172
  return this.client.requestWithoutBody(OP_ZaloAdsListFlowsByOfficialAccount, this.client.toTransportInput(OP_ZaloAdsListFlowsByOfficialAccount, request), options);
2026
2173
  }
@@ -2052,6 +2199,10 @@ var ZaloAdsService = class {
2052
2199
  createEcommerceCampaign(request, options) {
2053
2200
  return this.client.requestFormUrlEncoded(OP_ZaloAdsCreateEcommerceCampaign, this.client.toTransportInput(OP_ZaloAdsCreateEcommerceCampaign, request), options);
2054
2201
  }
2202
+ /** Alias theo tên tool chuẩn `zalo_ads_create_commerce_campaign` trong Project Schema Zalo ADS (`campaignType = 22`). */
2203
+ createCommerceCampaign(request, options) {
2204
+ return this.createEcommerceCampaign(request, options);
2205
+ }
2055
2206
  createForm(request, options) {
2056
2207
  return this.client.requestFormUrlEncoded(OP_ZaloAdsCreateForm, this.client.toTransportInput(OP_ZaloAdsCreateForm, request), options);
2057
2208
  }
@@ -2064,9 +2215,17 @@ var ZaloAdsService = class {
2064
2215
  createOfficialAccountCampaign(request, options) {
2065
2216
  return this.client.requestFormUrlEncoded(OP_ZaloAdsCreateOfficialAccountCampaign, this.client.toTransportInput(OP_ZaloAdsCreateOfficialAccountCampaign, request), options);
2066
2217
  }
2218
+ /** Alias theo tên tool chuẩn `zalo_ads_create_oa_campaign` trong Project Schema Zalo ADS (`campaignType = 3`). */
2219
+ createOaCampaign(request, options) {
2220
+ return this.createOfficialAccountCampaign(request, options);
2221
+ }
2067
2222
  createPostCampaign(request, options) {
2068
2223
  return this.client.requestFormUrlEncoded(OP_ZaloAdsCreatePostCampaign, this.client.toTransportInput(OP_ZaloAdsCreatePostCampaign, request), options);
2069
2224
  }
2225
+ /** Alias theo tên tool chuẩn `zalo_ads_create_article_campaign` trong Project Schema Zalo ADS (`campaignType = 4`). */
2226
+ createArticleCampaign(request, options) {
2227
+ return this.createPostCampaign(request, options);
2228
+ }
2070
2229
  listAutomatedRules(request = {}, options) {
2071
2230
  const queryInput = { query_param: { ruleName: request.ruleName ?? "" } };
2072
2231
  return this.client.requestWithoutBody(OP_ZaloAdsListAutomatedRules, queryInput, options);
@@ -2080,16 +2239,22 @@ var ZaloAdsService = class {
2080
2239
  changeAutomatedRuleStatus(request, options) {
2081
2240
  return this.client.requestJson(OP_ZaloAdsChangeAutomatedRuleStatus, this.client.toTransportInput(OP_ZaloAdsChangeAutomatedRuleStatus, request), options);
2082
2241
  }
2242
+ getAutomatedRuleHistory(request, options) {
2243
+ return this.client.requestWithoutBody(OP_ZaloAdsGetAutomatedRuleHistory, this.client.toTransportInput(OP_ZaloAdsGetAutomatedRuleHistory, request), options);
2244
+ }
2083
2245
  deleteAutomatedRule(request, options) {
2084
2246
  return this.client.requestJson(OP_ZaloAdsDeleteAutomatedRule, this.client.toTransportInput(OP_ZaloAdsDeleteAutomatedRule, request), options);
2085
2247
  }
2248
+ createConversion(request, options) {
2249
+ return this.client.requestJson(OP_ZaloAdsCreateConversion, this.client.toTransportInput(OP_ZaloAdsCreateConversion, request), options);
2250
+ }
2086
2251
  deleteConversion(request, options) {
2087
2252
  return this.client.requestWithoutBody(OP_ZaloAdsDeleteConversion, this.client.toTransportInput(OP_ZaloAdsDeleteConversion, request), options);
2088
2253
  }
2089
2254
  deleteCustomAudience(request, options) {
2090
2255
  return this.client.requestWithoutBody(OP_ZaloAdsDeleteCustomAudience, this.client.toTransportInput(OP_ZaloAdsDeleteCustomAudience, request), options);
2091
2256
  }
2092
- getAdById(request, options) {
2257
+ getAdById(request = {}, options) {
2093
2258
  return this.client.requestWithoutBody(OP_ZaloAdsGetAdById, this.client.toTransportInput(OP_ZaloAdsGetAdById, request), options);
2094
2259
  }
2095
2260
  getAdChangeLog(request, options) {
@@ -2104,28 +2269,28 @@ var ZaloAdsService = class {
2104
2269
  getApiBaAccountAllgrantedmembers(request = {}, options) {
2105
2270
  return this.client.requestWithoutBody(OP_ZaloAdsGetApiBaAccountAllgrantedmembers, this.client.toTransportInput(OP_ZaloAdsGetApiBaAccountAllgrantedmembers, request), options);
2106
2271
  }
2107
- getApiConversionAll(request, options) {
2272
+ getApiConversionAll(request = {}, options) {
2108
2273
  return this.client.requestWithoutBody(OP_ZaloAdsGetApiConversionAll, this.client.toTransportInput(OP_ZaloAdsGetApiConversionAll, request), options);
2109
2274
  }
2110
2275
  getApiConversionStandardEvents(request = {}, options) {
2111
2276
  return this.client.requestWithoutBody(OP_ZaloAdsGetApiConversionStandardEvents, this.client.toTransportInput(OP_ZaloAdsGetApiConversionStandardEvents, request), options);
2112
2277
  }
2113
- getApiCustomAudienceAll(request, options) {
2278
+ getApiCustomAudienceAll(request = {}, options) {
2114
2279
  return this.client.requestWithoutBody(OP_ZaloAdsGetApiCustomAudienceAll, this.client.toTransportInput(OP_ZaloAdsGetApiCustomAudienceAll, request), options);
2115
2280
  }
2116
2281
  getApiFilegroups(request = {}, options) {
2117
2282
  return this.client.requestWithoutBody(OP_ZaloAdsGetApiFilegroups, this.client.toTransportInput(OP_ZaloAdsGetApiFilegroups, request), options);
2118
2283
  }
2119
- getApiLpNews(request, options) {
2284
+ getApiLpNews(request = {}, options) {
2120
2285
  return this.client.requestWithoutBody(OP_ZaloAdsGetApiLpNews, this.client.toTransportInput(OP_ZaloAdsGetApiLpNews, request), options);
2121
2286
  }
2122
2287
  getApiMediaItems(request, options) {
2123
2288
  return this.client.requestWithoutBody(OP_ZaloAdsGetApiMediaItems, this.client.toTransportInput(OP_ZaloAdsGetApiMediaItems, request), options);
2124
2289
  }
2125
- getApiMemberFiles(request, options) {
2290
+ getApiMemberFiles(request = {}, options) {
2126
2291
  return this.client.requestWithoutBody(OP_ZaloAdsGetApiMemberFiles, this.client.toTransportInput(OP_ZaloAdsGetApiMemberFiles, request), options);
2127
2292
  }
2128
- getApiNotifiesHeader(request, options) {
2293
+ getApiNotifiesHeader(request = {}, options) {
2129
2294
  return this.client.requestWithoutBody(OP_ZaloAdsGetApiNotifiesHeader, this.client.toTransportInput(OP_ZaloAdsGetApiNotifiesHeader, request), options);
2130
2295
  }
2131
2296
  getApiPaymentTransactionHistory(request, options) {
@@ -2134,7 +2299,7 @@ var ZaloAdsService = class {
2134
2299
  getApiPlaceGetalldistricts(request = {}, options) {
2135
2300
  return this.client.requestWithoutBody(OP_ZaloAdsGetApiPlaceGetalldistricts, this.client.toTransportInput(OP_ZaloAdsGetApiPlaceGetalldistricts, request), options);
2136
2301
  }
2137
- getApiSpellCheckV2(request, options) {
2302
+ getApiSpellCheckV2(request = {}, options) {
2138
2303
  return this.client.requestWithoutBody(OP_ZaloAdsGetApiSpellCheckV2, this.client.toTransportInput(OP_ZaloAdsGetApiSpellCheckV2, request), options);
2139
2304
  }
2140
2305
  getApiWhoami(request = {}, options) {
@@ -2143,22 +2308,27 @@ var ZaloAdsService = class {
2143
2308
  getReportapiV2Ads(request, options) {
2144
2309
  return this.client.requestWithoutBody(OP_ZaloAdsGetReportapiV2Ads, this.client.toTransportInput(OP_ZaloAdsGetReportapiV2Ads, request), options);
2145
2310
  }
2146
- getReportapiV2Campaigns(request, options) {
2311
+ getReportapiV2Campaigns(request = {}, options) {
2147
2312
  return this.client.requestWithoutBody(OP_ZaloAdsGetReportapiV2Campaigns, this.client.toTransportInput(OP_ZaloAdsGetReportapiV2Campaigns, request), options);
2148
2313
  }
2149
- getReportapiV2UniqueUser(request, options) {
2314
+ getReportapiV2UniqueUser(request = {}, options) {
2150
2315
  return this.client.requestWithoutBody(OP_ZaloAdsGetReportapiV2UniqueUser, this.client.toTransportInput(OP_ZaloAdsGetReportapiV2UniqueUser, request), options);
2151
2316
  }
2152
2317
  getReportapiV3Campaigns(request, options) {
2153
- return this.client.requestWithoutBody(OP_ZaloAdsGetReportapiV3Campaigns, this.client.toTransportInput(OP_ZaloAdsGetReportapiV3Campaigns, request), options);
2318
+ const normalized = {
2319
+ filter: "[]",
2320
+ agencyId: 0,
2321
+ ...request
2322
+ };
2323
+ return this.client.requestWithoutBody(OP_ZaloAdsGetReportapiV3Campaigns, this.client.toTransportInput(OP_ZaloAdsGetReportapiV3Campaigns, normalized), options);
2154
2324
  }
2155
- getZaapiCampaignReportcampaign(request, options) {
2325
+ getZaapiCampaignReportcampaign(request = {}, options) {
2156
2326
  return this.client.requestWithoutBody(OP_ZaloAdsGetZaapiCampaignReportcampaign, this.client.toTransportInput(OP_ZaloAdsGetZaapiCampaignReportcampaign, request), options);
2157
2327
  }
2158
- getZaapiCheckcamphasmanyads(request, options) {
2328
+ getZaapiCheckcamphasmanyads(request = {}, options) {
2159
2329
  return this.client.requestWithoutBody(OP_ZaloAdsGetZaapiCheckcamphasmanyads, this.client.toTransportInput(OP_ZaloAdsGetZaapiCheckcamphasmanyads, request), options);
2160
2330
  }
2161
- getZaapiGetadsfromcampaignid(request, options) {
2331
+ getZaapiGetadsfromcampaignid(request = {}, options) {
2162
2332
  return this.client.requestWithoutBody(OP_ZaloAdsGetZaapiGetadsfromcampaignid, this.client.toTransportInput(OP_ZaloAdsGetZaapiGetadsfromcampaignid, request), options);
2163
2333
  }
2164
2334
  getZaapiGetallpages(request = {}, options) {
@@ -2194,7 +2364,7 @@ var ZaloAdsService = class {
2194
2364
  postApiMemberUploadImage(request, options) {
2195
2365
  return this.client.requestMultipart(OP_ZaloAdsPostApiMemberUploadImage, this.client.toTransportInput(OP_ZaloAdsPostApiMemberUploadImage, request), options);
2196
2366
  }
2197
- postZaapiDeletead(request, options) {
2367
+ postZaapiDeletead(request = {}, options) {
2198
2368
  return this.client.requestWithoutBody(OP_ZaloAdsPostZaapiDeletead, this.client.toTransportInput(OP_ZaloAdsPostZaapiDeletead, request), options);
2199
2369
  }
2200
2370
  renameCampaign(request, options) {
@@ -2203,6 +2373,10 @@ var ZaloAdsService = class {
2203
2373
  updateEcommerceAd(request, options) {
2204
2374
  return this.client.requestFormUrlEncoded(OP_ZaloAdsUpdateEcommerceAd, this.client.toTransportInput(OP_ZaloAdsUpdateEcommerceAd, request), options);
2205
2375
  }
2376
+ /** Alias theo tên tool chuẩn `zalo_ads_update_commerce_ad` trong Project Schema Zalo ADS (`Type = 23`, gắn `MiniPageId`). */
2377
+ updateCommerceAd(request, options) {
2378
+ return this.updateEcommerceAd(request, options);
2379
+ }
2206
2380
  updateFormAd(request, options) {
2207
2381
  return this.client.requestFormUrlEncoded(OP_ZaloAdsUpdateFormAd, this.client.toTransportInput(OP_ZaloAdsUpdateFormAd, request), options);
2208
2382
  }
@@ -2210,14 +2384,22 @@ var ZaloAdsService = class {
2210
2384
  return this.client.requestFormUrlEncoded(OP_ZaloAdsUpdateMessageAd, this.client.toTransportInput(OP_ZaloAdsUpdateMessageAd, request), options);
2211
2385
  }
2212
2386
  updateNewAds(request, options) {
2213
- return this.client.requestWithoutBody(OP_ZaloAdsUpdateNewAds, this.client.toTransportInput(OP_ZaloAdsUpdateNewAds, request), options);
2387
+ return this.client.requestMultipart(OP_ZaloAdsUpdateNewAds, this.client.toTransportInput(OP_ZaloAdsUpdateNewAds, request), options);
2214
2388
  }
2215
2389
  updateOfficialAccountAd(request, options) {
2216
2390
  return this.client.requestFormUrlEncoded(OP_ZaloAdsUpdateOfficialAccountAd, this.client.toTransportInput(OP_ZaloAdsUpdateOfficialAccountAd, request), options);
2217
2391
  }
2392
+ /** Alias theo tên tool chuẩn `zalo_ads_update_oa_ad` trong Project Schema Zalo ADS (`Type = 2`, `Action = 6`). */
2393
+ updateOaAd(request, options) {
2394
+ return this.updateOfficialAccountAd(request, options);
2395
+ }
2218
2396
  updatePostAd(request, options) {
2219
2397
  return this.client.requestFormUrlEncoded(OP_ZaloAdsUpdatePostAd, this.client.toTransportInput(OP_ZaloAdsUpdatePostAd, request), options);
2220
2398
  }
2399
+ /** Alias theo tên tool chuẩn `zalo_ads_update_article_ad` trong Project Schema Zalo ADS (`Type = 3`, gắn `ZaloFeedId`). */
2400
+ updateArticleAd(request, options) {
2401
+ return this.updatePostAd(request, options);
2402
+ }
2221
2403
  uploadCustomAudiencePhoneList(request, options) {
2222
2404
  return this.client.requestMultipart(OP_ZaloAdsUploadCustomAudiencePhoneList, this.client.toTransportInput(OP_ZaloAdsUploadCustomAudiencePhoneList, request), options);
2223
2405
  }
@@ -2251,6 +2433,10 @@ var ZaloChatWidgetService = class {
2251
2433
  getChatWidgetLoginConfig(request, options) {
2252
2434
  return this.client.requestWithoutBody(OP_ZaloChatWidgetGetChatWidgetLoginConfig, this.client.toTransportInput(OP_ZaloChatWidgetGetChatWidgetLoginConfig, request), options);
2253
2435
  }
2436
+ /** Alias theo tên tool chuẩn `zalo_chat_widget_get_login_config` trong Project Schema Zalo ADS. */
2437
+ getLoginConfig(request, options) {
2438
+ return this.getChatWidgetLoginConfig(request, options);
2439
+ }
2254
2440
  };
2255
2441
 
2256
2442
  // src/services/forms.service.ts
@@ -2633,6 +2819,26 @@ var OP_ZaloInstantPagesListOfficialAccounts = {
2633
2819
  "cookieFields": [],
2634
2820
  "bodyFields": []
2635
2821
  };
2822
+ var OP_ZaloInstantPagesUpsertInstantPageForm = {
2823
+ "operationId": "ZaloInstantPages_upsertInstantPageForm",
2824
+ "method": "PUT",
2825
+ "endpoint": "/api/instant-pages/{instantPageId}/form",
2826
+ "baseUrl": "https://page.ads.zalo.me",
2827
+ "binaryFields": [],
2828
+ "pathFields": [
2829
+ "instantPageId"
2830
+ ],
2831
+ "queryFields": [],
2832
+ "headerFields": [],
2833
+ "cookieFields": [],
2834
+ "bodyFields": [
2835
+ "oaId",
2836
+ "formName",
2837
+ "questions",
2838
+ "useCustomConsent",
2839
+ "consentConfig"
2840
+ ]
2841
+ };
2636
2842
  var ZaloInstantPagesService = class {
2637
2843
  constructor(client) {
2638
2844
  this.client = client;
@@ -2673,6 +2879,126 @@ var ZaloInstantPagesService = class {
2673
2879
  listOfficialAccounts(request = {}, options) {
2674
2880
  return this.client.requestWithoutBody(OP_ZaloInstantPagesListOfficialAccounts, this.client.toTransportInput(OP_ZaloInstantPagesListOfficialAccounts, request), options);
2675
2881
  }
2882
+ upsertInstantPageForm(request, options) {
2883
+ return this.client.requestJson(OP_ZaloInstantPagesUpsertInstantPageForm, this.client.toTransportInput(OP_ZaloInstantPagesUpsertInstantPageForm, request), options);
2884
+ }
2885
+ };
2886
+
2887
+ // src/services/profile-ads.service.ts
2888
+ var OP_ZaloProfileAdsCreateOaPage = {
2889
+ "operationId": "ZaloProfileAds_createOaPage",
2890
+ "method": "POST",
2891
+ "endpoint": "/oa",
2892
+ "baseUrl": "https://profile.ads.zalo.me",
2893
+ "binaryFields": [],
2894
+ "pathFields": [],
2895
+ "queryFields": [
2896
+ "option",
2897
+ "crsf-token"
2898
+ ],
2899
+ "headerFields": [],
2900
+ "cookieFields": [],
2901
+ "bodyFields": [
2902
+ "typeId",
2903
+ "tier",
2904
+ "typeName",
2905
+ "categoryId",
2906
+ "subCategoryId",
2907
+ "oaName",
2908
+ "description",
2909
+ "contactName",
2910
+ "contactPhone",
2911
+ "coverId",
2912
+ "avatarId",
2913
+ "province",
2914
+ "district",
2915
+ "address",
2916
+ "agreeTerm"
2917
+ ]
2918
+ };
2919
+ var OP_ZaloProfileAdsUploadOaAvatar = {
2920
+ "operationId": "ZaloProfileAds_uploadOaAvatar",
2921
+ "method": "POST",
2922
+ "endpoint": "/ajax/avatar/upload",
2923
+ "baseUrl": "https://profile.ads.zalo.me",
2924
+ "binaryFields": [
2925
+ "avatar-file"
2926
+ ],
2927
+ "pathFields": [],
2928
+ "queryFields": [
2929
+ "option"
2930
+ ],
2931
+ "headerFields": [],
2932
+ "cookieFields": [],
2933
+ "bodyFields": [
2934
+ "avatar-file",
2935
+ "is-new"
2936
+ ]
2937
+ };
2938
+ var OP_ZaloProfileAdsUploadOaCover = {
2939
+ "operationId": "ZaloProfileAds_uploadOaCover",
2940
+ "method": "POST",
2941
+ "endpoint": "/ajax/cover/upload",
2942
+ "baseUrl": "https://profile.ads.zalo.me",
2943
+ "binaryFields": [
2944
+ "cover-file"
2945
+ ],
2946
+ "pathFields": [],
2947
+ "queryFields": [
2948
+ "option"
2949
+ ],
2950
+ "headerFields": [],
2951
+ "cookieFields": [],
2952
+ "bodyFields": [
2953
+ "cover-file",
2954
+ "is-new"
2955
+ ]
2956
+ };
2957
+ var ZaloProfileAdsService = class {
2958
+ constructor(client) {
2959
+ this.client = client;
2960
+ }
2961
+ async createOaPage(request, options) {
2962
+ let csrfToken = request["crsf-token"];
2963
+ if (!csrfToken && this.client.authManager) {
2964
+ const session = await this.client.authManager.getSession("profile.ads.zalo.me");
2965
+ csrfToken = session.cookies["CSRF_TOKEN"] ?? session.xsrfToken;
2966
+ }
2967
+ const normalizedRequest = {
2968
+ option: "createpage",
2969
+ ...request,
2970
+ ...csrfToken ? { "crsf-token": csrfToken } : {}
2971
+ };
2972
+ return this.client.requestFormUrlEncoded(
2973
+ OP_ZaloProfileAdsCreateOaPage,
2974
+ this.client.toTransportInput(OP_ZaloProfileAdsCreateOaPage, normalizedRequest),
2975
+ options
2976
+ );
2977
+ }
2978
+ uploadOaAvatar(request, options) {
2979
+ const normalizedRequest = {
2980
+ option: "update",
2981
+ "is-new": "true",
2982
+ ...request
2983
+ };
2984
+ return this.client.requestMultipart(
2985
+ OP_ZaloProfileAdsUploadOaAvatar,
2986
+ this.client.toTransportInput(OP_ZaloProfileAdsUploadOaAvatar, normalizedRequest),
2987
+ options
2988
+ );
2989
+ }
2990
+ uploadOaCover(request, options) {
2991
+ const normalizedRequest = {
2992
+ option: "update",
2993
+ "is-new": "true",
2994
+ ...request
2995
+ };
2996
+ return this.client.requestMultipart(
2997
+ OP_ZaloProfileAdsUploadOaCover,
2998
+ this.client.toTransportInput(OP_ZaloProfileAdsUploadOaCover, normalizedRequest),
2999
+ options
3000
+ );
3001
+ }
2676
3002
  };
2677
3003
 
2678
3004
  // src/services/widget.service.ts
@@ -2752,6 +3078,8 @@ var ZaloAdsSdk = class {
2752
3078
  ads;
2753
3079
  forms;
2754
3080
  instantPages;
3081
+ profileAds;
3082
+ profile;
2755
3083
  widget;
2756
3084
  chatWidget;
2757
3085
  constructor(options = {}) {
@@ -2760,6 +3088,8 @@ var ZaloAdsSdk = class {
2760
3088
  this.ads = new ZaloAdsService(this.client);
2761
3089
  this.forms = new ZaloFormsService(this.client);
2762
3090
  this.instantPages = new ZaloInstantPagesService(this.client);
3091
+ this.profileAds = new ZaloProfileAdsService(this.client);
3092
+ this.profile = this.profileAds;
2763
3093
  this.widget = new ZaloWidgetApiService(this.client);
2764
3094
  this.chatWidget = new ZaloChatWidgetService(this.client);
2765
3095
  }
@@ -2986,21 +3316,25 @@ var ZaloAdsFlowChildMessageDto = class {
2986
3316
  text;
2987
3317
  };
2988
3318
  var ZaloAdsFlowButtonDto = class {
2989
- /** 3: mở nhánh tin nhắn; 12: gọi hotline. */
3319
+ /** 3 = Gửi tin nhắn vào nhánh hội thoại; 10 = Mở website; 12 = Thực hiện cuộc gọi. */
2990
3320
  type;
2991
3321
  /** Nhãn nút hiển thị cho người dùng. */
2992
3322
  text;
3323
+ /** URL website; bắt buộc với type 10. */
3324
+ url;
3325
+ /** Cờ của nút website; dùng true với type 10. */
3326
+ editable;
2993
3327
  /** Số hotline, bắt buộc khi type là 12. */
2994
3328
  phone;
2995
- /** Nhánh tin nhắn, bắt buộc khi type là 3. */
3329
+ /** Nhánh tin nhắn, bắt buộc khi type là 3. Với type 10 hoặc 12, để null hoặc bỏ qua. */
2996
3330
  messages;
2997
3331
  };
2998
3332
  var ZaloAdsFlowMessageDto = class {
2999
- /** Mẫu đã xác minh dùng 1 cho tin nhắn văn bản chính. */
3333
+ /** 1 = Tin nhắn văn bản; 2 = Tin nhắn kèm hình ảnh. */
3000
3334
  type;
3001
- /** Nội dung tin nhắn; có thể dùng biến {{user_name}}. */
3335
+ /** Nội dung tin nhắn, tối đa 1961 ký tự. Hỗ trợ biến: {{user_name}}, {{page_name}}, {{user_gender}}, {{user_id}}, {{page_id}}, {{date}}, {{datetime}}. */
3002
3336
  text;
3003
- /** URL media hoặc null với tin nhắn văn bản thuần. */
3337
+ /** URL media hoặc null với tin nhắn văn bản thuần. Bắt buộc và không được null khi type = 2. */
3004
3338
  url;
3005
3339
  /** Các nút đi kèm tin nhắn. */
3006
3340
  buttons;
@@ -3103,6 +3437,7 @@ var ZaloAdsUpdateMessageAdResponse = class {
3103
3437
  ZaloChatWidgetService,
3104
3438
  ZaloFormsService,
3105
3439
  ZaloInstantPagesService,
3440
+ ZaloProfileAdsService,
3106
3441
  ZaloSdkError,
3107
3442
  ZaloSdkHttpClient,
3108
3443
  ZaloWidgetApiService,