@things-factory/integration-marketplace 4.3.434 → 4.3.439
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-server/controllers/shopee/refresh-access-token.js +9 -9
- package/dist-server/controllers/shopee/refresh-access-token.js.map +1 -1
- package/dist-server/controllers/shopee/shopee.js +19 -14
- package/dist-server/controllers/shopee/shopee.js.map +1 -1
- package/dist-server/graphql/resolvers/marketplace-store/shopee/generate-shopee-access-token.js +14 -14
- package/dist-server/graphql/resolvers/marketplace-store/shopee/generate-shopee-access-token.js.map +1 -1
- package/package.json +5 -5
- package/server/controllers/shopee/refresh-access-token.ts +11 -9
- package/server/controllers/shopee/shopee.ts +24 -15
- package/server/graphql/resolvers/marketplace-store/shopee/generate-shopee-access-token.ts +16 -15
|
@@ -5,9 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.refreshAccessToken = void 0;
|
|
7
7
|
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
-
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
9
8
|
const typeorm_1 = require("typeorm");
|
|
10
9
|
const env_1 = require("@things-factory/env");
|
|
10
|
+
const integration_base_1 = require("@things-factory/integration-base");
|
|
11
11
|
const entities_1 = require("../../entities");
|
|
12
12
|
const shopeeConfig = env_1.config.get('marketplaceIntegrationShopee', {});
|
|
13
13
|
const { partnerId, partnerKey, isUAT } = shopeeConfig;
|
|
@@ -41,14 +41,14 @@ const refreshAccessToken = async (store_uuid, shop_id, refresh_token, old_access
|
|
|
41
41
|
shop_id: parseInt(shop_id)
|
|
42
42
|
};
|
|
43
43
|
const jsondata = JSON.stringify(data);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const result =
|
|
44
|
+
let requestPayload = {
|
|
45
|
+
url: `${getAuthUrl()}?${qs}`,
|
|
46
|
+
method: 'POST',
|
|
47
|
+
headers: { 'Content-Type': 'application/json' },
|
|
48
|
+
body: data
|
|
49
|
+
};
|
|
50
|
+
const response = await (0, integration_base_1.lambdaService)('Generic-requestProxy', requestPayload);
|
|
51
|
+
const result = JSON.parse(response.result);
|
|
52
52
|
if (result.error) {
|
|
53
53
|
env_1.logger.error(`Failed to refresh Shopee token: ${result.error} - shop ID (${shop_id})`);
|
|
54
54
|
throw result.error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh-access-token.js","sourceRoot":"","sources":["../../../server/controllers/shopee/refresh-access-token.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA2B;AAC3B,
|
|
1
|
+
{"version":3,"file":"refresh-access-token.js","sourceRoot":"","sources":["../../../server/controllers/shopee/refresh-access-token.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA2B;AAC3B,qCAA2D;AAE3D,6CAAoD;AACpD,uEAAgE;AAEhE,6CAAiD;AAEjD,MAAM,YAAY,GAAG,YAAM,CAAC,GAAG,CAAC,8BAA8B,EAAE,EAAE,CAAC,CAAA;AACnE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,YAAY,CAAA;AACrD,MAAM,WAAW,GAAG,wBAAwB,CAAA;AAErC,MAAM,kBAAkB,GAAG,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,EAAE;IAC/F,IAAI,gBAAgB,GAAqB,MAAM,IAAA,uBAAa,EAAC,2BAAgB,CAAC;SAC3E,kBAAkB,CAAC,IAAI,CAAC;SACxB,KAAK,CAAC,aAAa,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC;SACxC,MAAM,EAAE,CAAA;IAEX,IAAI,gBAAgB,IAAI,gBAAgB,CAAC,WAAW,EAAE;QACpD,OAAO;YACL,WAAW,EAAE,gBAAgB,CAAC,WAAW;SAC1C,CAAA;KACF;I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AAC,mCAAmC,MAAM,CAAC,KAAK,eAAe,OAAO,GAAG,CAAC,CAAA;QACtF,MAAM,MAAM,CAAC,KAAK,CAAA;KACnB;IAED,MAAM,MAAM,GAAG;QACb,WAAW,EAAE,MAAM,CAAC,YAAY;QAChC,YAAY,EAAE,MAAM,CAAC,aAAa,CAAC,qBAAqB;KACzD,CAAA;IAED,MAAM,IAAA,4BAAkB,GAAE,CAAC,MAAM,CAAC,2BAAgB,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE,CAAA;IAE/G,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AA5DY,QAAA,kBAAkB,sBA4D9B;AAED,SAAS,UAAU;IACjB,OAAO,kBAAkB,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,2BAA2B,WAAW,EAAE,CAAA;AAC9F,CAAC"}
|
|
@@ -81,10 +81,13 @@ class Shopee {
|
|
|
81
81
|
const qs = Object.entries(data)
|
|
82
82
|
.map(([k, v]) => `${k}=${encodeURIComponent(String(v))}`)
|
|
83
83
|
.join('&');
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
let requestPayload = {
|
|
85
|
+
url: `${this.getBaseUrl()}/api/v2/${endpoint}${qs ? '?' + qs : ''}`,
|
|
86
|
+
method: 'GET',
|
|
87
|
+
headers: {}
|
|
88
|
+
};
|
|
89
|
+
const response = await (0, integration_base_1.lambdaService)('Generic-requestProxy', requestPayload);
|
|
90
|
+
const result = JSON.parse(response.result);
|
|
88
91
|
try {
|
|
89
92
|
(0, integration_base_1.createPayloadLog)(shopid, endpoint, qs, result, {
|
|
90
93
|
state: { domain: null }
|
|
@@ -113,28 +116,30 @@ class Shopee {
|
|
|
113
116
|
.join('&');
|
|
114
117
|
const jsondata = JSON.stringify(data);
|
|
115
118
|
debug('data', data);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
headers: {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
119
|
+
let requestPayload = {
|
|
120
|
+
url: `${this.getBaseUrl()}/api/v2/${endpoint}${qs ? '?' + qs : ''}`,
|
|
121
|
+
method: 'POST',
|
|
122
|
+
headers: { 'Content-Type': 'application/json' },
|
|
123
|
+
responseType: endpoint == '/logistics/download_shipping_document' ? 'buffer' : null,
|
|
124
|
+
body: data
|
|
125
|
+
};
|
|
126
|
+
const response = await (0, integration_base_1.lambdaService)('Generic-requestProxy', requestPayload);
|
|
127
|
+
let responseResult = JSON.parse(response.result);
|
|
123
128
|
let result;
|
|
124
129
|
if (endpoint == '/logistics/download_shipping_document') {
|
|
125
130
|
try {
|
|
126
|
-
let awb =
|
|
131
|
+
let awb = Buffer.from(responseResult.data);
|
|
127
132
|
result = {
|
|
128
133
|
awb,
|
|
129
134
|
data
|
|
130
135
|
};
|
|
131
136
|
}
|
|
132
137
|
catch (_a) {
|
|
133
|
-
result =
|
|
138
|
+
result = responseResult;
|
|
134
139
|
}
|
|
135
140
|
}
|
|
136
141
|
else {
|
|
137
|
-
result =
|
|
142
|
+
result = responseResult;
|
|
138
143
|
try {
|
|
139
144
|
(0, integration_base_1.createPayloadLog)(shopid, endpoint, jsondata, result, {
|
|
140
145
|
state: { domain: null }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shopee.js","sourceRoot":"","sources":["../../../server/controllers/shopee/shopee.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA2B;AAC3B,4DAA8B;
|
|
1
|
+
{"version":3,"file":"shopee.js","sourceRoot":"","sources":["../../../server/controllers/shopee/shopee.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA2B;AAC3B,4DAA8B;AAE9B,uEAAkF;AAElF,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,+CAA+C,CAAC,CAAA;AAa/E,MAAa,MAAM;IAGj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ACL,MAAM,GAAG,cAAc,CAAA;YACvB,IAAI;gBACF,IAAA,mCAAgB,EAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE;oBACnD,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;iBACxB,CAAC,CAAA;aACH;YAAC,OAAO,CAAC,EAAE,GAAE;SACf;QAED,KAAK,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAA;QAEhC,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AArLD,wBAqLC"}
|
package/dist-server/graphql/resolvers/marketplace-store/shopee/generate-shopee-access-token.js
CHANGED
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.generateShopeeAccessToken = void 0;
|
|
7
7
|
const crypto_1 = __importDefault(require("crypto"));
|
|
8
8
|
const debug_1 = __importDefault(require("debug"));
|
|
9
|
-
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
10
9
|
const uuid_1 = require("uuid");
|
|
11
10
|
const env_1 = require("@things-factory/env");
|
|
11
|
+
const integration_base_1 = require("@things-factory/integration-base");
|
|
12
12
|
const entities_1 = require("../../../../entities");
|
|
13
13
|
const constants_1 = require("../../../constants");
|
|
14
14
|
const shopeeConfig = env_1.config.get('marketplaceIntegrationShopee', {});
|
|
@@ -39,21 +39,21 @@ exports.generateShopeeAccessToken = {
|
|
|
39
39
|
partner_id: Number(partnerId)
|
|
40
40
|
};
|
|
41
41
|
const jsondata = JSON.stringify(data);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
let requestPayload = {
|
|
43
|
+
url: authUrl,
|
|
44
|
+
method: 'POST',
|
|
45
|
+
headers: { 'Content-Type': 'application/json' },
|
|
46
|
+
body: data
|
|
47
|
+
};
|
|
48
|
+
const response = await (0, integration_base_1.lambdaService)('Generic-requestProxy', requestPayload);
|
|
49
|
+
const result = JSON.parse(response.result);
|
|
50
|
+
debug('response result', result);
|
|
51
|
+
if (result.error) {
|
|
52
|
+
const errorText = result.message;
|
|
51
53
|
debug('response result', errorText);
|
|
52
|
-
env_1.logger.error(`[Generate-Shopee-Access-Token]: Response code: ${
|
|
53
|
-
throw new Error(`unexpected error with response code - ${
|
|
54
|
+
env_1.logger.error(`[Generate-Shopee-Access-Token]: Response code: ${result.error}, Message: ${errorText}`);
|
|
55
|
+
throw new Error(`unexpected error with response code - ${result.error}, message: ${errorText}`);
|
|
54
56
|
}
|
|
55
|
-
const result = await response.json();
|
|
56
|
-
debug('response result', result);
|
|
57
57
|
var patch = {
|
|
58
58
|
accessToken: result.access_token,
|
|
59
59
|
refreshToken: result.refresh_token,
|
package/dist-server/graphql/resolvers/marketplace-store/shopee/generate-shopee-access-token.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-shopee-access-token.js","sourceRoot":"","sources":["../../../../../server/graphql/resolvers/marketplace-store/shopee/generate-shopee-access-token.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA2B;AAC3B,kDAAyB;AACzB
|
|
1
|
+
{"version":3,"file":"generate-shopee-access-token.js","sourceRoot":"","sources":["../../../../../server/graphql/resolvers/marketplace-store/shopee/generate-shopee-access-token.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA2B;AAC3B,kDAAyB;AACzB,+BAAmC;AAEnC,6CAAoD;AACpD,uEAAgE;AAEhE,mDAA2E;AAC3E,kDAAiD;AAEjD,MAAM,YAAY,GAAG,YAAM,CAAC,GAAG,CAAC,8BAA8B,EAAE,EAAE,CAAC,CAAA;AACnE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,YAAY,CAAA;AAErD,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,qEAAqE,CAAC,CAAA;AAE7E,QAAA,yBAAyB,GAAG;IACvC,KAAK,CAAC,yBAAyB,CAAC,CAAM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,EAAE,MAAM,EAAE,QAAQ,EAAE;aAC9C,CAAC,CAAA;YAEF,IAAI,CAAC,uBAAuB,EAAE;gBAC5B,MAAM,kBAAkB,GAAG,IAAI,6BAAkB,EAAE,CAAA;gBACnD,kBAAkB,CAAC,IAAI,GAAG,IAAA,SAAM,GAAE,CAAA;gBAClC,kBAAkB,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;gBACtD,kBAAkB,CAAC,KAAK,GAAG,KAAK,CAAA;gBAChC,kBAAkB,CAAC,QAAQ,GAAG,QAAQ,CAAA;gBACtC,kBAAkB,CAAC,MAAM,GAAG,MAAM,CAAA;gBAClC,kBAAkB,CAAC,OAAO,GAAG,IAAI,CAAA;gBACjC,MAAM,EAAE,CAAC,aAAa,CAAC,6BAAkB,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;aACpE;QACH,CAAC,CAAC,CAAA;QAEF,OAAO,MAAM,UAAU,CAAC,IAAI,+CACvB,gBAAgB,GAChB,KAAK,KACR,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,IAC3B,CAAA;IACJ,CAAC;CACF,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/integration-marketplace",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.439",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
"@things-factory/context-ui": "^4.3.434",
|
|
32
32
|
"@things-factory/grist-ui": "^4.3.434",
|
|
33
33
|
"@things-factory/i18n-base": "^4.3.434",
|
|
34
|
-
"@things-factory/integration-lmd": "^4.3.
|
|
35
|
-
"@things-factory/integration-ui": "^4.3.
|
|
34
|
+
"@things-factory/integration-lmd": "^4.3.437",
|
|
35
|
+
"@things-factory/integration-ui": "^4.3.437",
|
|
36
36
|
"@things-factory/more-ui": "^4.3.434",
|
|
37
37
|
"@things-factory/resource-ui": "^4.3.434",
|
|
38
|
-
"@things-factory/setting-ui": "^4.3.
|
|
38
|
+
"@things-factory/setting-ui": "^4.3.437",
|
|
39
39
|
"@things-factory/system-ui": "^4.3.434",
|
|
40
40
|
"debug": "^4.1.1",
|
|
41
41
|
"node-fetch": "^2.6.0",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"nock": "^13.0.2",
|
|
52
52
|
"should": "^13.2.3"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "55395487b5e1e8bf975684c7af2f9f480443fdbf"
|
|
55
55
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import crypto from 'crypto'
|
|
2
|
-
import fetch from 'node-fetch'
|
|
3
2
|
import { createQueryBuilder, getRepository } from 'typeorm'
|
|
3
|
+
|
|
4
4
|
import { config, logger } from '@things-factory/env'
|
|
5
|
+
import { lambdaService } from '@things-factory/integration-base'
|
|
6
|
+
|
|
5
7
|
import { MarketplaceStore } from '../../entities'
|
|
6
8
|
|
|
7
9
|
const shopeeConfig = config.get('marketplaceIntegrationShopee', {})
|
|
@@ -44,16 +46,16 @@ export const refreshAccessToken = async (store_uuid, shop_id, refresh_token, old
|
|
|
44
46
|
|
|
45
47
|
const jsondata = JSON.stringify(data)
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (!response.ok) {
|
|
53
|
-
throw 'Failed to get response to refresh Shopee access token'
|
|
49
|
+
let requestPayload = {
|
|
50
|
+
url: `${getAuthUrl()}?${qs}`,
|
|
51
|
+
method: 'POST',
|
|
52
|
+
headers: { 'Content-Type': 'application/json' },
|
|
53
|
+
body: data
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
const
|
|
56
|
+
const response = await lambdaService('Generic-requestProxy', requestPayload)
|
|
57
|
+
|
|
58
|
+
const result = JSON.parse(response.result)
|
|
57
59
|
|
|
58
60
|
if (result.error) {
|
|
59
61
|
logger.error(`Failed to refresh Shopee token: ${result.error} - shop ID (${shop_id})`)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import crypto from 'crypto'
|
|
2
2
|
import fetch from 'node-fetch'
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
import { createPayloadLog, lambdaService } from '@things-factory/integration-base'
|
|
4
5
|
|
|
5
6
|
const debug = require('debug')('things-factory:integration-marketplace:shopee')
|
|
6
7
|
|
|
@@ -116,11 +117,16 @@ export class Shopee {
|
|
|
116
117
|
.map(([k, v]) => `${k}=${encodeURIComponent(String(v))}`)
|
|
117
118
|
.join('&')
|
|
118
119
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
let requestPayload = {
|
|
121
|
+
url: `${this.getBaseUrl()}/api/v2/${endpoint}${qs ? '?' + qs : ''}`,
|
|
122
|
+
method: 'GET',
|
|
123
|
+
headers: {}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const response = await lambdaService('Generic-requestProxy', requestPayload)
|
|
127
|
+
|
|
128
|
+
const result = JSON.parse(response.result)
|
|
122
129
|
|
|
123
|
-
const result = await response.json()
|
|
124
130
|
try {
|
|
125
131
|
createPayloadLog(shopid, endpoint, qs, result, {
|
|
126
132
|
state: { domain: null }
|
|
@@ -156,27 +162,30 @@ export class Shopee {
|
|
|
156
162
|
|
|
157
163
|
debug('data', data)
|
|
158
164
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
headers: {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
165
|
+
let requestPayload = {
|
|
166
|
+
url: `${this.getBaseUrl()}/api/v2/${endpoint}${qs ? '?' + qs : ''}`,
|
|
167
|
+
method: 'POST',
|
|
168
|
+
headers: { 'Content-Type': 'application/json' },
|
|
169
|
+
responseType: endpoint == '/logistics/download_shipping_document' ? 'buffer' : null,
|
|
170
|
+
body: data
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const response = await lambdaService('Generic-requestProxy', requestPayload)
|
|
166
174
|
|
|
175
|
+
let responseResult: any = JSON.parse(response.result)
|
|
167
176
|
let result
|
|
168
177
|
if (endpoint == '/logistics/download_shipping_document') {
|
|
169
178
|
try {
|
|
170
|
-
let awb =
|
|
179
|
+
let awb = Buffer.from(responseResult.data)
|
|
171
180
|
result = {
|
|
172
181
|
awb,
|
|
173
182
|
data
|
|
174
183
|
}
|
|
175
184
|
} catch {
|
|
176
|
-
result =
|
|
185
|
+
result = responseResult
|
|
177
186
|
}
|
|
178
187
|
} else {
|
|
179
|
-
result =
|
|
188
|
+
result = responseResult
|
|
180
189
|
try {
|
|
181
190
|
createPayloadLog(shopid, endpoint, jsondata, result, {
|
|
182
191
|
state: { domain: null }
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import crypto from 'crypto'
|
|
2
2
|
import Debug from 'debug'
|
|
3
|
-
import fetch from 'node-fetch'
|
|
4
3
|
import { v4 as uuidv4 } from 'uuid'
|
|
5
4
|
|
|
6
5
|
import { config, logger } from '@things-factory/env'
|
|
6
|
+
import { lambdaService } from '@things-factory/integration-base'
|
|
7
7
|
|
|
8
8
|
import { MarketplaceSetting, MarketplaceStore } from '../../../../entities'
|
|
9
9
|
import { STORE_STATUS } from '../../../constants'
|
|
@@ -44,24 +44,25 @@ export const generateShopeeAccessToken = {
|
|
|
44
44
|
|
|
45
45
|
const jsondata = JSON.stringify(data)
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
body: jsondata
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
if (!response.ok) {
|
|
56
|
-
const errorText = await response.text()
|
|
57
|
-
debug('response result', errorText)
|
|
58
|
-
logger.error(`[Generate-Shopee-Access-Token]: Response code: ${response.status}, Message: ${errorText}`)
|
|
59
|
-
throw new Error(`unexpected error with response code - ${response.status}, message: ${errorText}`)
|
|
47
|
+
let requestPayload = {
|
|
48
|
+
url: authUrl,
|
|
49
|
+
method: 'POST',
|
|
50
|
+
headers: { 'Content-Type': 'application/json' },
|
|
51
|
+
body: data
|
|
60
52
|
}
|
|
61
53
|
|
|
62
|
-
const
|
|
54
|
+
const response = await lambdaService('Generic-requestProxy', requestPayload)
|
|
55
|
+
|
|
56
|
+
const result = JSON.parse(response.result)
|
|
63
57
|
debug('response result', result)
|
|
64
58
|
|
|
59
|
+
if (result.error) {
|
|
60
|
+
const errorText = result.message
|
|
61
|
+
debug('response result', errorText)
|
|
62
|
+
logger.error(`[Generate-Shopee-Access-Token]: Response code: ${result.error}, Message: ${errorText}`)
|
|
63
|
+
throw new Error(`unexpected error with response code - ${result.error}, message: ${errorText}`)
|
|
64
|
+
}
|
|
65
|
+
|
|
65
66
|
var patch = {
|
|
66
67
|
accessToken: result.access_token,
|
|
67
68
|
refreshToken: result.refresh_token,
|