@longvansoftware/storefront-js-client 3.8.6 → 3.8.8
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/config/config.d.ts +4 -0
- package/dist/config/config.js +5 -1
- package/dist/src/graphql/paymentV2/queries.d.ts +1 -0
- package/dist/src/graphql/paymentV2/queries.js +21 -1
- package/dist/src/lib/SDK.js +1 -1
- package/dist/src/lib/order/index.d.ts +5 -1
- package/dist/src/lib/order/index.js +28 -2
- package/dist/src/lib/paymentV2/index.d.ts +1 -0
- package/dist/src/lib/paymentV2/index.js +17 -0
- package/dist/src/lib/serviceSDK.d.ts +2 -1
- package/dist/src/lib/serviceSDK.js +2 -1
- package/package.json +1 -1
package/dist/config/config.d.ts
CHANGED
package/dist/config/config.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.environmentEndpoints = void 0;
|
|
3
|
+
exports.environmentEndpoints = exports.defaultTokens = void 0;
|
|
4
|
+
exports.defaultTokens = {
|
|
5
|
+
dev: "0194deb7-288b-7935-88ef-2671719a4324",
|
|
6
|
+
live: "0195f9f6-467c-7ff5-8d83-d0229ef63f8f",
|
|
7
|
+
};
|
|
4
8
|
exports.environmentEndpoints = {
|
|
5
9
|
dev: {
|
|
6
10
|
product: "https://product-service.dev.longvan.vn/product-service/graphql",
|
|
@@ -7,3 +7,4 @@ export declare const GW_CONFIG_DETAIL: import("graphql").DocumentNode;
|
|
|
7
7
|
export declare const GET_PAYMENT_METHOD_TITLES: import("graphql").DocumentNode;
|
|
8
8
|
export declare const GET_PAYEMNT_GATEWAYS_BY_METHOD_CODE: import("graphql").DocumentNode;
|
|
9
9
|
export declare const GET_PAYMENT_METHOD_TYPES_V2: import("graphql").DocumentNode;
|
|
10
|
+
export declare const GET_TRANSFER_INFO: import("graphql").DocumentNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GET_PAYMENT_METHOD_TYPES_V2 = exports.GET_PAYEMNT_GATEWAYS_BY_METHOD_CODE = exports.GET_PAYMENT_METHOD_TITLES = exports.GW_CONFIG_DETAIL = exports.PAYMENT_STATUS = exports.PAYMENT_INFO = exports.GET_PAYMENT_METHOD_TYPES = exports.PAYMENT_METHODS = exports.PAYMENTS_BY_ORDERS = void 0;
|
|
3
|
+
exports.GET_TRANSFER_INFO = exports.GET_PAYMENT_METHOD_TYPES_V2 = exports.GET_PAYEMNT_GATEWAYS_BY_METHOD_CODE = exports.GET_PAYMENT_METHOD_TITLES = exports.GW_CONFIG_DETAIL = exports.PAYMENT_STATUS = exports.PAYMENT_INFO = exports.GET_PAYMENT_METHOD_TYPES = exports.PAYMENT_METHODS = exports.PAYMENTS_BY_ORDERS = void 0;
|
|
4
4
|
const graphql_tag_1 = require("graphql-tag");
|
|
5
5
|
exports.PAYMENTS_BY_ORDERS = (0, graphql_tag_1.gql) `
|
|
6
6
|
query PaymentsByOrders($orderIds: [String!]!) {
|
|
@@ -255,3 +255,23 @@ exports.GET_PAYMENT_METHOD_TYPES_V2 = (0, graphql_tag_1.gql) `
|
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
257
|
`;
|
|
258
|
+
exports.GET_TRANSFER_INFO = (0, graphql_tag_1.gql) `
|
|
259
|
+
query GetTransferInfo(
|
|
260
|
+
$partnerId: String!
|
|
261
|
+
$storeId: String
|
|
262
|
+
$paymentId: String
|
|
263
|
+
) {
|
|
264
|
+
getTransferInfo(
|
|
265
|
+
partnerId: $partnerId
|
|
266
|
+
storeId: $storeId
|
|
267
|
+
paymentId: $paymentId
|
|
268
|
+
) {
|
|
269
|
+
bankCode
|
|
270
|
+
bankName
|
|
271
|
+
accountNumber
|
|
272
|
+
accountName
|
|
273
|
+
description
|
|
274
|
+
transferInfo
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
`;
|
package/dist/src/lib/SDK.js
CHANGED
|
@@ -37,7 +37,7 @@ class SDK {
|
|
|
37
37
|
const endpoints = config_1.environmentEndpoints[environment];
|
|
38
38
|
this.product = new index_1.ProductService(endpoints.product, orgId, storeId);
|
|
39
39
|
this.auth = new index_2.AuthService(endpoints.auth, orgId, storeId);
|
|
40
|
-
this.order = new index_3.OrderService(endpoints.order, orgId, storeId);
|
|
40
|
+
this.order = new index_3.OrderService(endpoints.order, orgId, storeId, environment);
|
|
41
41
|
this.user = new index_5.UserService(endpoints.user, orgId, storeId);
|
|
42
42
|
this.payment = new index_6.PaymentService(endpoints.payment, orgId, storeId);
|
|
43
43
|
this.crm = new index_7.CrmService(endpoints.crm, orgId, storeId);
|
|
@@ -10,8 +10,12 @@ export declare class OrderService extends Service {
|
|
|
10
10
|
* @param orgId - The organization ID.
|
|
11
11
|
* @param storeId - The store ID.
|
|
12
12
|
*/
|
|
13
|
-
constructor(endpoint: string, orgId: string, storeId: string);
|
|
13
|
+
constructor(endpoint: string, orgId: string, storeId: string, environment?: "dev" | "live");
|
|
14
14
|
setToken(token: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Override restApiCallWithToken to use default token if no token is set
|
|
17
|
+
*/
|
|
18
|
+
protected restApiCallWithToken(path: string, method: "GET" | "POST" | "PUT" | "DELETE", data?: any, headers?: any): Promise<any>;
|
|
15
19
|
/**
|
|
16
20
|
* Creates a new order.
|
|
17
21
|
* @param orderData - The data for the order.
|
|
@@ -8,10 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.OrderService = void 0;
|
|
13
16
|
const serviceSDK_1 = require("../serviceSDK");
|
|
14
17
|
const validatePhoneNumber_1 = require("../../utils/validatePhoneNumber");
|
|
18
|
+
const axios_1 = __importDefault(require("axios"));
|
|
19
|
+
const config_1 = require("../../../config/config");
|
|
15
20
|
/**
|
|
16
21
|
* Represents a service for managing orders.
|
|
17
22
|
*/
|
|
@@ -22,12 +27,33 @@ class OrderService extends serviceSDK_1.Service {
|
|
|
22
27
|
* @param orgId - The organization ID.
|
|
23
28
|
* @param storeId - The store ID.
|
|
24
29
|
*/
|
|
25
|
-
constructor(endpoint, orgId, storeId) {
|
|
26
|
-
super(endpoint, orgId, storeId);
|
|
30
|
+
constructor(endpoint, orgId, storeId, environment = "dev") {
|
|
31
|
+
super(endpoint, orgId, storeId, environment);
|
|
27
32
|
}
|
|
28
33
|
setToken(token) {
|
|
29
34
|
this.token = token;
|
|
30
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Override restApiCallWithToken to use default token if no token is set
|
|
38
|
+
*/
|
|
39
|
+
restApiCallWithToken(path, method, data, headers) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const tokenToUse = this.token || config_1.defaultTokens[this.environment];
|
|
42
|
+
try {
|
|
43
|
+
const modifiedHeaders = Object.assign(Object.assign({}, headers), { PartnerId: this.orgId, Authorization: "Bearer " + tokenToUse, "X-Ecomos-Access-Token": tokenToUse, "Partner-Id": this.orgId });
|
|
44
|
+
const response = yield (0, axios_1.default)({
|
|
45
|
+
url: this.endpoint + path,
|
|
46
|
+
method,
|
|
47
|
+
data,
|
|
48
|
+
headers: modifiedHeaders,
|
|
49
|
+
});
|
|
50
|
+
return response.data;
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
31
57
|
/**
|
|
32
58
|
* Creates a new order.
|
|
33
59
|
* @param orderData - The data for the order.
|
|
@@ -15,4 +15,5 @@ export declare class PaymentServiceV2 extends Service {
|
|
|
15
15
|
handleUpdateGatewayConfig(input: any, cassoApiKey: string): Promise<any>;
|
|
16
16
|
getPaymentGatewaysByMethodCode(methodCode: string): Promise<any>;
|
|
17
17
|
getPaymentMethodTypesV2(storeActive: any, allMethodTypes: boolean): Promise<any>;
|
|
18
|
+
getTransferInfo(storeId: string, paymentId: string): Promise<any>;
|
|
18
19
|
}
|
|
@@ -243,5 +243,22 @@ class PaymentServiceV2 extends serviceSDK_1.Service {
|
|
|
243
243
|
}
|
|
244
244
|
});
|
|
245
245
|
}
|
|
246
|
+
getTransferInfo(storeId, paymentId) {
|
|
247
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
248
|
+
const queries = queries_1.GET_TRANSFER_INFO;
|
|
249
|
+
const variables = {
|
|
250
|
+
partnerId: this.orgId,
|
|
251
|
+
storeId,
|
|
252
|
+
paymentId,
|
|
253
|
+
};
|
|
254
|
+
try {
|
|
255
|
+
const response = yield this.graphqlMutationV3(queries, variables);
|
|
256
|
+
return response.getTransferInfo;
|
|
257
|
+
}
|
|
258
|
+
catch (error) {
|
|
259
|
+
throw error;
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
}
|
|
246
263
|
}
|
|
247
264
|
exports.PaymentServiceV2 = PaymentServiceV2;
|
|
@@ -6,7 +6,8 @@ export declare class Service {
|
|
|
6
6
|
protected orgId: string;
|
|
7
7
|
protected storeId: string;
|
|
8
8
|
protected endpoint: string;
|
|
9
|
-
|
|
9
|
+
protected environment: "dev" | "live";
|
|
10
|
+
constructor(endpoint: string, orgId: string, storeId: string, environment?: "dev" | "live");
|
|
10
11
|
setToken(token: string): void;
|
|
11
12
|
setStoreId(storeId: string): void;
|
|
12
13
|
setOrgId(orgId: string): void;
|
|
@@ -18,7 +18,7 @@ const client_1 = require("@apollo/client");
|
|
|
18
18
|
const axios_1 = __importDefault(require("axios"));
|
|
19
19
|
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
20
20
|
class Service {
|
|
21
|
-
constructor(endpoint, orgId, storeId) {
|
|
21
|
+
constructor(endpoint, orgId, storeId, environment = "dev") {
|
|
22
22
|
this.token = null;
|
|
23
23
|
this.client = new client_1.ApolloClient({
|
|
24
24
|
link: new client_1.HttpLink({ uri: endpoint, fetch: cross_fetch_1.default }),
|
|
@@ -33,6 +33,7 @@ class Service {
|
|
|
33
33
|
this.orgId = orgId;
|
|
34
34
|
this.storeId = storeId;
|
|
35
35
|
this.endpoint = endpoint;
|
|
36
|
+
this.environment = environment;
|
|
36
37
|
}
|
|
37
38
|
setToken(token) {
|
|
38
39
|
this.token = token;
|