@congminh1254/shopee-sdk 0.5.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.
- package/README.md +7 -6
- package/lib/errors.js +2 -2
- package/lib/fetch.d.ts +2 -2
- package/lib/fetch.js +17 -14
- package/lib/fetch.js.map +1 -1
- package/lib/managers/ads.manager.js +22 -22
- package/lib/managers/ads.manager.js.map +1 -1
- package/lib/managers/auth.manager.d.ts +3 -3
- package/lib/managers/auth.manager.js +21 -12
- package/lib/managers/auth.manager.js.map +1 -1
- package/lib/managers/base.manager.d.ts +1 -1
- package/lib/managers/index.d.ts +10 -10
- package/lib/managers/index.js +10 -10
- package/lib/managers/logistics.manager.js +2 -2
- package/lib/managers/logistics.manager.js.map +1 -1
- package/lib/managers/order.manager.d.ts +3 -3
- package/lib/managers/order.manager.js +25 -25
- package/lib/managers/order.manager.js.map +1 -1
- package/lib/managers/payment.manager.js +2 -2
- package/lib/managers/payment.manager.js.map +1 -1
- package/lib/managers/product.manager.d.ts +3 -3
- package/lib/managers/product.manager.js +10 -10
- package/lib/managers/product.manager.js.map +1 -1
- package/lib/managers/public.manager.d.ts +3 -3
- package/lib/managers/public.manager.js +8 -8
- package/lib/managers/push.manager.d.ts +3 -3
- package/lib/managers/push.manager.js +11 -11
- package/lib/managers/push.manager.js.map +1 -1
- package/lib/managers/voucher.manager.js +12 -12
- package/lib/managers/voucher.manager.js.map +1 -1
- package/lib/schemas/access-token.d.ts +2 -1
- package/lib/schemas/attribute.d.ts +4 -4
- package/lib/schemas/fetch.d.ts +2 -2
- package/lib/schemas/index.d.ts +12 -12
- package/lib/schemas/index.js +12 -12
- package/lib/schemas/logistics.d.ts +1 -1
- package/lib/schemas/order.d.ts +26 -26
- package/lib/schemas/order.js +1 -1
- package/lib/schemas/payment.d.ts +1 -1
- package/lib/schemas/product.d.ts +1 -1
- package/lib/schemas/product.js +0 -1
- package/lib/schemas/product.js.map +1 -1
- package/lib/schemas/push.d.ts +1 -1
- package/lib/schemas/region.js +5 -5
- package/lib/schemas/voucher.js.map +1 -1
- package/lib/sdk.d.ts +12 -12
- package/lib/sdk.js +15 -19
- package/lib/sdk.js.map +1 -1
- package/lib/storage/custom-token-storage.d.ts +2 -2
- package/lib/storage/custom-token-storage.js +11 -11
- package/lib/storage/custom-token-storage.js.map +1 -1
- package/lib/storage/token-storage.interface.d.ts +1 -1
- package/lib/utils/signature.js +3 -6
- package/lib/utils/signature.js.map +1 -1
- 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
|
|
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:
|
|
20
|
-
base_url:
|
|
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:
|
|
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 =
|
|
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 =
|
|
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
|
|
2
|
-
import { FetchOptions } from
|
|
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
|
|
2
|
-
import { ShopeeApiError, ShopeeSdkError } from
|
|
3
|
-
import { generateSignature } from
|
|
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 =
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
67
|
-
const responseData = responseType?.indexOf(
|
|
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(
|
|
73
|
+
if (responseType?.indexOf("application/json") !== -1) {
|
|
71
74
|
if (responseData.error) {
|
|
72
75
|
// Handle invalid access token error
|
|
73
|
-
if (responseData.error ===
|
|
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 ===
|
|
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(
|
|
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,G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AY,CAAC,KAAK,KAAK,uBAAuB,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;wBACnE,IAAI,CAAC;4BACH,sCAAsC;4BACtC,MAAM,MAAM,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"}
|
|
@@ -19,8 +19,8 @@ export class AdsManager extends BaseManager {
|
|
|
19
19
|
* that can be used for advertising campaigns.
|
|
20
20
|
*/
|
|
21
21
|
async getTotalBalance() {
|
|
22
|
-
const response = await ShopeeFetch.fetch(this.config,
|
|
23
|
-
method:
|
|
22
|
+
const response = await ShopeeFetch.fetch(this.config, "/ads/get_total_balance", {
|
|
23
|
+
method: "GET",
|
|
24
24
|
auth: true,
|
|
25
25
|
});
|
|
26
26
|
return response;
|
|
@@ -40,8 +40,8 @@ export class AdsManager extends BaseManager {
|
|
|
40
40
|
* These settings affect how ads campaigns are managed and funded.
|
|
41
41
|
*/
|
|
42
42
|
async getShopToggleInfo() {
|
|
43
|
-
const response = await ShopeeFetch.fetch(this.config,
|
|
44
|
-
method:
|
|
43
|
+
const response = await ShopeeFetch.fetch(this.config, "/ads/get_shop_toggle_info", {
|
|
44
|
+
method: "GET",
|
|
45
45
|
auth: true,
|
|
46
46
|
});
|
|
47
47
|
return response;
|
|
@@ -63,8 +63,8 @@ export class AdsManager extends BaseManager {
|
|
|
63
63
|
* Use this API to get keyword suggestions to improve item discoverability in search results.
|
|
64
64
|
*/
|
|
65
65
|
async getRecommendedKeywordList(params) {
|
|
66
|
-
const response = await ShopeeFetch.fetch(this.config,
|
|
67
|
-
method:
|
|
66
|
+
const response = await ShopeeFetch.fetch(this.config, "/ads/get_recommended_keyword_list", {
|
|
67
|
+
method: "GET",
|
|
68
68
|
auth: true,
|
|
69
69
|
params,
|
|
70
70
|
});
|
|
@@ -86,8 +86,8 @@ export class AdsManager extends BaseManager {
|
|
|
86
86
|
* Use this API to identify high-potential items for advertising campaigns.
|
|
87
87
|
*/
|
|
88
88
|
async getRecommendedItemList() {
|
|
89
|
-
const response = await ShopeeFetch.fetch(this.config,
|
|
90
|
-
method:
|
|
89
|
+
const response = await ShopeeFetch.fetch(this.config, "/ads/get_recommended_item_list", {
|
|
90
|
+
method: "GET",
|
|
91
91
|
auth: true,
|
|
92
92
|
});
|
|
93
93
|
return response;
|
|
@@ -123,8 +123,8 @@ export class AdsManager extends BaseManager {
|
|
|
123
123
|
* Use this API to analyze hourly ad performance patterns for optimization.
|
|
124
124
|
*/
|
|
125
125
|
async getAllCpcAdsHourlyPerformance(params) {
|
|
126
|
-
const response = await ShopeeFetch.fetch(this.config,
|
|
127
|
-
method:
|
|
126
|
+
const response = await ShopeeFetch.fetch(this.config, "/ads/get_all_cpc_ads_hourly_performance", {
|
|
127
|
+
method: "GET",
|
|
128
128
|
auth: true,
|
|
129
129
|
params,
|
|
130
130
|
});
|
|
@@ -162,8 +162,8 @@ export class AdsManager extends BaseManager {
|
|
|
162
162
|
* Use this API to analyze daily ad performance trends over a time period.
|
|
163
163
|
*/
|
|
164
164
|
async getAllCpcAdsDailyPerformance(params) {
|
|
165
|
-
const response = await ShopeeFetch.fetch(this.config,
|
|
166
|
-
method:
|
|
165
|
+
const response = await ShopeeFetch.fetch(this.config, "/ads/get_all_cpc_ads_daily_performance", {
|
|
166
|
+
method: "GET",
|
|
167
167
|
auth: true,
|
|
168
168
|
params,
|
|
169
169
|
});
|
|
@@ -197,8 +197,8 @@ export class AdsManager extends BaseManager {
|
|
|
197
197
|
* your advertising strategy based on detailed performance data.
|
|
198
198
|
*/
|
|
199
199
|
async getProductCampaignDailyPerformance(params) {
|
|
200
|
-
const response = await ShopeeFetch.fetch(this.config,
|
|
201
|
-
method:
|
|
200
|
+
const response = await ShopeeFetch.fetch(this.config, "/ads/get_product_campaign_daily_performance", {
|
|
201
|
+
method: "GET",
|
|
202
202
|
auth: true,
|
|
203
203
|
params,
|
|
204
204
|
});
|
|
@@ -231,8 +231,8 @@ export class AdsManager extends BaseManager {
|
|
|
231
231
|
* throughout the day to optimize timing of ad campaigns and budget allocation.
|
|
232
232
|
*/
|
|
233
233
|
async getProductCampaignHourlyPerformance(params) {
|
|
234
|
-
const response = await ShopeeFetch.fetch(this.config,
|
|
235
|
-
method:
|
|
234
|
+
const response = await ShopeeFetch.fetch(this.config, "/ads/get_product_campaign_hourly_performance", {
|
|
235
|
+
method: "GET",
|
|
236
236
|
auth: true,
|
|
237
237
|
params,
|
|
238
238
|
});
|
|
@@ -261,8 +261,8 @@ export class AdsManager extends BaseManager {
|
|
|
261
261
|
* to fetch detailed performance metrics.
|
|
262
262
|
*/
|
|
263
263
|
async getProductLevelCampaignIdList(params) {
|
|
264
|
-
const response = await ShopeeFetch.fetch(this.config,
|
|
265
|
-
method:
|
|
264
|
+
const response = await ShopeeFetch.fetch(this.config, "/ads/get_product_level_campaign_id_list", {
|
|
265
|
+
method: "GET",
|
|
266
266
|
auth: true,
|
|
267
267
|
params,
|
|
268
268
|
});
|
|
@@ -301,8 +301,8 @@ export class AdsManager extends BaseManager {
|
|
|
301
301
|
* which can help with optimization and decision-making for future campaign management.
|
|
302
302
|
*/
|
|
303
303
|
async getProductLevelCampaignSettingInfo(params) {
|
|
304
|
-
const response = await ShopeeFetch.fetch(this.config,
|
|
305
|
-
method:
|
|
304
|
+
const response = await ShopeeFetch.fetch(this.config, "/ads/get_product_level_campaign_setting_info", {
|
|
305
|
+
method: "GET",
|
|
306
306
|
auth: true,
|
|
307
307
|
params,
|
|
308
308
|
});
|
|
@@ -338,8 +338,8 @@ export class AdsManager extends BaseManager {
|
|
|
338
338
|
* based on competitive marketplace data.
|
|
339
339
|
*/
|
|
340
340
|
async getProductRecommendedRoiTarget(params) {
|
|
341
|
-
const response = await ShopeeFetch.fetch(this.config,
|
|
342
|
-
method:
|
|
341
|
+
const response = await ShopeeFetch.fetch(this.config, "/ads/get_product_recommended_roi_target", {
|
|
342
|
+
method: "GET",
|
|
343
343
|
auth: true,
|
|
344
344
|
params,
|
|
345
345
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ads.manager.js","sourceRoot":"","sources":["../../src/managers/ads.manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ads.manager.js","sourceRoot":"","sources":["../../src/managers/ads.manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAsBhD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,O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,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,KAAK,CAAC,kCAAkC,CACtC,MAAgD;QAEhD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,8CAA8C,EAC9C;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,IAAI;YACV,MAAM;SACP,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,KAAK,CAAC,8BAA8B,CAClC,MAA4C;QAE5C,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,yCAAyC,EACzC;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,IAAI;YACV,MAAM;SACP,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ShopeeConfig } from
|
|
2
|
-
import { AccessToken } from
|
|
3
|
-
import { BaseManager } from
|
|
1
|
+
import { ShopeeConfig } from "../sdk.js";
|
|
2
|
+
import { AccessToken } from "../schemas/access-token.js";
|
|
3
|
+
import { BaseManager } from "./base.manager.js";
|
|
4
4
|
export declare class AuthManager extends BaseManager {
|
|
5
5
|
constructor(config: ShopeeConfig);
|
|
6
6
|
getAccessToken(code: string, shopId?: number, mainAccountId?: number): Promise<AccessToken>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ShopeeFetch } from
|
|
2
|
-
import { BaseManager } from
|
|
1
|
+
import { ShopeeFetch } from "../fetch.js";
|
|
2
|
+
import { BaseManager } from "./base.manager.js";
|
|
3
3
|
export class AuthManager extends BaseManager {
|
|
4
4
|
constructor(config) {
|
|
5
5
|
super(config);
|
|
@@ -15,23 +15,29 @@ export class AuthManager extends BaseManager {
|
|
|
15
15
|
if (mainAccountId) {
|
|
16
16
|
body.main_account_id = mainAccountId;
|
|
17
17
|
}
|
|
18
|
-
const response = await ShopeeFetch.fetch(this.config,
|
|
19
|
-
method:
|
|
18
|
+
const response = await ShopeeFetch.fetch(this.config, "/auth/token/get", {
|
|
19
|
+
method: "POST",
|
|
20
20
|
body,
|
|
21
21
|
});
|
|
22
|
+
if (!response.expired_at && response.expire_in) {
|
|
23
|
+
response.expired_at = Date.now() + response.expire_in * 1000 - 60 * 1000;
|
|
24
|
+
}
|
|
22
25
|
return {
|
|
23
26
|
...response,
|
|
24
|
-
shop_id: shopId
|
|
27
|
+
shop_id: shopId,
|
|
25
28
|
};
|
|
26
29
|
}
|
|
27
30
|
async getAccessTokenByResendCode(code) {
|
|
28
31
|
const body = {
|
|
29
32
|
resend_code: code,
|
|
30
33
|
};
|
|
31
|
-
const response = await ShopeeFetch.fetch(this.config,
|
|
32
|
-
method:
|
|
33
|
-
body
|
|
34
|
+
const response = await ShopeeFetch.fetch(this.config, "/public/get_token_by_resend_code", {
|
|
35
|
+
method: "POST",
|
|
36
|
+
body,
|
|
34
37
|
});
|
|
38
|
+
if (!response.expired_at && response.expire_in) {
|
|
39
|
+
response.expired_at = Date.now() + response.expire_in * 1000 - 60 * 1000;
|
|
40
|
+
}
|
|
35
41
|
return response;
|
|
36
42
|
}
|
|
37
43
|
async getRefreshToken(refreshToken, shopId, merchantId) {
|
|
@@ -45,13 +51,16 @@ export class AuthManager extends BaseManager {
|
|
|
45
51
|
if (merchantId) {
|
|
46
52
|
body.merchant_id = merchantId;
|
|
47
53
|
}
|
|
48
|
-
const response = await ShopeeFetch.fetch(this.config,
|
|
49
|
-
method:
|
|
50
|
-
body
|
|
54
|
+
const response = await ShopeeFetch.fetch(this.config, "/auth/access_token/get", {
|
|
55
|
+
method: "POST",
|
|
56
|
+
body,
|
|
51
57
|
});
|
|
58
|
+
if (!response.expired_at && response.expire_in) {
|
|
59
|
+
response.expired_at = Date.now() + response.expire_in * 1000 - 60 * 1000;
|
|
60
|
+
}
|
|
52
61
|
return {
|
|
53
62
|
...response,
|
|
54
|
-
shop_id: shopId
|
|
63
|
+
shop_id: shopId,
|
|
55
64
|
};
|
|
56
65
|
}
|
|
57
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.manager.js","sourceRoot":"","sources":["../../src/managers/auth.manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,OAAO,WAAY,SAAQ,WAAW;IAC1C,YAAY,MAAoB;QAC9B,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAEM,KAAK,CAAC,cAAc,CACzB,IAAY,EACZ,MAAe,EACf,aAAsB;QAEtB,MAAM,IAAI,GAA8C;YACtD,IAAI;YACJ,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU;SACnC,CAAC;QAEF,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACxB,CAAC;QAED,IAAI,aAAa,EAAE,CAAC;YAClB,IAAI,CAAC,eAAe,GAAG,aAAa,CAAC;QACvC,CAAC;QAED,MAAM,QAAQ,GAAgB,MAAM,WAAW,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"auth.manager.js","sourceRoot":"","sources":["../../src/managers/auth.manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,OAAO,WAAY,SAAQ,WAAW;IAC1C,YAAY,MAAoB;QAC9B,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAEM,KAAK,CAAC,cAAc,CACzB,IAAY,EACZ,MAAe,EACf,aAAsB;QAEtB,MAAM,IAAI,GAA8C;YACtD,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I,GAA8C;YACtD,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU;YAClC,aAAa,EAAE,YAAY;SAC5B,CAAC;QAEF,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACxB,CAAC;QAED,IAAI,UAAU,EAAE,CAAC;YACf,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAChC,CAAC;QAED,MAAM,QAAQ,GAAgB,MAAM,WAAW,CAAC,KAAK,CACnD,IAAI,CAAC,MAAM,EACX,wBAAwB,EACxB;YACE,MAAM,EAAE,MAAM;YACd,IAAI;SACL,CACF,CAAC;QAEF,IAAI,CAAC,QAAQ,CAAC,UAAU,IAAI,QAAQ,CAAC,SAAS,EAAE,CAAC;YAC/C,QAAQ,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC,SAAS,GAAG,IAAI,GAAG,EAAE,GAAG,IAAI,CAAC;QAC3E,CAAC;QAED,OAAO;YACL,GAAG,QAAQ;YACX,OAAO,EAAE,MAAM;SAChB,CAAC;IACJ,CAAC;CACF"}
|
package/lib/managers/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
1
|
+
export * from "./auth.manager.js";
|
|
2
|
+
export * from "./base.manager.js";
|
|
3
|
+
export * from "./logistics.manager.js";
|
|
4
|
+
export * from "./order.manager.js";
|
|
5
|
+
export * from "./order.manager.js";
|
|
6
|
+
export * from "./product.manager.js";
|
|
7
|
+
export * from "./public.manager.js";
|
|
8
|
+
export * from "./push.manager.js";
|
|
9
|
+
export * from "./voucher.manager.js";
|
|
10
|
+
export * from "./ads.manager.js";
|
package/lib/managers/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
1
|
+
export * from "./auth.manager.js";
|
|
2
|
+
export * from "./base.manager.js";
|
|
3
|
+
export * from "./logistics.manager.js";
|
|
4
|
+
export * from "./order.manager.js";
|
|
5
|
+
export * from "./order.manager.js";
|
|
6
|
+
export * from "./product.manager.js";
|
|
7
|
+
export * from "./public.manager.js";
|
|
8
|
+
export * from "./push.manager.js";
|
|
9
|
+
export * from "./voucher.manager.js";
|
|
10
|
+
export * from "./ads.manager.js";
|
|
11
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -31,8 +31,8 @@ export class LogisticsManager extends BaseManager {
|
|
|
31
31
|
* - logistics.package_number_not_exist: Package number required for split order
|
|
32
32
|
*/
|
|
33
33
|
async getTrackingInfo(params) {
|
|
34
|
-
const response = await ShopeeFetch.fetch(this.config,
|
|
35
|
-
method:
|
|
34
|
+
const response = await ShopeeFetch.fetch(this.config, "/logistics/get_tracking_info", {
|
|
35
|
+
method: "GET",
|
|
36
36
|
auth: true,
|
|
37
37
|
params,
|
|
38
38
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logistics.manager.js","sourceRoot":"","sources":["../../src/managers/logistics.manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,OAAO,gBAAiB,SAAQ,WAAW;
|
|
1
|
+
{"version":3,"file":"logistics.manager.js","sourceRoot":"","sources":["../../src/managers/logistics.manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,OAAO,gBAAiB,SAAQ,WAAW;IAC/C,YAAY,MAAoB;QAC9B,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,KAAK,CAAC,eAAe,CAAC,MAA6B;QACjD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,8BAA8B,EAC9B;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,IAAI;YACV,MAAM;SACP,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseManager } from
|
|
2
|
-
import { ShopeeConfig } from
|
|
3
|
-
import { GetOrderListParams, GetOrderListResponse, GetOrdersDetailParams, GetOrdersDetailResponse, GetShipmentListParams, GetShipmentListResponse, SplitOrderParams, SplitOrderResponse, UnsplitOrderParams, UnsplitOrderResponse, CancelOrderParams, CancelOrderResponse, GetBuyerInvoiceInfoParams, GetBuyerInvoiceInfoResponse } from
|
|
1
|
+
import { BaseManager } from "./base.manager.js";
|
|
2
|
+
import { ShopeeConfig } from "../sdk.js";
|
|
3
|
+
import { GetOrderListParams, GetOrderListResponse, GetOrdersDetailParams, GetOrdersDetailResponse, GetShipmentListParams, GetShipmentListResponse, SplitOrderParams, SplitOrderResponse, UnsplitOrderParams, UnsplitOrderResponse, CancelOrderParams, CancelOrderResponse, GetBuyerInvoiceInfoParams, GetBuyerInvoiceInfoResponse } from "../schemas/order.js";
|
|
4
4
|
export declare class OrderManager extends BaseManager {
|
|
5
5
|
constructor(config: ShopeeConfig);
|
|
6
6
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseManager } from
|
|
2
|
-
import { ShopeeFetch } from
|
|
1
|
+
import { BaseManager } from "./base.manager.js";
|
|
2
|
+
import { ShopeeFetch } from "../fetch.js";
|
|
3
3
|
export class OrderManager extends BaseManager {
|
|
4
4
|
constructor(config) {
|
|
5
5
|
super(config);
|
|
@@ -20,8 +20,8 @@ export class OrderManager extends BaseManager {
|
|
|
20
20
|
* @returns Promise<GetOrderListResponse> - The response containing order list and pagination information
|
|
21
21
|
*/
|
|
22
22
|
async getOrderList(params) {
|
|
23
|
-
const response = await ShopeeFetch.fetch(this.config,
|
|
24
|
-
method:
|
|
23
|
+
const response = await ShopeeFetch.fetch(this.config, "/order/get_order_list", {
|
|
24
|
+
method: "GET",
|
|
25
25
|
params,
|
|
26
26
|
auth: true,
|
|
27
27
|
});
|
|
@@ -38,11 +38,11 @@ export class OrderManager extends BaseManager {
|
|
|
38
38
|
*/
|
|
39
39
|
async getOrdersDetail(params) {
|
|
40
40
|
const response = await ShopeeFetch.fetch(this.config, `/order/get_order_detail`, {
|
|
41
|
-
method:
|
|
41
|
+
method: "GET",
|
|
42
42
|
auth: true,
|
|
43
43
|
params: {
|
|
44
44
|
...params,
|
|
45
|
-
order_sn_list: params.order_sn_list.join(
|
|
45
|
+
order_sn_list: params.order_sn_list.join(","),
|
|
46
46
|
},
|
|
47
47
|
});
|
|
48
48
|
return response;
|
|
@@ -56,8 +56,8 @@ export class OrderManager extends BaseManager {
|
|
|
56
56
|
* @returns Promise<GetShipmentListResponse> - The response containing shipment list and pagination information
|
|
57
57
|
*/
|
|
58
58
|
async getShipmentList(params) {
|
|
59
|
-
const response = await ShopeeFetch.fetch(this.config,
|
|
60
|
-
method:
|
|
59
|
+
const response = await ShopeeFetch.fetch(this.config, "/order/get_shipment_list", {
|
|
60
|
+
method: "GET",
|
|
61
61
|
params,
|
|
62
62
|
auth: true,
|
|
63
63
|
});
|
|
@@ -71,21 +71,21 @@ export class OrderManager extends BaseManager {
|
|
|
71
71
|
* @returns Promise resolving to the split order response
|
|
72
72
|
*/
|
|
73
73
|
async splitOrder(params) {
|
|
74
|
-
return ShopeeFetch.fetch(this.config,
|
|
75
|
-
method:
|
|
74
|
+
return ShopeeFetch.fetch(this.config, "/order/split_order", {
|
|
75
|
+
method: "POST",
|
|
76
76
|
body: {
|
|
77
77
|
order_sn: params.order_sn,
|
|
78
|
-
package_list: params.package_list.map(pkg => ({
|
|
79
|
-
item_list: pkg.item_list.map(item => ({
|
|
78
|
+
package_list: params.package_list.map((pkg) => ({
|
|
79
|
+
item_list: pkg.item_list.map((item) => ({
|
|
80
80
|
item_id: item.item_id,
|
|
81
81
|
model_id: item.model_id,
|
|
82
82
|
order_item_id: item.order_item_id,
|
|
83
83
|
promotion_group_id: item.promotion_group_id,
|
|
84
|
-
model_quantity: item.model_quantity
|
|
85
|
-
}))
|
|
86
|
-
}))
|
|
84
|
+
model_quantity: item.model_quantity,
|
|
85
|
+
})),
|
|
86
|
+
})),
|
|
87
87
|
},
|
|
88
|
-
auth: true
|
|
88
|
+
auth: true,
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
@@ -103,12 +103,12 @@ export class OrderManager extends BaseManager {
|
|
|
103
103
|
* - Cannot unsplit order with missing items
|
|
104
104
|
*/
|
|
105
105
|
async unsplitOrder(params) {
|
|
106
|
-
return ShopeeFetch.fetch(this.config,
|
|
107
|
-
method:
|
|
106
|
+
return ShopeeFetch.fetch(this.config, "/order/unsplit_order", {
|
|
107
|
+
method: "POST",
|
|
108
108
|
body: {
|
|
109
|
-
order_sn: params.order_sn
|
|
109
|
+
order_sn: params.order_sn,
|
|
110
110
|
},
|
|
111
|
-
auth: true
|
|
111
|
+
auth: true,
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
/**
|
|
@@ -129,14 +129,14 @@ export class OrderManager extends BaseManager {
|
|
|
129
129
|
* - Order has already been shipped
|
|
130
130
|
*/
|
|
131
131
|
async cancelOrder(params) {
|
|
132
|
-
return ShopeeFetch.fetch(this.config,
|
|
133
|
-
method:
|
|
132
|
+
return ShopeeFetch.fetch(this.config, "/order/cancel_order", {
|
|
133
|
+
method: "POST",
|
|
134
134
|
body: {
|
|
135
135
|
order_sn: params.order_sn,
|
|
136
136
|
cancel_reason: params.cancel_reason,
|
|
137
|
-
item_list: params.item_list
|
|
137
|
+
item_list: params.item_list,
|
|
138
138
|
},
|
|
139
|
-
auth: true
|
|
139
|
+
auth: true,
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
@@ -163,7 +163,7 @@ export class OrderManager extends BaseManager {
|
|
|
163
163
|
*/
|
|
164
164
|
async getBuyerInvoiceInfo(params) {
|
|
165
165
|
const response = await ShopeeFetch.fetch(this.config, `/order/get_buyer_invoice_info`, {
|
|
166
|
-
method:
|
|
166
|
+
method: "POST",
|
|
167
167
|
auth: true,
|
|
168
168
|
body: params,
|
|
169
169
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order.manager.js","sourceRoot":"","sources":["../../src/managers/order.manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"order.manager.js","sourceRoot":"","sources":["../../src/managers/order.manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAkBhD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,OAAO,YAAa,SAAQ,WAAW;IAC3C,YAAY,MAAoB;QAC9B,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,YAAY,CAAC,MAA0B;QAC3C,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,CAAC,MAAM,EACX,uBAAuB,EACvB;YACE,MAAM,EAAE,KAAK;YACb,MAAM;YACN,IAAI,EAAE,IAAI;SACX,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,eAAe,CAAC,MAA6B;QACjD,MAAM,QAAQ,GA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;;;;;;OAaG;IACH,KAAK,CAAC,YAAY,CAAC,MAA0B;QAC3C,OAAO,WAAW,CAAC,KAAK,CAAuB,IAAI,CAAC,MAAM,EAAE,sBAAsB,EAAE;YAClF,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,QAAQ,EAAE,MAAM,CAAC,QAAQ;aAC1B;YACD,IAAI,EAAE,IAAI;SACX,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,CAAC,WAAW,CAAC,MAAyB;QACzC,OAAO,WAAW,CAAC,KAAK,CAAsB,IAAI,CAAC,MAAM,EAAE,qBAAqB,EAAE;YAChF,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,aAAa,EAAE,MAAM,CAAC,aAAa;gBACnC,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B;YACD,IAAI,EAAE,IAAI;SACX,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,KAAK,CAAC,mBAAmB,CACvB,MAAiC;QAEjC,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"}
|
|
@@ -28,8 +28,8 @@ export class PaymentManager extends BaseManager {
|
|
|
28
28
|
* - error_not_found: Order income details not found
|
|
29
29
|
*/
|
|
30
30
|
async getEscrowDetail(params) {
|
|
31
|
-
const response = await ShopeeFetch.fetch(this.config,
|
|
32
|
-
method:
|
|
31
|
+
const response = await ShopeeFetch.fetch(this.config, "/payment/get_escrow_detail", {
|
|
32
|
+
method: "GET",
|
|
33
33
|
auth: true,
|
|
34
34
|
params,
|
|
35
35
|
});
|