@longvansoftware/service-js-client 1.1.9 → 1.2.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/dist/config/config.d.ts +2 -0
- package/dist/config/config.js +4 -2
- package/dist/src/graphql/cloud/queries.d.ts +1 -0
- package/dist/src/graphql/cloud/queries.js +7 -2
- package/dist/src/graphql/paymentLV/queries.d.ts +1 -0
- package/dist/src/graphql/paymentLV/queries.js +39 -0
- package/dist/src/lib/SDK.d.ts +3 -0
- package/dist/src/lib/SDK.js +3 -0
- package/dist/src/lib/cloud/index.d.ts +1 -0
- package/dist/src/lib/cloud/index.js +16 -0
- package/dist/src/lib/paymentLV/index.d.ts +6 -0
- package/dist/src/lib/paymentLV/index.js +40 -0
- package/dist/src/lib/serviceSDK.d.ts +1 -0
- package/dist/src/lib/serviceSDK.js +26 -1
- package/package.json +1 -1
package/dist/config/config.d.ts
CHANGED
@@ -13,6 +13,7 @@ export declare const environmentEndpoints: {
|
|
13
13
|
dns: string;
|
14
14
|
crm_camping: string;
|
15
15
|
order_graphQL: string;
|
16
|
+
paymentLV: string;
|
16
17
|
};
|
17
18
|
live: {
|
18
19
|
product: string;
|
@@ -28,5 +29,6 @@ export declare const environmentEndpoints: {
|
|
28
29
|
dns: string;
|
29
30
|
crm_camping: string;
|
30
31
|
order_graphQL: string;
|
32
|
+
paymentLV: string;
|
31
33
|
};
|
32
34
|
};
|
package/dist/config/config.js
CHANGED
@@ -15,7 +15,8 @@ exports.environmentEndpoints = {
|
|
15
15
|
cloud: "https://api-gateway.dev.longvan.vn/cloud-service-api/graphql",
|
16
16
|
dns: "https://admin-dev.longvan.net/powerdns/dns",
|
17
17
|
crm_camping: "https://crm.dev.longvan.vn/campaign-gateway/graphql",
|
18
|
-
order_graphQL: "https://api-gateway.dev.longvan.vn/order-cloud-service/graphql"
|
18
|
+
order_graphQL: "https://api-gateway.dev.longvan.vn/order-cloud-service/graphql",
|
19
|
+
paymentLV: "https://payment.dev.longvan.vn/graphql",
|
19
20
|
},
|
20
21
|
live: {
|
21
22
|
product: "https://product-service.longvan.vn/product-service/graphql",
|
@@ -30,6 +31,7 @@ exports.environmentEndpoints = {
|
|
30
31
|
cloud: "https://api-gateway.longvan.vn/cloud-service-api/graphql",
|
31
32
|
dns: "https://admin.longvan.net/powerdns/dns",
|
32
33
|
crm_camping: "https://crm.longvan.vn/campaign-gateway/graphql",
|
33
|
-
order_graphQL: "https://api-gateway.longvan.vn/order-cloud-service/graphql"
|
34
|
+
order_graphQL: "https://api-gateway.longvan.vn/order-cloud-service/graphql",
|
35
|
+
paymentLV: "https://payment.longvan.vn/graphql",
|
34
36
|
},
|
35
37
|
};
|
@@ -4,3 +4,4 @@ export declare const GET_USER_MAIL_HOSTING: import("graphql").DocumentNode;
|
|
4
4
|
export declare const SERVICE_TYPE: import("graphql").DocumentNode;
|
5
5
|
export declare const SEARCH_SERVICE: import("graphql").DocumentNode;
|
6
6
|
export declare const GET_PRODUCTS_OF_SERVICE: import("graphql").DocumentNode;
|
7
|
+
export declare const GET_IPS_OF_SERVICE: import("graphql").DocumentNode;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.GET_PRODUCTS_OF_SERVICE = exports.SEARCH_SERVICE = exports.SERVICE_TYPE = exports.GET_USER_MAIL_HOSTING = exports.GET_MAIL_RESOURCE = exports.SERVICE_DETAIL = void 0;
|
3
|
+
exports.GET_IPS_OF_SERVICE = exports.GET_PRODUCTS_OF_SERVICE = exports.SEARCH_SERVICE = exports.SERVICE_TYPE = exports.GET_USER_MAIL_HOSTING = exports.GET_MAIL_RESOURCE = exports.SERVICE_DETAIL = void 0;
|
4
4
|
const graphql_tag_1 = require("graphql-tag");
|
5
5
|
exports.SERVICE_DETAIL = (0, graphql_tag_1.gql) `
|
6
6
|
query ServiceDetail($serviceId: String) {
|
@@ -120,7 +120,12 @@ exports.SEARCH_SERVICE = (0, graphql_tag_1.gql) `
|
|
120
120
|
}
|
121
121
|
`;
|
122
122
|
exports.GET_PRODUCTS_OF_SERVICE = (0, graphql_tag_1.gql) `
|
123
|
-
query GetProductsOfService($serviceId: String!){
|
123
|
+
query GetProductsOfService($serviceId: String!) {
|
124
124
|
getProductsOfService(serviceId: $serviceId)
|
125
125
|
}
|
126
126
|
`;
|
127
|
+
exports.GET_IPS_OF_SERVICE = (0, graphql_tag_1.gql) `
|
128
|
+
query GetIpsOfService($serviceId: String!) {
|
129
|
+
getIpsOfService(serviceId: $serviceId)
|
130
|
+
}
|
131
|
+
`;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const PAYMENTS_BY_ORDERS: import("graphql").DocumentNode;
|
@@ -0,0 +1,39 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.PAYMENTS_BY_ORDERS = void 0;
|
4
|
+
const graphql_tag_1 = require("graphql-tag");
|
5
|
+
exports.PAYMENTS_BY_ORDERS = (0, graphql_tag_1.gql) `
|
6
|
+
query PaymentsByOrders($orderIds: [String!]!) {
|
7
|
+
paymentsByOrders(orderIds: $orderIds) {
|
8
|
+
methodCode
|
9
|
+
partnerCode
|
10
|
+
totalAmount
|
11
|
+
fee
|
12
|
+
discountAmount
|
13
|
+
payDate
|
14
|
+
payType
|
15
|
+
transactionDate
|
16
|
+
orderId
|
17
|
+
paymentId
|
18
|
+
invoiceId
|
19
|
+
orderInfo
|
20
|
+
orderType
|
21
|
+
locale
|
22
|
+
merchantIp
|
23
|
+
extraData
|
24
|
+
storeID
|
25
|
+
bankCode
|
26
|
+
appUser
|
27
|
+
phone
|
28
|
+
email
|
29
|
+
address
|
30
|
+
statusCode
|
31
|
+
statusDescription
|
32
|
+
transactionId
|
33
|
+
createBy
|
34
|
+
methodDescription
|
35
|
+
methodMapping
|
36
|
+
baseMethodCode
|
37
|
+
}
|
38
|
+
}
|
39
|
+
`;
|
package/dist/src/lib/SDK.d.ts
CHANGED
@@ -11,6 +11,7 @@ import { CloudService } from "./cloud";
|
|
11
11
|
import { DnsService } from "../lib/dns/index";
|
12
12
|
import { CrmCampingService } from "./crm_camping";
|
13
13
|
import { OrderGraphQLService } from "./orderGraphQL";
|
14
|
+
import { PaymentLVService } from "./paymentLV";
|
14
15
|
export interface Endpoints {
|
15
16
|
product: string;
|
16
17
|
crm: string;
|
@@ -25,6 +26,7 @@ export interface Endpoints {
|
|
25
26
|
dns: string;
|
26
27
|
crm_camping: string;
|
27
28
|
order_graphQL: string;
|
29
|
+
paymentLV: string;
|
28
30
|
}
|
29
31
|
export declare class SDK {
|
30
32
|
orgId: string;
|
@@ -44,6 +46,7 @@ export declare class SDK {
|
|
44
46
|
dns: DnsService;
|
45
47
|
crm_camping: CrmCampingService;
|
46
48
|
order_graphQL: OrderGraphQLService;
|
49
|
+
paymentLV: PaymentLVService;
|
47
50
|
token: string | null;
|
48
51
|
constructor(orgId: string, storeId: string, storefrontAccessToken: string, environment: string);
|
49
52
|
setToken(token: string): void;
|
package/dist/src/lib/SDK.js
CHANGED
@@ -17,6 +17,7 @@ const cloud_1 = require("./cloud");
|
|
17
17
|
const index_10 = require("../lib/dns/index");
|
18
18
|
const crm_camping_1 = require("./crm_camping");
|
19
19
|
const orderGraphQL_1 = require("./orderGraphQL");
|
20
|
+
const paymentLV_1 = require("./paymentLV");
|
20
21
|
class SDK {
|
21
22
|
constructor(orgId, storeId, storefrontAccessToken, environment) {
|
22
23
|
this.orgId = orgId;
|
@@ -43,6 +44,7 @@ class SDK {
|
|
43
44
|
this.dns = new index_10.DnsService(endpoints.dns, orgId, storeId);
|
44
45
|
this.crm_camping = new crm_camping_1.CrmCampingService(endpoints.crm_camping, orgId, storeId);
|
45
46
|
this.order_graphQL = new orderGraphQL_1.OrderGraphQLService(endpoints.order_graphQL, orgId, storeId);
|
47
|
+
this.paymentLV = new paymentLV_1.PaymentLVService(endpoints.paymentLV, orgId, storeId);
|
46
48
|
// Initialize other services here
|
47
49
|
}
|
48
50
|
setToken(token) {
|
@@ -61,6 +63,7 @@ class SDK {
|
|
61
63
|
this.dns.setToken(token);
|
62
64
|
this.crm_camping.setToken(token);
|
63
65
|
this.order_graphQL.setToken(token);
|
66
|
+
this.paymentLV.setToken(token);
|
64
67
|
// Set token for other services here
|
65
68
|
}
|
66
69
|
// các module export từ serviceSDK.ts set storeId vào serviceSDK.ts
|
@@ -260,5 +260,21 @@ class CloudService extends serviceSDK_1.Service {
|
|
260
260
|
}
|
261
261
|
});
|
262
262
|
}
|
263
|
+
getIpsOfService(serviceId) {
|
264
|
+
return __awaiter(this, void 0, void 0, function* () {
|
265
|
+
const query = queries_1.GET_IPS_OF_SERVICE;
|
266
|
+
const variables = {
|
267
|
+
serviceId,
|
268
|
+
};
|
269
|
+
try {
|
270
|
+
const response = yield this.graphqlQueryV2(query, variables);
|
271
|
+
return response.getIpsOfService;
|
272
|
+
}
|
273
|
+
catch (error) {
|
274
|
+
console.log(`Error in getIpsOfService: ${error}`);
|
275
|
+
throw error;
|
276
|
+
}
|
277
|
+
});
|
278
|
+
}
|
263
279
|
}
|
264
280
|
exports.CloudService = CloudService;
|
@@ -0,0 +1,40 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.PaymentLVService = void 0;
|
13
|
+
const queries_1 = require("../../graphql/paymentLV/queries");
|
14
|
+
const serviceSDK_1 = require("../serviceSDK");
|
15
|
+
class PaymentLVService extends serviceSDK_1.Service {
|
16
|
+
constructor(endpoint, orgId, storeId) {
|
17
|
+
super(endpoint, orgId, storeId);
|
18
|
+
}
|
19
|
+
setToken(token) {
|
20
|
+
this.token = token;
|
21
|
+
}
|
22
|
+
paymentsByOrders(orderIds) {
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
24
|
+
const query = queries_1.PAYMENTS_BY_ORDERS;
|
25
|
+
const variables = {
|
26
|
+
orderIds,
|
27
|
+
};
|
28
|
+
// const headers = { PartnerId: this.orgId };
|
29
|
+
try {
|
30
|
+
const response = yield this.graphqlQueryCustomHeader(query, variables);
|
31
|
+
return response.paymentsByOrders;
|
32
|
+
}
|
33
|
+
catch (error) {
|
34
|
+
console.log(`Error in paymentsByOrders: ${error}`);
|
35
|
+
throw error;
|
36
|
+
}
|
37
|
+
});
|
38
|
+
}
|
39
|
+
}
|
40
|
+
exports.PaymentLVService = PaymentLVService;
|
@@ -15,4 +15,5 @@ export declare class Service {
|
|
15
15
|
protected restApiCallWithNoToken(path: string, method: "GET" | "POST" | "PUT" | "DELETE", data?: any, headers?: any): Promise<any>;
|
16
16
|
protected graphqlQueryV2(query: DocumentNode, variables: any): Promise<any>;
|
17
17
|
protected graphqlMutationV2(mutation: DocumentNode, variables: any): Promise<any>;
|
18
|
+
protected graphqlQueryCustomHeader(query: DocumentNode, variables: any, additionalHeaders?: Record<string, string>): Promise<any>;
|
18
19
|
}
|
@@ -96,7 +96,7 @@ class Service {
|
|
96
96
|
restApiCallWithToken(path, method, data, headers) {
|
97
97
|
return __awaiter(this, void 0, void 0, function* () {
|
98
98
|
try {
|
99
|
-
const modifiedHeaders = Object.assign(
|
99
|
+
const modifiedHeaders = Object.assign({}, headers);
|
100
100
|
const response = yield (0, axios_1.default)({
|
101
101
|
url: this.endpoint + path,
|
102
102
|
method,
|
@@ -183,5 +183,30 @@ class Service {
|
|
183
183
|
}
|
184
184
|
});
|
185
185
|
}
|
186
|
+
graphqlQueryCustomHeader(query_1, variables_1) {
|
187
|
+
return __awaiter(this, arguments, void 0, function* (query, variables, additionalHeaders = {}) {
|
188
|
+
try {
|
189
|
+
const headers = Object.assign({ "Content-Type": "application/json" }, additionalHeaders);
|
190
|
+
const { data, errors } = yield this.client.query({
|
191
|
+
query: (0, client_1.gql) `
|
192
|
+
${query}
|
193
|
+
`,
|
194
|
+
variables,
|
195
|
+
context: {
|
196
|
+
method: "POST",
|
197
|
+
headers
|
198
|
+
},
|
199
|
+
});
|
200
|
+
if (errors) {
|
201
|
+
throw new Error(`GraphQL error! errors: ${errors}`);
|
202
|
+
}
|
203
|
+
return data;
|
204
|
+
}
|
205
|
+
catch (error) {
|
206
|
+
console.log(`Error in graphqlQuery: ${error}`);
|
207
|
+
throw error.message;
|
208
|
+
}
|
209
|
+
});
|
210
|
+
}
|
186
211
|
}
|
187
212
|
exports.Service = Service;
|