@longvansoftware/service-js-client 1.1.8 → 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/orderGraphQL/queries.d.ts +1 -0
- package/dist/src/graphql/orderGraphQL/queries.js +77 -1
- package/dist/src/graphql/paymentLV/queries.d.ts +1 -0
- package/dist/src/graphql/paymentLV/queries.js +39 -0
- package/dist/src/graphql/product/queries.js +5 -1
- 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/orderGraphQL/index.d.ts +1 -0
- package/dist/src/lib/orderGraphQL/index.js +17 -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
|
+
`;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.GET_ORDER_DETAIL = void 0;
|
3
|
+
exports.GET_ORDER_LINE_ITEM_BY_SERVICE_ID = exports.GET_ORDER_DETAIL = void 0;
|
4
4
|
const graphql_tag_1 = require("graphql-tag");
|
5
5
|
exports.GET_ORDER_DETAIL = (0, graphql_tag_1.gql) `
|
6
6
|
query getOrderDetail($orderId: String!) {
|
@@ -59,3 +59,79 @@ exports.GET_ORDER_DETAIL = (0, graphql_tag_1.gql) `
|
|
59
59
|
}
|
60
60
|
}
|
61
61
|
`;
|
62
|
+
exports.GET_ORDER_LINE_ITEM_BY_SERVICE_ID = (0, graphql_tag_1.gql) `
|
63
|
+
query GetOrderLineItemByServiceId($partnerId: String!, $serviceId: String!) {
|
64
|
+
getOrderLineItemByServiceId(partnerId: $partnerId, serviceId: $serviceId) {
|
65
|
+
id
|
66
|
+
partnerId
|
67
|
+
currentQuantity
|
68
|
+
customAttributes {
|
69
|
+
key
|
70
|
+
value
|
71
|
+
}
|
72
|
+
discountedTotalPrice {
|
73
|
+
amount
|
74
|
+
currencyCode
|
75
|
+
}
|
76
|
+
originalTotalPrice {
|
77
|
+
amount
|
78
|
+
currencyCode
|
79
|
+
}
|
80
|
+
quantity
|
81
|
+
variant {
|
82
|
+
availableForSale
|
83
|
+
barcode
|
84
|
+
|
85
|
+
currentlyNotInStock
|
86
|
+
id
|
87
|
+
|
88
|
+
price {
|
89
|
+
amount
|
90
|
+
currencyCode
|
91
|
+
}
|
92
|
+
|
93
|
+
unitPrice {
|
94
|
+
amount
|
95
|
+
currencyCode
|
96
|
+
}
|
97
|
+
|
98
|
+
quantityAvailable
|
99
|
+
requiresShipping
|
100
|
+
sku
|
101
|
+
title
|
102
|
+
|
103
|
+
weight
|
104
|
+
weightUnit
|
105
|
+
}
|
106
|
+
orderId
|
107
|
+
orderItemId
|
108
|
+
fulfilledQuantity
|
109
|
+
fulfillingQuantity
|
110
|
+
orderItemName
|
111
|
+
note
|
112
|
+
createdStamp
|
113
|
+
updatedStamp
|
114
|
+
completedAt
|
115
|
+
orderLineItemParentId
|
116
|
+
orderStatus
|
117
|
+
totalVAT {
|
118
|
+
amount
|
119
|
+
currencyCode
|
120
|
+
}
|
121
|
+
vatRate {
|
122
|
+
amount
|
123
|
+
currencyCode
|
124
|
+
}
|
125
|
+
totalTax {
|
126
|
+
amount
|
127
|
+
currencyCode
|
128
|
+
}
|
129
|
+
unitType
|
130
|
+
productOptions {
|
131
|
+
idOption
|
132
|
+
name
|
133
|
+
value
|
134
|
+
}
|
135
|
+
}
|
136
|
+
}
|
137
|
+
`;
|
@@ -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
|
+
`;
|
@@ -105,6 +105,7 @@ exports.GET_PRODUCT_BY_ID_QUERY = (0, graphql_tag_1.gql) `
|
|
105
105
|
description
|
106
106
|
sku
|
107
107
|
shortDescription
|
108
|
+
subType
|
108
109
|
weight
|
109
110
|
width
|
110
111
|
depth
|
@@ -138,6 +139,7 @@ exports.GET_PRODUCT_BY_ID_QUERY = (0, graphql_tag_1.gql) `
|
|
138
139
|
handle
|
139
140
|
title
|
140
141
|
price
|
142
|
+
priceType
|
141
143
|
compareAtPrice
|
142
144
|
options
|
143
145
|
optionsIds
|
@@ -648,7 +650,8 @@ exports.GET_RESOURCE_BY_PRODUCT = (0, graphql_tag_1.gql) `
|
|
648
650
|
}
|
649
651
|
productId
|
650
652
|
productName
|
651
|
-
|
653
|
+
resourceName
|
654
|
+
resourceUnit
|
652
655
|
price
|
653
656
|
}
|
654
657
|
}
|
@@ -669,6 +672,7 @@ exports.GET_PRODUCT_VARIANT_BY_ID = (0, graphql_tag_1.gql) `
|
|
669
672
|
description
|
670
673
|
sku
|
671
674
|
shortDescription
|
675
|
+
subType
|
672
676
|
weight
|
673
677
|
width
|
674
678
|
depth
|
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;
|
@@ -66,5 +66,22 @@ class OrderGraphQLService extends serviceSDK_1.Service {
|
|
66
66
|
}
|
67
67
|
});
|
68
68
|
}
|
69
|
+
getOrderLineItemByServiceId(serviceId) {
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
71
|
+
const query = queries_1.GET_ORDER_LINE_ITEM_BY_SERVICE_ID;
|
72
|
+
const variables = {
|
73
|
+
partnerId: this.orgId,
|
74
|
+
serviceId,
|
75
|
+
};
|
76
|
+
try {
|
77
|
+
const response = yield this.graphqlQueryV2(query, variables);
|
78
|
+
return response.getOrderLineItemByServiceId;
|
79
|
+
}
|
80
|
+
catch (error) {
|
81
|
+
console.log(`Error in getOrderLineItemByServiceId: ${error}`);
|
82
|
+
throw error;
|
83
|
+
}
|
84
|
+
});
|
85
|
+
}
|
69
86
|
}
|
70
87
|
exports.OrderGraphQLService = OrderGraphQLService;
|
@@ -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;
|