lazada-api-client 1.0.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/LICENSE ADDED
@@ -0,0 +1,12 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2026 PKMM97
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted,
6
+ provided that the above copyright notice and this permission notice appear in all copies.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
9
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
11
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
12
+ THIS SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # lazada-api-client
2
+
3
+ A TypeScript client for Lazada Open API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install lazada-api-client
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { LazadaModule } from 'lazada-api-client';
15
+
16
+ const lazada = new LazadaModule({
17
+ appKey: 'YOUR_APP_KEY',
18
+ appSecret: 'YOUR_APP_SECRET',
19
+ shopId: 'YOUR_SHOP_ID',
20
+ appAccessToken: 'YOUR_ACCESS_TOKEN',
21
+ });
22
+
23
+ const products = await lazada.getProducts();
24
+ ```
25
+
26
+ ## Auth
27
+
28
+ ```typescript
29
+ const url = lazada.generateAuthLink('https://your-app.com/lazada/callback', 'YOUR_APP_KEY', 'STATE_UUID');
30
+ const token = await lazada.fetchTokenWithAuthCode('AUTH_CODE_FROM_LAZADA', 'STATE_UUID');
31
+ ```
32
+
33
+ ## Supported APIs
34
+
35
+ | Method | Description |
36
+ | ------------------------ | ----------------------------------- |
37
+ | `generateAuthLink` | Generate Lazada authorization URL |
38
+ | `fetchTokenWithAuthCode` | Fetch access token with auth code |
39
+ | `refreshToken` | Refresh access token |
40
+ | `getOrdersBeforeSomeDay` | Get recent orders |
41
+ | `getOrderDetail` | Get order detail |
42
+ | `getProducts` | Get product list |
43
+ | `getProductItem` | Get product item detail |
44
+ | `createProduct` | Create product |
45
+ | `updateSellableQuantity` | Update sellable quantity |
46
+ | `updateStatusProduct` | Update product status |
47
+ | `updatePrice` | Update product price |
48
+ | `getCategoryTree` | Get category tree |
49
+ | `getBrands` | Get brand list |
50
+
51
+ ## Build
52
+
53
+ ```bash
54
+ npm run build
55
+ ```
56
+
57
+ ## Publish
58
+
59
+ ```bash
60
+ npm login
61
+ npm test
62
+ npm pack --dry-run
63
+ npm publish
64
+ ```
65
+
66
+ The package publishes only `dist`, `README.md`, `LICENSE`, and `package.json`.
@@ -0,0 +1,6 @@
1
+ export { LazadaModule } from './module/lazada';
2
+ export { LazadaConfig, LazadaConfigList } from './module/lazada/dto/request/config.request';
3
+ export { LZD_UPDATE_SELLABLE_QUANTITY, LZD_UPDATE_STATUS_PRODUCT, } from './module/lazada/dto/request/product.request';
4
+ export { LazadaResponseAccessToken } from './module/lazada/dto/response/config.response';
5
+ export { LazadaResponsePackOrder, LazadaResponseRTSOrder, LazadaResponseTraceOrder, } from './module/lazada/dto/response/order.response';
6
+ export { LazadaResponseProductItem, LazadaResponseReview } from './module/lazada/dto/response/product.response';
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LazadaResponseReview = exports.LazadaModule = void 0;
4
+ var lazada_1 = require("./module/lazada");
5
+ Object.defineProperty(exports, "LazadaModule", { enumerable: true, get: function () { return lazada_1.LazadaModule; } });
6
+ var product_response_1 = require("./module/lazada/dto/response/product.response");
7
+ Object.defineProperty(exports, "LazadaResponseReview", { enumerable: true, get: function () { return product_response_1.LazadaResponseReview; } });
@@ -0,0 +1,21 @@
1
+ import { LazadaConfig } from '../dto/request/config.request';
2
+ import { LazadaResponseAccessToken } from '../dto/response/config.response';
3
+ /**
4
+ *
5
+ * @param host
6
+ * @param appKey
7
+ * @param shopId
8
+ * @returns
9
+ */
10
+ export declare function generateAuthLink(redirectURL: string, appKey: string, uuid: string): {
11
+ url: string;
12
+ redirect: string;
13
+ };
14
+ /**
15
+ *
16
+ * @param authCode
17
+ * @param config
18
+ * @returns
19
+ */
20
+ export declare function fetchTokenWithAuthCode(authCode: string, uuid: string, config: LazadaConfig): Promise<LazadaResponseAccessToken>;
21
+ export declare function refreshToken(config: LazadaConfig): Promise<any>;
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.generateAuthLink = generateAuthLink;
46
+ exports.fetchTokenWithAuthCode = fetchTokenWithAuthCode;
47
+ exports.refreshToken = refreshToken;
48
+ const constant_1 = require("../common/constant");
49
+ const helper_1 = require("../common/helper");
50
+ const LazadaHelper = __importStar(require("../common/helper"));
51
+ /**
52
+ *
53
+ * @param host
54
+ * @param appKey
55
+ * @param shopId
56
+ * @returns
57
+ */
58
+ function generateAuthLink(redirectURL, appKey, uuid) {
59
+ const queryParams = new URLSearchParams({
60
+ response_type: 'code',
61
+ redirect_uri: redirectURL,
62
+ client_id: appKey,
63
+ uuid,
64
+ });
65
+ const url = decodeURIComponent(`${constant_1.LZD_END_POINT_AUTH}?${queryParams}`);
66
+ return { url, redirect: redirectURL };
67
+ }
68
+ /**
69
+ *
70
+ * @param authCode
71
+ * @param config
72
+ * @returns
73
+ */
74
+ function fetchTokenWithAuthCode(authCode, uuid, config) {
75
+ const { appKey, appSecret } = config;
76
+ const payload = {
77
+ app_key: appKey,
78
+ sign_method: constant_1.LZD_ALGORITHM,
79
+ timestamp: LazadaHelper.getTimestampMilisec(),
80
+ code: authCode,
81
+ uuid,
82
+ };
83
+ return (0, helper_1.executeAuth)(constant_1.LAZADA_PATH.FETCH_TOKEN, payload, appSecret);
84
+ }
85
+ function refreshToken(config) {
86
+ return __awaiter(this, void 0, void 0, function* () {
87
+ const payload = {
88
+ refresh_token: config.refreshToken,
89
+ app_key: config.appKey,
90
+ sign_method: constant_1.LZD_ALGORITHM,
91
+ timestamp: LazadaHelper.getTimestampMilisec(),
92
+ };
93
+ return LazadaHelper.httpGet(constant_1.LAZADA_PATH.REFRESH_TOKEN, payload, config.appSecret);
94
+ });
95
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ *
3
+ * @param info
4
+ * @param order_id
5
+ * @returns
6
+ */
7
+ export declare function getOrderById(info: any, order_id: string): Promise<any>;
8
+ export declare function getOrdersBeforeSomeDay(info: any, offset?: number, limit?: number): Promise<any>;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.getOrderById = getOrderById;
46
+ exports.getOrdersBeforeSomeDay = getOrdersBeforeSomeDay;
47
+ const constant_1 = require("../common/constant");
48
+ const LazadaHelper = __importStar(require("../common/helper"));
49
+ /**
50
+ *
51
+ * @param info
52
+ * @param order_id
53
+ * @returns
54
+ */
55
+ function getOrderById(info, order_id) {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ const obj = {
58
+ order_id,
59
+ app_key: info.appKey,
60
+ sign_method: constant_1.LZD_ALGORITHM,
61
+ timestamp: LazadaHelper.getTimestampMilisec(),
62
+ access_token: info.appAccessToken,
63
+ };
64
+ return LazadaHelper.httpGet(constant_1.LAZADA_PATH.SINGLE_ORDER_GET, obj, info.appSecret);
65
+ });
66
+ }
67
+ function getOrdersBeforeSomeDay(info_1) {
68
+ return __awaiter(this, arguments, void 0, function* (info, offset = 1, limit = 100) {
69
+ const fifteenDaysAgo = new Date();
70
+ fifteenDaysAgo.setDate(fifteenDaysAgo.getDate() - 1);
71
+ fifteenDaysAgo.setHours(0, 0, 0, 0);
72
+ const obj = {
73
+ offset,
74
+ limit,
75
+ app_key: info.appKey,
76
+ sign_method: constant_1.LZD_ALGORITHM,
77
+ timestamp: LazadaHelper.getTimestampMilisec(),
78
+ access_token: info.appAccessToken,
79
+ update_after: fifteenDaysAgo.toISOString(),
80
+ };
81
+ return LazadaHelper.httpGet(constant_1.LAZADA_PATH.ORDERS_GET, obj, info.appSecret);
82
+ });
83
+ }
@@ -0,0 +1,50 @@
1
+ import { LazadaConfig } from '../dto/request/config.request';
2
+ import { LZD_UPDATE_SELLABLE_QUANTITY, LZD_UPDATE_STATUS_PRODUCT } from '../dto/request/product.request';
3
+ /**
4
+ *
5
+ * @param info
6
+ * @returns
7
+ */
8
+ export declare function getProducts(info: any): Promise<any[]>;
9
+ /**
10
+ *
11
+ * @param info
12
+ * @param itemId
13
+ * @returns
14
+ */
15
+ export declare function getProductItem(info: any, itemId: number): Promise<any>;
16
+ /**
17
+ *
18
+ * @param info
19
+ * @param itemId
20
+ * @param payload
21
+ * @returns
22
+ */
23
+ export declare function updateSellableQuantity(info: any, itemId: any, payload: Array<LZD_UPDATE_SELLABLE_QUANTITY>): Promise<any>;
24
+ /**
25
+ *
26
+ * @param info
27
+ * @param itemId
28
+ * @param payload
29
+ * @returns
30
+ */
31
+ export declare function updateStatusProduct(info: any, itemId: number, payload: Array<LZD_UPDATE_STATUS_PRODUCT>): Promise<any>;
32
+ /**
33
+ *
34
+ * @param itemId
35
+ * @param info
36
+ * @param payload
37
+ * @returns
38
+ */
39
+ export declare function updatePrice(info: any, itemId: number, payload: any): Promise<any>;
40
+ export declare function getCategoryTree(info: any): Promise<any>;
41
+ export declare function getCategorySuggestion(info: any, productName: string): Promise<any>;
42
+ export declare function getCategoryAttributes(info: any, categoryId: string): Promise<any>;
43
+ /**
44
+ *
45
+ * @param {} payload
46
+ * @param {LazadaConfig} config
47
+ * @returns
48
+ */
49
+ export declare function createProduct(payload: any, config: LazadaConfig): Promise<any>;
50
+ export declare function getBrandByPages(info: any): Promise<any>;
@@ -0,0 +1,232 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.getProducts = getProducts;
46
+ exports.getProductItem = getProductItem;
47
+ exports.updateSellableQuantity = updateSellableQuantity;
48
+ exports.updateStatusProduct = updateStatusProduct;
49
+ exports.updatePrice = updatePrice;
50
+ exports.getCategoryTree = getCategoryTree;
51
+ exports.getCategorySuggestion = getCategorySuggestion;
52
+ exports.getCategoryAttributes = getCategoryAttributes;
53
+ exports.createProduct = createProduct;
54
+ exports.getBrandByPages = getBrandByPages;
55
+ const constant_1 = require("../common/constant");
56
+ const helper_1 = require("../common/helper");
57
+ const LazadaHelper = __importStar(require("../common/helper"));
58
+ /**
59
+ *
60
+ * @param info
61
+ * @returns
62
+ */
63
+ function getProducts(info) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ var _a;
66
+ const obj = {
67
+ app_key: info.appKey,
68
+ sign_method: constant_1.LZD_ALGORITHM,
69
+ timestamp: new Date().getTime(),
70
+ access_token: info.appAccessToken,
71
+ };
72
+ const productList = [];
73
+ let i = 0;
74
+ while (i < 10000) {
75
+ obj['offset'] = i;
76
+ obj['limit'] = 50;
77
+ try {
78
+ const response = yield LazadaHelper.httpGet(constant_1.LAZADA_PATH.PRODUCT_GET, obj, info.appSecret);
79
+ if (!((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.products))
80
+ break;
81
+ productList.push(...response.data.products);
82
+ }
83
+ catch (err) {
84
+ console.log('[GetProductList]', err);
85
+ }
86
+ i += 50;
87
+ }
88
+ return productList;
89
+ });
90
+ }
91
+ /**
92
+ *
93
+ * @param info
94
+ * @param itemId
95
+ * @returns
96
+ */
97
+ function getProductItem(info, itemId) {
98
+ return __awaiter(this, void 0, void 0, function* () {
99
+ const obj = {
100
+ item_id: itemId,
101
+ app_key: info.appKey,
102
+ sign_method: constant_1.LZD_ALGORITHM,
103
+ access_token: info.appAccessToken,
104
+ timestamp: LazadaHelper.getTimestampMilisec(),
105
+ };
106
+ return LazadaHelper.httpGet(constant_1.LAZADA_PATH.PRODUCT_ITEM_GET, obj, info.appSecret);
107
+ });
108
+ }
109
+ /**
110
+ *
111
+ * @param info
112
+ * @param itemId
113
+ * @param payload
114
+ * @returns
115
+ */
116
+ function updateSellableQuantity(info, itemId, payload) {
117
+ return __awaiter(this, void 0, void 0, function* () {
118
+ const obj = {
119
+ app_key: info.appKey,
120
+ sign_method: constant_1.LZD_ALGORITHM,
121
+ payload: (0, helper_1.toRequestProductsXML)(payload.map((x) => (0, helper_1.toProductXML)(itemId, x.skuId, x === null || x === void 0 ? void 0 : x.sellerSku, x.quantity))),
122
+ timestamp: LazadaHelper.getTimestampMilisec(),
123
+ access_token: info.appAccessToken,
124
+ };
125
+ return LazadaHelper.httpGet(constant_1.LAZADA_PATH.UPDATE_SELLABLE_QUANTITY, obj, info.appSecret);
126
+ });
127
+ }
128
+ /**
129
+ *
130
+ * @param info
131
+ * @param itemId
132
+ * @param payload
133
+ * @returns
134
+ */
135
+ function updateStatusProduct(info, itemId, payload) {
136
+ return __awaiter(this, void 0, void 0, function* () {
137
+ const obj = {
138
+ app_key: info.appKey,
139
+ sign_method: constant_1.LZD_ALGORITHM,
140
+ payload: (0, helper_1.toRequestProductsXML)(payload.map((x) => (0, helper_1.productParametersXML)(itemId, x.skuId, x === null || x === void 0 ? void 0 : x.sellerSku, x.status))),
141
+ timestamp: LazadaHelper.getTimestampMilisec(),
142
+ access_token: info.appAccessToken,
143
+ };
144
+ return (0, helper_1.executePOST)(constant_1.LAZADA_PATH.UPDATE_PRODUCT, obj, info.appSecret);
145
+ });
146
+ }
147
+ /**
148
+ *
149
+ * @param itemId
150
+ * @param info
151
+ * @param payload
152
+ * @returns
153
+ */
154
+ function updatePrice(info, itemId, payload) {
155
+ return __awaiter(this, void 0, void 0, function* () {
156
+ const obj = {
157
+ app_key: info.appKey,
158
+ sign_method: constant_1.LZD_ALGORITHM,
159
+ payload: (0, helper_1.toRequestProductsXML)(payload.map((x) => (0, helper_1.priceParametersXML)(itemId, x.skuId, x === null || x === void 0 ? void 0 : x.sellerSku, x.price))),
160
+ timestamp: LazadaHelper.getTimestampMilisec(),
161
+ access_token: info.appAccessToken,
162
+ };
163
+ return (0, helper_1.executePOST)(constant_1.LAZADA_PATH.UPDATE_PRICE, obj, info.appSecret);
164
+ });
165
+ }
166
+ function getCategoryTree(info) {
167
+ return __awaiter(this, void 0, void 0, function* () {
168
+ const obj = {
169
+ app_key: info.appKey,
170
+ sign_method: constant_1.LZD_ALGORITHM,
171
+ access_token: info.appAccessToken,
172
+ timestamp: LazadaHelper.getTimestampMilisec(),
173
+ };
174
+ return LazadaHelper.httpGet('/category/tree/get', obj, info.appSecret);
175
+ });
176
+ }
177
+ function getCategorySuggestion(info, productName) {
178
+ return __awaiter(this, void 0, void 0, function* () {
179
+ const obj = {
180
+ app_key: info.appKey,
181
+ sign_method: constant_1.LZD_ALGORITHM,
182
+ access_token: info.appAccessToken,
183
+ timestamp: LazadaHelper.getTimestampMilisec(),
184
+ product_name: productName,
185
+ };
186
+ return LazadaHelper.httpGet('/product/category/suggestion/get', obj, info.appSecret);
187
+ });
188
+ }
189
+ function getCategoryAttributes(info, categoryId) {
190
+ return __awaiter(this, void 0, void 0, function* () {
191
+ const obj = {
192
+ app_key: info.appKey,
193
+ sign_method: constant_1.LZD_ALGORITHM,
194
+ access_token: info.appAccessToken,
195
+ timestamp: LazadaHelper.getTimestampMilisec(),
196
+ primary_category_id: categoryId,
197
+ };
198
+ return LazadaHelper.httpGet('/category/attributes/get', obj, info.appSecret);
199
+ });
200
+ }
201
+ /**
202
+ *
203
+ * @param {} payload
204
+ * @param {LazadaConfig} config
205
+ * @returns
206
+ */
207
+ function createProduct(payload, config) {
208
+ return __awaiter(this, void 0, void 0, function* () {
209
+ const obj = {
210
+ app_key: config.appKey,
211
+ sign_method: constant_1.LZD_ALGORITHM,
212
+ payload: LazadaHelper.createProductParametersXML2(payload),
213
+ timestamp: LazadaHelper.getTimestampMilisec(),
214
+ access_token: config.appAccessToken,
215
+ };
216
+ console.log(obj);
217
+ return (0, helper_1.executePOST)(constant_1.LAZADA_PATH.CREATE_PRODUCT, obj, config.appSecret);
218
+ });
219
+ }
220
+ function getBrandByPages(info) {
221
+ return __awaiter(this, void 0, void 0, function* () {
222
+ const obj = {
223
+ app_key: info.appKey,
224
+ sign_method: constant_1.LZD_ALGORITHM,
225
+ access_token: info.appAccessToken,
226
+ timestamp: LazadaHelper.getTimestampMilisec(),
227
+ startRow: 0,
228
+ pageSize: 20,
229
+ };
230
+ return LazadaHelper.httpGet('/category/brands/query', obj, info.appSecret);
231
+ });
232
+ }
@@ -0,0 +1,87 @@
1
+ declare enum PRODUCT_STATUS {
2
+ ACTIVE = "active",
3
+ INACTIVE = "inactive",
4
+ DELETED = "deleted"
5
+ }
6
+ declare enum REVERSE_STATUS {
7
+ REQUEST_INITIATE = "REQUEST_INITIATE",
8
+ REQUEST_REJECT = "REQUEST_REJECT",
9
+ REQUEST_CANCEL = "REQUEST_CANCEL",
10
+ CANCEL_SUCCESS = "CANCEL_SUCCESS",
11
+ REFUND_PENDING = "REFUND_PENDING",
12
+ REFUND_AUTHORIZED = "REFUND_AUTHORIZED",
13
+ REFUND_SUCCESS = "REFUND_SUCCESS",
14
+ REFUND_REJECT = "REFUND_REJECT",
15
+ REQUEST_COMPLETE = "REQUEST_COMPLETE",
16
+ SELLER_AGREE_RETURN = "SELLER_AGREE_RETURN",
17
+ SELLER_REJECT_RETURN = "SELLER_REJECT_RETURN",
18
+ BUYER_RETURN_ITEM = "BUYER_RETURN_ITEM",
19
+ SELLER_AGREE_REFUND = "SELLER_AGREE_REFUND",
20
+ SELLER_REJECT_REFUND = "SELLER_REJECT_REFUND",
21
+ CS_APPROVING = "CS_APPROVING",
22
+ AGREE_CANCEL_ORDER = "AGREE_CANCEL_ORDER",
23
+ REJECT_CANCEL_ORDER = "REJECT_CANCEL_ORDER"
24
+ }
25
+ declare enum ORDER_STATUS {
26
+ UNPAID = "UNPAID",
27
+ PENDING = "PENDING",
28
+ PACKED = "PACKED",
29
+ READY_TO_SHIP = "READY_TO_SHIP",
30
+ READY_TO_SHIP_PENDING = "READY_TO_SHIP_PENDING",
31
+ SHIPPED = "SHIPPED",
32
+ FAILED_DELIVERY = "FAILED_DELIVERY",
33
+ DELIVERED = "DELIVERED",
34
+ CONFIRMED = "CONFIRMED",
35
+ LOST_BY_3PL = "LOST_BY_3PL",
36
+ DAMAGED_BY_3PL = "DAMAGED_BY_3PL",
37
+ RETURNED = "RETURNED",
38
+ CANCELED = "CANCELED",
39
+ SHIPPED_BACK = "SHIPPED_BACK",
40
+ SHIPPED_BACK_SUCCESS = "SHIPPED_BACK_SUCCESS",
41
+ SHIPPED_BACK_FAILED = "SHIPPED_BACK_FAILED",
42
+ PACKED_SCRAPPED = "PACKED_SCRAPPED"
43
+ }
44
+ declare enum WEBHOOK_TYPE {
45
+ ORDER = 0,
46
+ AUTH_EXPIRE = 8,
47
+ REVERSE = 10,
48
+ FULFILLMENT = 14,
49
+ PRODUCT = 21
50
+ }
51
+ declare const BUYER_USERNAME = "Kh\u00E1ch h\u00E0ng \u0111\u00E1nh gi\u00E1";
52
+ declare const MAX_RANGE_CAN_BE_REVIEW = 12;
53
+ declare const TIME_RANGE_EXCEED = 7;
54
+ declare const END_POINT = "https://api.lazada.vn/rest";
55
+ declare const END_POINT_AUTH = "https://auth.lazada.com/oauth/authorize";
56
+ declare const ALGORITHM = "sha256";
57
+ declare const DIGEST = "hex";
58
+ declare const DROP_SHIP = "dropship";
59
+ declare enum PATH {
60
+ PRODUCT_GET = "/products/get",
61
+ UPDATE_SELLABLE_QUANTITY = "/product/stock/sellable/update",
62
+ UPDATE_PRICE = "/product/price_quantity/update",
63
+ ORDERS_GET = "/orders/get",
64
+ SINGLE_ORDER_GET = "/order/get",
65
+ SINGLE_ORDER_ITEM_GET = "/order/items/get",
66
+ PRODUCT_ITEM_GET = "/product/item/get",
67
+ SET_STATUS_TO_PACKED_BY_MARKETPLACE = "/order/pack",
68
+ REVERSE_LIST = "/reverse/getreverseordersforseller",
69
+ REVERSE_DETAIL = "/order/reverse/return/detail/list",
70
+ SHIPPING_LABEL_GET = "/order/document/awb/pdf/get",
71
+ SHIPPING_LABEL_V2 = "/order/package/document/get",
72
+ STREAM_S3 = "/stream-s3",
73
+ FULFILL_PACK = "/order/fulfill/pack",
74
+ SHIPMENT_PROVIDERS = "/order/shipment/providers/get",
75
+ READY_TO_SHIP = "/order/package/rts",
76
+ HISTORY_REVIEW = "/review/seller/history/list",
77
+ REVIEW_LIST = "/review/seller/list/v2",
78
+ UPDATE_PRODUCT = "/product/update",
79
+ TRACE_ORDER = "/logistic/order/trace",
80
+ FETCH_TOKEN = "/auth/token/create",
81
+ REFRESH_TOKEN = "/auth/token/refresh",
82
+ CREATE_PRODUCT = "/product/create"
83
+ }
84
+ declare enum CODE {
85
+ SUCCESS = "0"
86
+ }
87
+ export { PRODUCT_STATUS as LAZADA_PRODUCT_STATUS, REVERSE_STATUS as LAZADA_REVERSE_STATUS, ORDER_STATUS as LAZADA_ORDER_STATUS, PATH as LAZADA_PATH, CODE as LAZADA_CODE, WEBHOOK_TYPE as LAZADA_WEBHOOK_TYPE, END_POINT as LZD_END_POINT, END_POINT_AUTH as LZD_END_POINT_AUTH, ALGORITHM as LZD_ALGORITHM, DIGEST as LZD_DIGEST, DROP_SHIP as LZD_DROP_SHIP, BUYER_USERNAME as LZD_BUYER_USERNAME, TIME_RANGE_EXCEED as LZD_TIME_RANGE_EXCEED, MAX_RANGE_CAN_BE_REVIEW as LZD_MAX_RANGE_CAN_BE_REVIEW, };