@congminh1254/shopee-sdk 0.4.0 → 0.6.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.
Files changed (58) hide show
  1. package/README.md +7 -6
  2. package/lib/errors.js +2 -2
  3. package/lib/fetch.d.ts +2 -2
  4. package/lib/fetch.js +17 -14
  5. package/lib/fetch.js.map +1 -1
  6. package/lib/managers/ads.manager.d.ts +221 -1
  7. package/lib/managers/ads.manager.js +281 -6
  8. package/lib/managers/ads.manager.js.map +1 -1
  9. package/lib/managers/auth.manager.d.ts +3 -3
  10. package/lib/managers/auth.manager.js +21 -12
  11. package/lib/managers/auth.manager.js.map +1 -1
  12. package/lib/managers/base.manager.d.ts +1 -1
  13. package/lib/managers/index.d.ts +10 -10
  14. package/lib/managers/index.js +10 -10
  15. package/lib/managers/logistics.manager.js +2 -2
  16. package/lib/managers/logistics.manager.js.map +1 -1
  17. package/lib/managers/order.manager.d.ts +3 -3
  18. package/lib/managers/order.manager.js +25 -25
  19. package/lib/managers/order.manager.js.map +1 -1
  20. package/lib/managers/payment.manager.js +2 -2
  21. package/lib/managers/payment.manager.js.map +1 -1
  22. package/lib/managers/product.manager.d.ts +3 -3
  23. package/lib/managers/product.manager.js +10 -10
  24. package/lib/managers/product.manager.js.map +1 -1
  25. package/lib/managers/public.manager.d.ts +3 -3
  26. package/lib/managers/public.manager.js +8 -8
  27. package/lib/managers/push.manager.d.ts +3 -3
  28. package/lib/managers/push.manager.js +11 -11
  29. package/lib/managers/push.manager.js.map +1 -1
  30. package/lib/managers/voucher.manager.js +12 -12
  31. package/lib/managers/voucher.manager.js.map +1 -1
  32. package/lib/schemas/access-token.d.ts +2 -1
  33. package/lib/schemas/ads.d.ts +456 -0
  34. package/lib/schemas/attribute.d.ts +4 -4
  35. package/lib/schemas/fetch.d.ts +2 -2
  36. package/lib/schemas/index.d.ts +12 -11
  37. package/lib/schemas/index.js +12 -11
  38. package/lib/schemas/index.js.map +1 -1
  39. package/lib/schemas/logistics.d.ts +1 -1
  40. package/lib/schemas/order.d.ts +26 -26
  41. package/lib/schemas/order.js +1 -1
  42. package/lib/schemas/payment.d.ts +1 -1
  43. package/lib/schemas/product.d.ts +1 -1
  44. package/lib/schemas/product.js +0 -1
  45. package/lib/schemas/product.js.map +1 -1
  46. package/lib/schemas/push.d.ts +1 -1
  47. package/lib/schemas/region.js +5 -5
  48. package/lib/schemas/voucher.js.map +1 -1
  49. package/lib/sdk.d.ts +12 -12
  50. package/lib/sdk.js +15 -19
  51. package/lib/sdk.js.map +1 -1
  52. package/lib/storage/custom-token-storage.d.ts +2 -2
  53. package/lib/storage/custom-token-storage.js +11 -11
  54. package/lib/storage/custom-token-storage.js.map +1 -1
  55. package/lib/storage/token-storage.interface.d.ts +1 -1
  56. package/lib/utils/signature.js +3 -6
  57. package/lib/utils/signature.js.map +1 -1
  58. package/package.json +2 -1
package/README.md CHANGED
@@ -11,19 +11,19 @@ npm install shopee-sdk
11
11
  ## Usage
12
12
 
