@longvansoftware/service-js-client 1.1.9 → 1.2.1

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.
@@ -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
  };
@@ -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 CANCEL_PAYMENT: import("graphql").DocumentNode;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CANCEL_PAYMENT = void 0;
4
+ const graphql_tag_1 = require("graphql-tag");
5
+ exports.CANCEL_PAYMENT = (0, graphql_tag_1.gql) `
6
+ mutation CancelPayment(
7
+ $paymentId: String!
8
+ $reason: String!
9
+ $createBy: String
10
+ ) {
11
+ cancelPayment(paymentId: $paymentId, reason: $reason, createBy: $createBy)
12
+ }
13
+ `;
@@ -0,0 +1,2 @@
1
+ export declare const PAYMENTS_BY_ORDERS: import("graphql").DocumentNode;
2
+ export declare const GET_TRANSFER_INFO: import("graphql").DocumentNode;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GET_TRANSFER_INFO = 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
+ `;
40
+ exports.GET_TRANSFER_INFO = (0, graphql_tag_1.gql) `
41
+ query GetTransferInfor($partnerId: String! $storeId: String!){
42
+ getTransferInfo(partnerId: $partnerId, storeId: $storeId) {
43
+ bankCode
44
+ bankName
45
+ accountNumber
46
+ accountName
47
+ description
48
+ }
49
+ }
50
+ `;
@@ -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;
@@ -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
@@ -23,4 +23,5 @@ export declare class CloudService extends Service {
23
23
  searchService(filter: Filter): Promise<any>;
24
24
  updateDNS(payload: {}): Promise<any>;
25
25
  getProductsOfService(serviceId: string): Promise<any>;
26
+ getIpsOfService(serviceId: string): Promise<any>;
26
27
  }
@@ -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,8 @@
1
+ import { Service } from "../serviceSDK";
2
+ export declare class PaymentLVService extends Service {
3
+ constructor(endpoint: string, orgId: string, storeId: string);
4
+ setToken(token: string): void;
5
+ paymentsByOrders(orderIds: [string]): Promise<any>;
6
+ getTransferInfo(): Promise<any>;
7
+ cancelPayment(paymentId: string, reason: string, createBy: string): Promise<any>;
8
+ }
@@ -0,0 +1,78 @@
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 mutations_1 = require("../../graphql/paymentLV/mutations");
14
+ const queries_1 = require("../../graphql/paymentLV/queries");
15
+ const serviceSDK_1 = require("../serviceSDK");
16
+ class PaymentLVService extends serviceSDK_1.Service {
17
+ constructor(endpoint, orgId, storeId) {
18
+ super(endpoint, orgId, storeId);
19
+ }
20
+ setToken(token) {
21
+ this.token = token;
22
+ }
23
+ paymentsByOrders(orderIds) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ const query = queries_1.PAYMENTS_BY_ORDERS;
26
+ const variables = {
27
+ orderIds,
28
+ };
29
+ // const headers = { PartnerId: this.orgId };
30
+ try {
31
+ const response = yield this.graphqlQueryCustomHeader(query, variables
32
+ // headers
33
+ );
34
+ return response.paymentsByOrders;
35
+ }
36
+ catch (error) {
37
+ console.log(`Error in paymentsByOrders: ${error}`);
38
+ throw error;
39
+ }
40
+ });
41
+ }
42
+ getTransferInfo() {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ const query = queries_1.GET_TRANSFER_INFO;
45
+ const variables = {
46
+ partnerId: this.orgId,
47
+ storeId: this.storeId,
48
+ };
49
+ try {
50
+ const response = yield this.graphqlQueryCustomHeader(query, variables);
51
+ return response.getTransferInfo;
52
+ }
53
+ catch (error) {
54
+ console.log(`Error fetching get getTransferInfo method: ${error}`);
55
+ throw error;
56
+ }
57
+ });
58
+ }
59
+ cancelPayment(paymentId, reason, createBy) {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ const mutation = mutations_1.CANCEL_PAYMENT;
62
+ const variables = {
63
+ paymentId,
64
+ reason,
65
+ createBy,
66
+ };
67
+ try {
68
+ const response = yield this.graphqlMutationCustomHeader(mutation, variables);
69
+ return response.cancelPayment;
70
+ }
71
+ catch (error) {
72
+ console.log(`Error fetching get cancelPayment method: ${error}`);
73
+ throw error;
74
+ }
75
+ });
76
+ }
77
+ }
78
+ exports.PaymentLVService = PaymentLVService;
@@ -15,4 +15,6 @@ 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>;
19
+ protected graphqlMutationCustomHeader(mutation: DocumentNode, variables: any, additionalHeaders?: Record<string, string>): Promise<any>;
18
20
  }
@@ -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(Object.assign({}, headers), { PartnerId: this.orgId, Authorization: "Bearer " + this.token });
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,55 @@ 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
+ }
211
+ graphqlMutationCustomHeader(mutation_1, variables_1) {
212
+ return __awaiter(this, arguments, void 0, function* (mutation, variables, additionalHeaders = {}) {
213
+ try {
214
+ const headers = Object.assign({ "Content-Type": "application/json" }, additionalHeaders);
215
+ const { data, errors } = yield this.client.mutate({
216
+ mutation: (0, client_1.gql) `
217
+ ${mutation}
218
+ `,
219
+ variables,
220
+ context: {
221
+ method: "POST",
222
+ headers,
223
+ },
224
+ });
225
+ if (errors) {
226
+ throw new Error(`GraphQL error! errors: ${errors}`);
227
+ }
228
+ return data;
229
+ }
230
+ catch (error) {
231
+ console.log(`Error in graphqlMutation: ${error}`);
232
+ throw error.message;
233
+ }
234
+ });
235
+ }
186
236
  }
187
237
  exports.Service = Service;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longvansoftware/service-js-client",
3
- "version": "1.1.9",
3
+ "version": "1.2.1",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "files": [