@congminh1254/shopee-sdk 1.2.0 → 1.3.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/lib/fetch.js +6 -4
- package/lib/fetch.js.map +1 -1
- package/lib/managers/discount.manager.d.ts +47 -1
- package/lib/managers/discount.manager.js +67 -0
- package/lib/managers/discount.manager.js.map +1 -1
- package/lib/schemas/discount.d.ts +67 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +5 -6
package/lib/fetch.js
CHANGED
|
@@ -74,9 +74,11 @@ export class ShopeeFetch {
|
|
|
74
74
|
? await response.json()
|
|
75
75
|
: await response.text();
|
|
76
76
|
if (responseType?.indexOf("application/json") !== -1) {
|
|
77
|
-
|
|
77
|
+
// Type guard for JSON response with error field
|
|
78
|
+
const jsonData = responseData;
|
|
79
|
+
if (jsonData.error) {
|
|
78
80
|
// Handle invalid access token error
|
|
79
|
-
if (
|
|
81
|
+
if (jsonData.error === "invalid_acceess_token" && options.auth) {
|
|
80
82
|
try {
|
|
81
83
|
// Attempt to refresh the access token
|
|
82
84
|
await config.sdk?.refreshToken();
|
|
@@ -85,10 +87,10 @@ export class ShopeeFetch {
|
|
|
85
87
|
}
|
|
86
88
|
catch (refreshError) {
|
|
87
89
|
// If refresh fails, throw the original error
|
|
88
|
-
throw new ShopeeApiError(response.status,
|
|
90
|
+
throw new ShopeeApiError(response.status, jsonData);
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
|
-
throw new ShopeeApiError(response.status,
|
|
93
|
+
throw new ShopeeApiError(response.status, jsonData);
|
|
92
94
|
}
|
|
93
95
|
const data = responseData;
|
|
94
96
|
return data;
|
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;A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AC;IACH,CAAC;CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ShopeeConfig } from "../sdk.js";
|
|
2
2
|
import { BaseManager } from "./base.manager.js";
|
|
3
|
-
import { AddDiscountParams, AddDiscountResponse, AddDiscountItemParams, AddDiscountItemResponse, DeleteDiscountParams, DeleteDiscountResponse, DeleteDiscountItemParams, DeleteDiscountItemResponse, EndDiscountParams, EndDiscountResponse, GetDiscountParams, GetDiscountResponse, GetDiscountListParams, GetDiscountListResponse, UpdateDiscountParams, UpdateDiscountResponse, UpdateDiscountItemParams, UpdateDiscountItemResponse } from "../schemas/discount.js";
|
|
3
|
+
import { AddDiscountParams, AddDiscountResponse, AddDiscountItemParams, AddDiscountItemResponse, DeleteDiscountParams, DeleteDiscountResponse, DeleteDiscountItemParams, DeleteDiscountItemResponse, EndDiscountParams, EndDiscountResponse, GetDiscountParams, GetDiscountResponse, GetDiscountListParams, GetDiscountListResponse, UpdateDiscountParams, UpdateDiscountResponse, UpdateDiscountItemParams, UpdateDiscountItemResponse, GetSipDiscountsParams, GetSipDiscountsResponse, SetSipDiscountParams, SetSipDiscountResponse, DeleteSipDiscountParams, DeleteSipDiscountResponse } from "../schemas/discount.js";
|
|
4
4
|
export declare class DiscountManager extends BaseManager {
|
|
5
5
|
constructor(config: ShopeeConfig);
|
|
6
6
|
/**
|
|
@@ -99,4 +99,50 @@ export declare class DiscountManager extends BaseManager {
|
|
|
99
99
|
* - warning: Warning message if any
|
|
100
100
|
*/
|
|
101
101
|
updateDiscountItem(params: UpdateDiscountItemParams): Promise<UpdateDiscountItemResponse>;
|
|
102
|
+
/**
|
|
103
|
+
* Get SIP Overseas Discounts
|
|
104
|
+
* @param {GetSipDiscountsParams} [params] - Optional parameters for filtering by region
|
|
105
|
+
* @returns {Promise<GetSipDiscountsResponse>} The response containing a list of SIP discounts
|
|
106
|
+
*
|
|
107
|
+
* Only regions that have upcoming/ongoing discounts will be returned.
|
|
108
|
+
* Use Primary shop's Shop ID to request - the API will return the list of Affiliate shops
|
|
109
|
+
* under this Primary shop that have set discounts, along with the discount details.
|
|
110
|
+
*
|
|
111
|
+
* The response includes:
|
|
112
|
+
* - discount_list: Array of discount information for each region
|
|
113
|
+
* - region: The region of the SIP affiliate shop
|
|
114
|
+
* - status: The status of the discount (upcoming/ongoing)
|
|
115
|
+
* - sip_discount_rate: The discount rate percentage
|
|
116
|
+
* - start_time: When the discount starts (UNIX timestamp)
|
|
117
|
+
* - end_time: When the discount ends (UNIX timestamp)
|
|
118
|
+
* - create_time: When the discount was created (UNIX timestamp)
|
|
119
|
+
* - update_time: When the discount was last updated (UNIX timestamp)
|
|
120
|
+
*/
|
|
121
|
+
getSipDiscounts(params?: GetSipDiscountsParams): Promise<GetSipDiscountsResponse>;
|
|
122
|
+
/**
|
|
123
|
+
* Set SIP Overseas Discount for SIP affiliate region
|
|
124
|
+
* @param {SetSipDiscountParams} params - Parameters for setting the SIP discount
|
|
125
|
+
* @returns {Promise<SetSipDiscountResponse>} The response containing the created/updated discount details
|
|
126
|
+
*
|
|
127
|
+
* Use Primary shop's Shop ID to request. Provide the region and discount rate of the Affiliate shop
|
|
128
|
+
* to be set or update - the API will set or update the discount rate for that region's Affiliate shop.
|
|
129
|
+
*
|
|
130
|
+
* Notes:
|
|
131
|
+
* - The start time is 30 minutes after the discount is set
|
|
132
|
+
* - The end time is 180 days after the start time
|
|
133
|
+
* - Cannot edit the promotion within 15 minutes after an update
|
|
134
|
+
* - In VN region, discount rate cannot exceed 50%
|
|
135
|
+
*/
|
|
136
|
+
setSipDiscount(params: SetSipDiscountParams): Promise<SetSipDiscountResponse>;
|
|
137
|
+
/**
|
|
138
|
+
* Delete SIP Overseas Discount for SIP affiliate region
|
|
139
|
+
* @param {DeleteSipDiscountParams} params - Parameters for deleting the SIP discount
|
|
140
|
+
* @returns {Promise<DeleteSipDiscountResponse>} The response containing the deleted region
|
|
141
|
+
*
|
|
142
|
+
* Use Primary shop's Shop ID to request. Provide the region of the Affiliate shop to be deleted,
|
|
143
|
+
* and the API will delete the discount from that region's Affiliate shop.
|
|
144
|
+
*
|
|
145
|
+
* Note: Cannot edit the promotion within 15 minutes after an update
|
|
146
|
+
*/
|
|
147
|
+
deleteSipDiscount(params: DeleteSipDiscountParams): Promise<DeleteSipDiscountResponse>;
|
|
102
148
|
}
|
|
@@ -163,5 +163,72 @@ export class DiscountManager extends BaseManager {
|
|
|
163
163
|
});
|
|
164
164
|
return response;
|
|
165
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Get SIP Overseas Discounts
|
|
168
|
+
* @param {GetSipDiscountsParams} [params] - Optional parameters for filtering by region
|
|
169
|
+
* @returns {Promise<GetSipDiscountsResponse>} The response containing a list of SIP discounts
|
|
170
|
+
*
|
|
171
|
+
* Only regions that have upcoming/ongoing discounts will be returned.
|
|
172
|
+
* Use Primary shop's Shop ID to request - the API will return the list of Affiliate shops
|
|
173
|
+
* under this Primary shop that have set discounts, along with the discount details.
|
|
174
|
+
*
|
|
175
|
+
* The response includes:
|
|
176
|
+
* - discount_list: Array of discount information for each region
|
|
177
|
+
* - region: The region of the SIP affiliate shop
|
|
178
|
+
* - status: The status of the discount (upcoming/ongoing)
|
|
179
|
+
* - sip_discount_rate: The discount rate percentage
|
|
180
|
+
* - start_time: When the discount starts (UNIX timestamp)
|
|
181
|
+
* - end_time: When the discount ends (UNIX timestamp)
|
|
182
|
+
* - create_time: When the discount was created (UNIX timestamp)
|
|
183
|
+
* - update_time: When the discount was last updated (UNIX timestamp)
|
|
184
|
+
*/
|
|
185
|
+
async getSipDiscounts(params) {
|
|
186
|
+
const response = await ShopeeFetch.fetch(this.config, "/discount/get_sip_discounts", {
|
|
187
|
+
method: "GET",
|
|
188
|
+
auth: true,
|
|
189
|
+
params,
|
|
190
|
+
});
|
|
191
|
+
return response;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Set SIP Overseas Discount for SIP affiliate region
|
|
195
|
+
* @param {SetSipDiscountParams} params - Parameters for setting the SIP discount
|
|
196
|
+
* @returns {Promise<SetSipDiscountResponse>} The response containing the created/updated discount details
|
|
197
|
+
*
|
|
198
|
+
* Use Primary shop's Shop ID to request. Provide the region and discount rate of the Affiliate shop
|
|
199
|
+
* to be set or update - the API will set or update the discount rate for that region's Affiliate shop.
|
|
200
|
+
*
|
|
201
|
+
* Notes:
|
|
202
|
+
* - The start time is 30 minutes after the discount is set
|
|
203
|
+
* - The end time is 180 days after the start time
|
|
204
|
+
* - Cannot edit the promotion within 15 minutes after an update
|
|
205
|
+
* - In VN region, discount rate cannot exceed 50%
|
|
206
|
+
*/
|
|
207
|
+
async setSipDiscount(params) {
|
|
208
|
+
const response = await ShopeeFetch.fetch(this.config, "/discount/set_sip_discount", {
|
|
209
|
+
method: "POST",
|
|
210
|
+
auth: true,
|
|
211
|
+
body: params,
|
|
212
|
+
});
|
|
213
|
+
return response;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Delete SIP Overseas Discount for SIP affiliate region
|
|
217
|
+
* @param {DeleteSipDiscountParams} params - Parameters for deleting the SIP discount
|
|
218
|
+
* @returns {Promise<DeleteSipDiscountResponse>} The response containing the deleted region
|
|
219
|
+
*
|
|
220
|
+
* Use Primary shop's Shop ID to request. Provide the region of the Affiliate shop to be deleted,
|
|
221
|
+
* and the API will delete the discount from that region's Affiliate shop.
|
|
222
|
+
*
|
|
223
|
+
* Note: Cannot edit the promotion within 15 minutes after an update
|
|
224
|
+
*/
|
|
225
|
+
async deleteSipDiscount(params) {
|
|
226
|
+
const response = await ShopeeFetch.fetch(this.config, "/discount/delete_sip_discount", {
|
|
227
|
+
method: "POST",
|
|
228
|
+
auth: true,
|
|
229
|
+
body: params,
|
|
230
|
+
});
|
|
231
|
+
return response;
|
|
232
|
+
}
|
|
166
233
|
}
|
|
167
234
|
//# sourceMappingURL=discount.manager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discount.manager.js","sourceRoot":"","sources":["../../src/managers/discount.manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"discount.manager.js","sourceRoot":"","sources":["../../src/managers/discount.manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA2BhD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAC9C,YAAY,MAAoB;QAC9B,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,WAAW,CAAC,MAAyB;QACzC,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,wBAAwB,EACxB;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,MAAM;SACb,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,eAAe,CAAC,MAA6B;QACjD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,6BAA6B,EAC7B;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,MAAM;SACb,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,cAAc,CAAC,MAA4B;QAC/C,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,2BAA2B,EAC3B;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,MAAM;SACb,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,kBAAkB,CAAC,MAAgC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F,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,kBAAkB,CAAC,MAAgC;QACvD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,gCAAgC,EAChC;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,MAAM;SACb,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,KAAK,CAAC,eAAe,CAAC,MAA8B;QAClD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,6BAA6B,EAC7B;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,IAAI;YACV,MAAM;SACP,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,cAAc,CAAC,MAA4B;QAC/C,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,4BAA4B,EAC5B;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,MAAM;SACb,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,iBAAiB,CAAC,MAA+B;QACrD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,+BAA+B,EAC/B;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,MAAM;SACb,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -332,3 +332,70 @@ export interface UpdateDiscountItemResponse extends BaseResponse {
|
|
|
332
332
|
/** Warning message if any */
|
|
333
333
|
warning?: string;
|
|
334
334
|
}
|
|
335
|
+
/**
|
|
336
|
+
* SIP discount information
|
|
337
|
+
*/
|
|
338
|
+
export interface SipDiscountInfo {
|
|
339
|
+
/** The region of SIP affiliate shop */
|
|
340
|
+
region: string;
|
|
341
|
+
/** The status of discount for SIP affiliate shop in current region, can be upcoming/ongoing, excluding expired discounts */
|
|
342
|
+
status: string;
|
|
343
|
+
/** The discount rate set for SIP affiliate shop in current region */
|
|
344
|
+
sip_discount_rate: number;
|
|
345
|
+
/** The start time of discount for SIP affiliate shop in current region, in UNIX seconds */
|
|
346
|
+
start_time: number;
|
|
347
|
+
/** The end time of discount for SIP affiliate shop in current region, in UNIX seconds */
|
|
348
|
+
end_time: number;
|
|
349
|
+
/** The create time of discount for SIP affiliate shop in current region, in UNIX seconds */
|
|
350
|
+
create_time: number;
|
|
351
|
+
/** The latest update time of discount for SIP affiliate shop in current region, in UNIX seconds */
|
|
352
|
+
update_time: number;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Parameters for getting SIP discounts
|
|
356
|
+
*/
|
|
357
|
+
export interface GetSipDiscountsParams {
|
|
358
|
+
/** The region of SIP affiliate shop that needs to get discount information. If not passed, will return the discount information set for all SIP affiliate shops */
|
|
359
|
+
region?: string;
|
|
360
|
+
[key: string]: string | number | boolean | undefined;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Parameters for setting SIP discount
|
|
364
|
+
*/
|
|
365
|
+
export interface SetSipDiscountParams {
|
|
366
|
+
/** The region of SIP affiliate shop that needs to set discount */
|
|
367
|
+
region: string;
|
|
368
|
+
/** The overall market discount rate that will apply to all items for SIP affiliate shop in current region */
|
|
369
|
+
sip_discount_rate: number;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Parameters for deleting SIP discount
|
|
373
|
+
*/
|
|
374
|
+
export interface DeleteSipDiscountParams {
|
|
375
|
+
/** The region of SIP affiliate shop that needs to delete discount */
|
|
376
|
+
region: string;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Response for the get SIP discounts API
|
|
380
|
+
*/
|
|
381
|
+
export interface GetSipDiscountsResponse extends BaseResponse {
|
|
382
|
+
response: {
|
|
383
|
+
/** List of discounts in each region */
|
|
384
|
+
discount_list: SipDiscountInfo[];
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Response for the set SIP discount API
|
|
389
|
+
*/
|
|
390
|
+
export interface SetSipDiscountResponse extends BaseResponse {
|
|
391
|
+
response: SipDiscountInfo;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Response for the delete SIP discount API
|
|
395
|
+
*/
|
|
396
|
+
export interface DeleteSipDiscountResponse extends BaseResponse {
|
|
397
|
+
response: {
|
|
398
|
+
/** The region of SIP affiliate shop that was deleted */
|
|
399
|
+
region: string;
|
|
400
|
+
};
|
|
401
|
+
}
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.
|
|
1
|
+
export declare const SDK_VERSION = "1.3.0";
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@congminh1254/shopee-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Shopee SDK maintaining by community",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/sdk.js",
|
|
@@ -68,22 +68,21 @@
|
|
|
68
68
|
},
|
|
69
69
|
"homepage": "https://github.com/congminh1254/shopee-sdk#readme",
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@types/node-fetch": "^2.6.12",
|
|
72
71
|
"@commitlint/cli": "^20.1.0",
|
|
73
72
|
"@commitlint/config-conventional": "^20.0.0",
|
|
74
|
-
"@types/jest": "^
|
|
73
|
+
"@types/jest": "^30.0.0",
|
|
75
74
|
"@typescript-eslint/eslint-plugin": "^7.0.1",
|
|
76
75
|
"@typescript-eslint/parser": "^7.0.1",
|
|
77
76
|
"eslint": "^8.56.0",
|
|
78
77
|
"eslint-config-prettier": "^10.1.5",
|
|
79
|
-
"husky": "^
|
|
80
|
-
"jest": "^
|
|
78
|
+
"husky": "^9.1.7",
|
|
79
|
+
"jest": "^30.2.0",
|
|
81
80
|
"prettier": "^3.2.5",
|
|
82
81
|
"ts-jest": "^29.3.2",
|
|
83
82
|
"ts-node": "^10.9.2",
|
|
84
83
|
"typescript": "^5.7.3"
|
|
85
84
|
},
|
|
86
85
|
"dependencies": {
|
|
87
|
-
"node-fetch": "^
|
|
86
|
+
"node-fetch": "^3.3.2"
|
|
88
87
|
}
|
|
89
88
|
}
|