13
13
  ```typescript
14
- import { ShopeeClient } from 'shopee-sdk';
14
+ import { ShopeeClient } from "shopee-sdk";
15
15
 
16
16
  // Initialize the client
17
17
  const client = new ShopeeClient({
18
18
  partner_id: 123456,
19
- partner_key: 'your-partner-key',
20
- base_url: 'https://partner.test-stable.shopeemobile.com', // For sandbox
19
+ partner_key: "your-partner-key",
20
+ base_url: "https://partner.test-stable.shopeemobile.com", // For sandbox
21
21
  // base_url: 'https://partner.shopeemobile.com', // For production
22
22
  });
23
23
 
24
24
  // Authenticate (if working with shop-level APIs)
25
25
  await client.auth.getToken({
26
- code: 'authorization-code',
26
+ code: "authorization-code",
27
27
  shop_id: 123456,
28
28
  });
29
29
 
@@ -43,7 +43,7 @@ const voucher = await client.voucher.addVoucher({
43
43
  reward_type: 1, // fixed amount
44
44
  usage_quantity: 100,
45
45
  min_basket_price: 20,
46
- discount_amount: 10
46
+ discount_amount: 10,
47
47
  });
48
48
 
49
49
  // Example: Get lost push messages (partner-level API, no auth required)
@@ -73,6 +73,7 @@ Examples of commit messages:
73
73
  This project uses [Release Please](https://github.com/googleapis/release-please) to automate version management and releases.
74
74
 
75
75
  The release process follows these steps:
76
+
76
77
  1. Commits to the main branch are automatically analyzed
77
78
  2. When conventional commit messages are detected, Release Please creates or updates a release PR
78
79
  3. When the release PR is merged:
@@ -82,4 +83,4 @@ The release process follows these steps:
82
83
 
83
84
  ## License
84
85
 
85
- MIT
86
+ MIT
package/lib/errors.js CHANGED
@@ -1,13 +1,13 @@
1
1
  export class ShopeeSdkError extends Error {
2
2
  constructor(message) {
3
3
  super(message);
4
- this.name = 'ShopeeSdkError';
4
+ this.name = "ShopeeSdkError";
5
5
  }
6
6
  }
7
7
  export class ShopeeApiError extends Error {
8
8
  constructor(status, data) {
9
9
  super(`API Error: ${status} - ${JSON.stringify(data)}`);
10
- this.name = 'ShopeeApiError';
10
+ this.name = "ShopeeApiError";
11
11
  this.status = status;
12
12
  this.data = data;
13
13
  }
package/lib/fetch.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ShopeeConfig } from './sdk.js';
2
- import { FetchOptions } from './schemas/fetch.js';
1
+ import { ShopeeConfig } from "./sdk.js";
2
+ import { FetchOptions } from "./schemas/fetch.js";
3
3
  export declare class ShopeeFetch {
4
4
  static fetch<T>(config: ShopeeConfig, path: string, options?: FetchOptions): Promise<T>;
5
5
  }
package/lib/fetch.js CHANGED
@@ -1,9 +1,9 @@
1
- import fetch, { Headers } from 'node-fetch';
2
- import { ShopeeApiError, ShopeeSdkError } from './errors.js';
3
- import { generateSignature } from './utils/signature.js';
1
+ import fetch, { Headers } from "node-fetch";
2
+ import { ShopeeApiError, ShopeeSdkError } from "./errors.js";
3
+ import { generateSignature } from "./utils/signature.js";
4
4
  export class ShopeeFetch {
5
5
  static async fetch(config, path, options = {}) {
6
- const { method = 'GET', params = {}, body, ...restOptions } = options;
6
+ const { method = "GET", params = {}, body } = options;
7
7
  const url = new URL(`${config.base_url}${path}`);
8
8
  // Add required parameters
9
9
  const timestamp = Math.floor(Date.now() / 1000);
@@ -21,9 +21,12 @@ export class ShopeeFetch {
21
21
  };
22
22
  let authParams = {};
23
23
  if (options.auth) {
24
- const token = await config.sdk?.getAuthToken();
24
+ let token = await config.sdk?.getAuthToken();
25
+ if (token?.expired_at && token.expired_at < Date.now()) {
26
+ token = await config.sdk?.refreshToken();
27
+ }
25
28
  if (!token) {
26
- throw new ShopeeSdkError('No access token found');
29
+ throw new ShopeeSdkError("No access token found");
27
30
  }
28
31
  authParams = {
29
32
  access_token: token?.access_token,
@@ -39,7 +42,7 @@ export class ShopeeFetch {
39
42
  }
40
43
  Object.entries({ ...allParams, ...authParams, sign: signature }).forEach(([key, value]) => {
41
44
  if (Array.isArray(value)) {
42
- value.forEach(item => {
45
+ value.forEach((item) => {
43
46
  url.searchParams.append(key, String(item));
44
47
  });
45
48
  }
@@ -49,7 +52,7 @@ export class ShopeeFetch {
49
52
  });
50
53
  // Prepare headers
51
54
  const headers = new Headers();
52
- headers.set('Content-Type', 'application/json');
55
+ headers.set("Content-Type", "application/json");
53
56
  if (options.headers) {
54
57
  Object.entries(options.headers).forEach(([key, value]) => {
55
58
  headers.set(key, value);
@@ -63,14 +66,14 @@ export class ShopeeFetch {
63
66
  };
64
67
  try {
65
68
  const response = await fetch(url.toString(), requestOptions);
66
- const responseType = response.headers.get('Content-Type');
67
- const responseData = responseType?.indexOf('application/json') !== -1
69
+ const responseType = response.headers.get("Content-Type");
70
+ const responseData = responseType?.indexOf("application/json") !== -1
68
71
  ? await response.json()
69
72
  : await response.text();
70
- if (responseType?.indexOf('application/json') !== -1) {
73
+ if (responseType?.indexOf("application/json") !== -1) {
71
74
  if (responseData.error) {
72
75
  // Handle invalid access token error
73
- if (responseData.error === 'invalid_acceess_token' && options.auth) {
76
+ if (responseData.error === "invalid_acceess_token" && options.auth) {
74
77
  try {
75
78
  // Attempt to refresh the access token
76
79
  await config.sdk?.refreshToken();
@@ -91,14 +94,14 @@ export class ShopeeFetch {
91
94
  }
92
95
  catch (error) {
93
96
  if (error instanceof Error) {
94
- if (error.name === 'FetchError') {
97
+ if (error.name === "FetchError") {
95
98
  // Network error
96
99
  throw new ShopeeSdkError(`Network error: ${error.message}`);
97
100
  }
98
101
  // Other errors
99
102
  throw new ShopeeSdkError(`Unexpected error: ${error.message}`);
100
103
  }
101
- throw new ShopeeSdkError('Unknown error occurred');
104
+ throw new ShopeeSdkError("Unknown error occurred");
102
105
  }
103
106
  }
104
107
  }
package/lib/fetch.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.js","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAyB,OAAO,EAAe,MAAM,YAAY,CAAC;AAGhF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,OAAO,WAAW;IACf,MAAM,CAAC,KAAK,CAAC,KAAK,CACvB,MAAoB,EACpB,IAAY,EACZ,UAAwB,EAAE;QAE1B,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,MAAM,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,WAAW,EAAE,GAAG,OAAO,CAAC;QACtE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,GAAG,IAAI,EAAE,CAAC,CAAC;QACjD,0BAA0B;QAC1B,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;QAChD,IAAI,SAAS,GAAG,iBAAiB,CAAC,MAAM,CAAC,WAAW,EAAE;YACpD,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE;YAC5B,GAAG,CAAC,QAAQ;YACZ,SAAS,CAAC,QAAQ,EAAE;SACrB,CAAC,CAAC;QAEH,uBAAuB;QACvB,MAAM,CAAC,IAAI,C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,CAAC,GAAG,EAAE,YAAY,EAAE,CAAC;4BACjC,uCAAuC;4BACvC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;wBAC3C,CAAC;wBAAC,OAAO,YAAY,EAAE,CAAC;4BACtB,6CAA6C;4BAC7C,MAAM,IAAI,cAAc,CAAC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;wBAC1D,CAAC;oBACH,CAAC;oBACD,MAAM,IAAI,cAAc,CAAC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;gBAC1D,CAAC;gBAED,MAAM,IAAI,GAAG,YAAiB,CAAC;gBAC/B,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,IAAI,cAAc,CAAC,0BAA0B,YAAY,KAAK,YAAY,EAAE,CAAC,CAAC;QACtF,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;gBAC3B,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;oBAChC,gBAAgB;oBAChB,MAAM,IAAI,cAAc,CAAC,kBAAkB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;gBAC9D,CAAC;gBACD,eAAe;gBACf,MAAM,IAAI,cAAc,CAAC,qBAAqB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACjE,CAAC;YACD,MAAM,IAAI,cAAc,CAAC,wBAAwB,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;CACF"}
@@ -1,6 +1,6 @@
1
1
  import { ShopeeConfig } from "../sdk.js";
2
2
  import { BaseManager } from "./base.manager.js";
3
- import { GetTotalBalanceResponse, GetShopToggleInfoResponse, GetRecommendedKeywordListParams, GetRecommendedKeywordListResponse } from "../schemas/ads.js";
3
+ import { GetTotalBalanceResponse, GetShopToggleInfoResponse, GetRecommendedKeywordListParams, GetRecommendedKeywordListResponse, GetRecommendedItemListResponse, GetAllCpcAdsHourlyPerformanceParams, GetAllCpcAdsHourlyPerformanceResponse, GetAllCpcAdsDailyPerformanceParams, GetAllCpcAdsDailyPerformanceResponse, GetProductCampaignDailyPerformanceParams, GetProductCampaignDailyPerformanceResponse, GetProductCampaignHourlyPerformanceParams, GetProductCampaignHourlyPerformanceResponse, GetProductLevelCampaignIdListParams, GetProductLevelCampaignIdListResponse, GetProductLevelCampaignSettingInfoParams, GetProductLevelCampaignSettingInfoResponse, GetProductRecommendedRoiTargetParams, GetProductRecommendedRoiTargetResponse } from "../schemas/ads.js";
4
4
  export declare class AdsManager extends BaseManager {
5
5
  constructor(config: ShopeeConfig);
6
6
  /**
@@ -50,4 +50,224 @@ export declare class AdsManager extends BaseManager {
50
50
  * Use this API to get keyword suggestions to improve item discoverability in search results.
51
51
  */
52
52
  getRecommendedKeywordList(params: GetRecommendedKeywordListParams): Promise<GetRecommendedKeywordListResponse>;
53
+ /**
54
+ * Get the list of recommended SKUs (Shop level) with the corresponding tag
55
+ * @returns {Promise<GetRecommendedItemListResponse>} Response containing recommended items
56
+ *
57
+ * This API is used to get the list of recommended SKU (Shop level) with the corresponding tag,
58
+ * i.e top search/best selling/best ROI tag.
59
+ *
60
+ * The response includes an array of items with the following details for each item:
61
+ * - item_id: Recommended SKU's item id
62
+ * - item_status_list: Status of items (indicates whether an item is eligible for ads or not)
63
+ * - sku_tag_list: Tags such as "best selling", "best ROI", "top search"
64
+ * - ongoing_ad_type_list: Current status of ads on this item (e.g., search ads, discovery ads)
65
+ *
66
+ * Use this API to identify high-potential items for advertising campaigns.
67
+ */
68
+ getRecommendedItemList(): Promise<GetRecommendedItemListResponse>;
69
+ /**
70
+ * Get shop level CPC ads single-date hourly performance data
71
+ * @param {GetAllCpcAdsHourlyPerformanceParams} params Request parameters
72
+ * @param {string} params.performance_date Single date for hourly performance data in DD-MM-YYYY format
73
+ * @returns {Promise<GetAllCpcAdsHourlyPerformanceResponse>} Response containing hourly performance metrics
74
+ *
75
+ * This API is used to get Shop level CPC ads single-date hourly performance.
76
+ * The date must be today or earlier than today (up to 6 months ago).
77
+ *
78
+ * The response includes an array of hourly performance metrics with the following details for each hour:
79
+ * - hour: The hour the performance record belongs to
80
+ * - date: The date the performance record belongs to
81
+ * - impression: Number of times buyers see ads
82
+ * - clicks: Total number of clicks on the ad
83
+ * - ctr: Click-through rate (Clicks / Impressions)
84
+ * - direct_order: Orders placed within 7 days after clicking on the clicked ad
85
+ * - broad_order: Orders placed within 7 days after clicking on any ad from the same shop
86
+ * - direct_conversions: Direct conversion rate (clicked ad orders / total clicks)
87
+ * - broad_conversions: Broad conversion rate (any shop orders / total clicks)
88
+ * - direct_item_sold: Items sold from the clicked ad
89
+ * - broad_item_sold: Items sold from the shop after any ad click
90
+ * - direct_gmv: Total sales from the clicked ad
91
+ * - broad_gmv: Total sales from the shop after any ad click
92
+ * - expense: Ad expenditure
93
+ * - cost_per_conversion: Average cost per sales conversion
94
+ * - direct_roas: Direct return on ad spend (direct GMV / expense)
95
+ * - broad_roas: Broad return on ad spend (broad GMV / expense)
96
+ *
97
+ * Use this API to analyze hourly ad performance patterns for optimization.
98
+ */
99
+ getAllCpcAdsHourlyPerformance(params: GetAllCpcAdsHourlyPerformanceParams): Promise<GetAllCpcAdsHourlyPerformanceResponse>;
100
+ /**
101
+ * Get shop level CPC ads daily performance data for a date range
102
+ * @param {GetAllCpcAdsDailyPerformanceParams} params Request parameters
103
+ * @param {string} params.start_date Start date of the performance data range in DD-MM-YYYY format
104
+ * @param {string} params.end_date End date of the performance data range in DD-MM-YYYY format
105
+ * @returns {Promise<GetAllCpcAdsDailyPerformanceResponse>} Response containing daily performance metrics
106
+ *
107
+ * This API is used to get Shop level CPC ads multiple-days daily performance.
108
+ * The date range must be today or earlier than today (up to 6 months ago), and cannot exceed 1 month.
109
+ * Start date must be earlier than end date and cannot be equal to end date.
110
+ *
111
+ * The response includes an array of daily performance metrics with the following details for each day:
112
+ * - date: The date the performance record belongs to
113
+ * - impression: Number of times buyers see ads
114
+ * - clicks: Total number of clicks on the ad
115
+ * - ctr: Click-through rate (Clicks / Impressions)
116
+ * - direct_order: Orders placed within 7 days after clicking on the clicked ad
117
+ * - broad_order: Orders placed within 7 days after clicking on any ad from the same shop
118
+ * - direct_conversions: Direct conversion rate (clicked ad orders / total clicks)
119
+ * - broad_conversions: Broad conversion rate (any shop orders / total clicks)
120
+ * - direct_item_sold: Items sold from the clicked ad
121
+ * - broad_item_sold: Items sold from the shop after any ad click
122
+ * - direct_gmv: Total sales from the clicked ad
123
+ * - broad_gmv: Total sales from the shop after any ad click
124
+ * - expense: Ad expenditure
125
+ * - cost_per_conversion: Average cost per sales conversion
126
+ * - direct_roas: Direct return on ad spend (direct GMV / expense)
127
+ * - broad_roas: Broad return on ad spend (broad GMV / expense)
128
+ *
129
+ * Use this API to analyze daily ad performance trends over a time period.
130
+ */
131
+ getAllCpcAdsDailyPerformance(params: GetAllCpcAdsDailyPerformanceParams): Promise<GetAllCpcAdsDailyPerformanceResponse>;
132
+ /**
133
+ * Get product-level campaign performance data for a date range
134
+ * @param {GetProductCampaignDailyPerformanceParams} params Request parameters
135
+ * @param {string} params.start_date Start date of the performance data range in DD-MM-YYYY format
136
+ * @param {string} params.end_date End date of the performance data range in DD-MM-YYYY format
137
+ * @param {string} params.campaign_id_list Comma-separated list of campaign IDs to fetch performance for (max 100)
138
+ * @returns {Promise<GetProductCampaignDailyPerformanceResponse>} Response containing detailed campaign performance metrics
139
+ *
140
+ * This API is used to get product-level ads performance data across multiple days.
141
+ * The date range must be today or earlier than today (up to 6 months ago), and cannot exceed 1 month.
142
+ * Start date must be earlier than end date and cannot be equal to end date.
143
+ *
144
+ * The response is structured hierarchically with:
145
+ * - shop_id and region information
146
+ * - Detailed campaign list with campaign_id, ad_type, campaign_placement, and ad_name
147
+ * - Comprehensive daily metrics for each campaign including:
148
+ * - Impressions, clicks, and CTR
149
+ * - Expense (ad spend)
150
+ * - Direct and broad performance metrics (orders, GMV, ROI)
151
+ * - Conversion rates and cost efficiency metrics
152
+ *
153
+ * Direct metrics refer to performance of the advertised product specifically, while
154
+ * broad metrics account for any purchases from the shop after an ad click.
155
+ *
156
+ * Use this API to analyze campaign effectiveness at the product level and optimize
157
+ * your advertising strategy based on detailed performance data.
158
+ */
159
+ getProductCampaignDailyPerformance(params: GetProductCampaignDailyPerformanceParams): Promise<GetProductCampaignDailyPerformanceResponse>;
160
+ /**
161
+ * Get product-level campaign hourly performance data for a single day
162
+ * @param {GetProductCampaignHourlyPerformanceParams} params Request parameters
163
+ * @param {string} params.performance_date Single date for the hourly performance data in DD-MM-YYYY format
164
+ * @param {string} params.campaign_id_list Comma-separated list of campaign IDs to fetch performance for (max 100)
165
+ * @returns {Promise<GetProductCampaignHourlyPerformanceResponse>} Response containing detailed hourly campaign performance metrics
166
+ *
167
+ * This API is used to get product-level ads hourly performance data for a single day.
168
+ * The date must be today or earlier than today (up to 6 months ago).
169
+ *
170
+ * The response is structured hierarchically with:
171
+ * - shop_id and region information
172
+ * - Detailed campaign list with campaign_id, ad_type, campaign_placement, and ad_name
173
+ * - Comprehensive hourly metrics for each campaign including:
174
+ * - Hour the performance record belongs to
175
+ * - Impressions, clicks, and CTR
176
+ * - Expense (ad spend)
177
+ * - Direct and broad performance metrics (orders, GMV, ROI)
178
+ * - Conversion rates and cost efficiency metrics
179
+ *
180
+ * Direct metrics refer to performance of the advertised product specifically, while
181
+ * broad metrics account for any purchases from the shop after an ad click.
182
+ *
183
+ * Use this API to analyze hourly campaign patterns and performance fluctuations
184
+ * throughout the day to optimize timing of ad campaigns and budget allocation.
185
+ */
186
+ getProductCampaignHourlyPerformance(params: GetProductCampaignHourlyPerformanceParams): Promise<GetProductCampaignHourlyPerformanceResponse>;
187
+ /**
188
+ * Get a list of all product-level campaign IDs for a shop
189
+ * @param {GetProductLevelCampaignIdListParams} [params] Optional request parameters
190
+ * @param {string} [params.ad_type] Filter campaigns by ad type (can be "", "all", "auto", or "manual")
191
+ * @param {number} [params.offset] Pagination offset for fetching subsequent pages
192
+ * @param {number} [params.limit] Page size limit (number of results to return)
193
+ * @returns {Promise<GetProductLevelCampaignIdListResponse>} Response containing campaign IDs and pagination info
194
+ *
195
+ * This API is used to fetch all product campaign IDs displayed on the advertiser platform
196
+ * for a specific shop. The results can be filtered by ad type and paginated using
197
+ * offset and limit parameters.
198
+ *
199
+ * The response contains:
200
+ * - shop_id: The unique identifier for the shop
201
+ * - region: The region where the shop is located
202
+ * - has_next_page: Indicates if there are more campaigns on the next page
203
+ * - campaign_list: List of campaigns with ad_type and campaign_id
204
+ *
205
+ * Use this API to retrieve campaign IDs that can then be used with other APIs
206
+ * like getProductCampaignDailyPerformance or getProductCampaignHourlyPerformance
207
+ * to fetch detailed performance metrics.
208
+ */
209
+ getProductLevelCampaignIdList(params?: GetProductLevelCampaignIdListParams): Promise<GetProductLevelCampaignIdListResponse>;
210
+ /**
211
+ * Get detailed settings information for product-level campaigns
212
+ * @param {GetProductLevelCampaignSettingInfoParams} params Request parameters
213
+ * @param {string} params.info_type_list Comma-separated list of info types to retrieve (1: Common Info, 2: Manual Bidding Info, 3: Auto Bidding Info, 4: Auto Product Ads Info)
214
+ * @param {string} params.campaign_id_list Comma-separated list of campaign IDs to fetch settings for (max 100)
215
+ * @returns {Promise<GetProductLevelCampaignSettingInfoResponse>} Response containing detailed campaign settings
216
+ *
217
+ * This API is used to retrieve detailed configuration settings for product-level ad campaigns.
218
+ * Depending on the info_type_list parameter, different types of information will be returned:
219
+ *
220
+ * Info type 1 (Common Info) includes:
221
+ * - Ad type (auto or manual)
222
+ * - Ad name and status
223
+ * - Bidding method and placement
224
+ * - Campaign budget and duration
225
+ * - List of item IDs in the campaign
226
+ *
227
+ * Info type 2 (Manual Bidding Info) includes:
228
+ * - Enhanced CPC setting
229
+ * - Selected keywords with match types and bid prices
230
+ * - Discovery ads placement settings
231
+ *
232
+ * Info type 3 (Auto Bidding Info) includes:
233
+ * - ROAS (Return on Ad Spend) target
234
+ *
235
+ * Info type 4 (Auto Product Ads Info) includes:
236
+ * - Product name and status
237
+ * - Item IDs
238
+ *
239
+ * Use this API to analyze and understand the detailed settings of your ad campaigns,
240
+ * which can help with optimization and decision-making for future campaign management.
241
+ */
242
+ getProductLevelCampaignSettingInfo(params: GetProductLevelCampaignSettingInfoParams): Promise<GetProductLevelCampaignSettingInfoResponse>;
243
+ /**
244
+ * Get recommended ROI target values for a product's ad campaign
245
+ * @param {GetProductRecommendedRoiTargetParams} params Request parameters
246
+ * @param {string} params.reference_id A random string used to prevent duplicate ads
247
+ * @param {number} params.item_id Unique identifier for a product
248
+ * @returns {Promise<GetProductRecommendedRoiTargetResponse>} Response containing recommended ROI targets
249
+ *
250
+ * This API is used to get recommended Return on Investment (ROI) target values for
251
+ * a product's ad campaign. These recommendations help sellers set competitive ROI
252
+ * targets for their advertising campaigns.
253
+ *
254
+ * The response includes three recommendation levels:
255
+ *
256
+ * - Lower bound: A more competitive target (e.g., value=3.5, percentile=80) that makes
257
+ * the ad more competitive than 80% of similar ads.
258
+ *
259
+ * - Exact (mid-level): A balanced target (e.g., value=5.9, percentile=50) that makes
260
+ * the ad more competitive than 50% of similar ads.
261
+ *
262
+ * - Upper bound: A less competitive target (e.g., value=10.8, percentile=20) that makes
263
+ * the ad more competitive than 20% of similar ads.
264
+ *
265
+ * Each recommendation includes:
266
+ * - value: The recommended ROI target value
267
+ * - percentile: Indicates how competitive this target is compared to similar ads
268
+ *
269
+ * Use this API to help determine optimal ROI targets for your advertising strategy
270
+ * based on competitive marketplace data.
271
+ */
272
+ getProductRecommendedRoiTarget(params: GetProductRecommendedRoiTargetParams): Promise<GetProductRecommendedRoiTargetResponse>;
53
273
  }