@longvansoftware/storefront-js-client 1.0.11 → 1.0.13

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.
@@ -5,6 +5,7 @@ export declare const environmentEndpoints: {
5
5
  auth: string;
6
6
  order: string;
7
7
  user: string;
8
+ payment: string;
8
9
  };
9
10
  live: {
10
11
  product: string;
@@ -12,5 +13,6 @@ export declare const environmentEndpoints: {
12
13
  auth: string;
13
14
  order: string;
14
15
  user: string;
16
+ payment: string;
15
17
  };
16
18
  };
@@ -8,6 +8,7 @@ exports.environmentEndpoints = {
8
8
  auth: "https://crm.dev.longvan.vn/authorization-gateway/graphql",
9
9
  order: "https://storefront.dev.longvan.vn/v2",
10
10
  user: "https://user.dev.longvan.vn/user-gateway/graphql",
11
+ payment: "https://portal.dev.longvan.vn/invoice-gateway/graphql",
11
12
  },
12
13
  live: {
13
14
  product: "https://product-service.dev.longvan.vn/product-service/graphql",
@@ -15,5 +16,6 @@ exports.environmentEndpoints = {
15
16
  auth: "https://crm.dev.longvan.vn/authorization-gateway/graphql",
16
17
  order: "https://storefront.dev.longvan.vn/v2",
17
18
  user: "https://user.dev.longvan.vn/user-gateway/graphql",
19
+ payment: "https://portal.dev.longvan.vn/invoice-gateway/graphql",
18
20
  },
19
21
  };
@@ -0,0 +1 @@
1
+ export declare const CREATE_PAYMENT_ORDER_MUTATION: import("graphql").DocumentNode;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CREATE_PAYMENT_ORDER_MUTATION = void 0;
4
+ const graphql_tag_1 = require("graphql-tag");
5
+ exports.CREATE_PAYMENT_ORDER_MUTATION = (0, graphql_tag_1.gql) `
6
+ mutation CreatePaymentOrder(
7
+ $orgId: String!
8
+ $orderId: String!
9
+ $paymentMethod: String!
10
+ $storeId: String!
11
+ $source: String!
12
+ $appliedAmount: Float!
13
+ $payDate: String!
14
+ $returnUrl: String
15
+ $paymentType: String!
16
+ $createBy: String!
17
+ ) {
18
+ createPaymentOrder(
19
+ orgId: $orgId
20
+ orderId: $orderId
21
+ paymentMethod: $paymentMethod
22
+ storeId: $storeId
23
+ source: $source
24
+ appliedAmount: $appliedAmount
25
+ payDate: $payDate
26
+ returnUrl: $returnUrl
27
+ paymentType: $paymentType
28
+ createBy: $createBy
29
+ ) {
30
+ code
31
+ message
32
+ data
33
+ }
34
+ }
35
+ `;
@@ -0,0 +1 @@
1
+ export declare const GET_PAYMENT_METHOD: import("graphql").DocumentNode;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GET_PAYMENT_METHOD = void 0;
4
+ const graphql_tag_1 = require("graphql-tag");
5
+ exports.GET_PAYMENT_METHOD = (0, graphql_tag_1.gql) `
6
+ query GetPaymentMethod($orgId: String!, $storeChannelId: String) {
7
+ getPaymentMethod(orgId: $orgId, storeChannelId: $storeChannelId) {
8
+ code
9
+ name
10
+ }
11
+ }
12
+ `;
@@ -2,12 +2,15 @@ import { ProductService } from "../lib/product/index";
2
2
  import { AuthService } from "../lib/auth/index";
3
3
  import { OrderService } from "../lib/order/index";
4
4
  import { UserService } from "../lib/user/index";
5
+ import { PaymentService } from "../lib/payment/index";
6
+ import { CrmService } from "../lib/crm/index";
5
7
  export interface Endpoints {
6
8
  product: string;
7
9
  crm: string;
8
10
  auth: string;
9
11
  order: string;
10
12
  user: string;
13
+ payment: string;
11
14
  }
12
15
  export declare class SDK {
13
16
  orgId: string;
@@ -17,6 +20,8 @@ export declare class SDK {
17
20
  auth: AuthService;
18
21
  order: OrderService;
19
22
  user: UserService;
23
+ payment: PaymentService;
24
+ crm: CrmService;
20
25
  token: string | null;
21
26
  constructor(orgId: string, storeId: string, storefrontAccessToken: string);
22
27
  setToken(token: string): void;
@@ -8,6 +8,8 @@ const index_3 = require("../lib/order/index");
8
8
  const index_4 = require("../lib/user/index");
9
9
  const config_1 = require("../../config/config");
10
10
  const helpers_1 = require("../utils/helpers");
11
+ const index_5 = require("../lib/payment/index");
12
+ const index_6 = require("../lib/crm/index");
11
13
  class SDK {
12
14
  constructor(orgId, storeId, storefrontAccessToken) {
13
15
  this.orgId = orgId;
@@ -22,7 +24,8 @@ class SDK {
22
24
  this.auth = new index_2.AuthService(endpoints.auth, orgId, storeId);
23
25
  this.order = new index_3.OrderService(endpoints.order, orgId, storeId);
24
26
  this.user = new index_4.UserService(endpoints.user, orgId, storeId);
25
- // this.crm = new CrmService(endpoints.crm, orgId, storeId);
27
+ this.payment = new index_5.PaymentService(endpoints.payment, orgId, storeId);
28
+ this.crm = new index_6.CrmService(endpoints.crm, orgId, storeId);
26
29
  // Initialize other services here
27
30
  }
28
31
  setToken(token) {
@@ -31,7 +34,9 @@ class SDK {
31
34
  this.product.setToken(token);
32
35
  this.auth.setToken(token);
33
36
  this.order.setToken(token);
34
- // this.crm.setToken(token);
37
+ this.user.setToken(token);
38
+ this.payment.setToken(token);
39
+ this.crm.setToken(token);
35
40
  // Set token for other services here
36
41
  }
37
42
  }
@@ -1,6 +1,6 @@
1
1
  import { AddOpportunityRequest, GetOpportunityRequest } from '../../types/crm';
2
2
  import { Service } from '../service';
3
- export declare class UserService extends Service {
3
+ export declare class CrmService extends Service {
4
4
  constructor(endpoint: string, orgId: string, storeId: string);
5
5
  addOpportunity(addOpportunityRequest: AddOpportunityRequest, performerId: string): Promise<any>;
6
6
  getListOpportunity(performerId: string, getOpportunityRequest: GetOpportunityRequest): Promise<any>;
@@ -9,11 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.UserService = void 0;
12
+ exports.CrmService = void 0;
13
13
  const mutations_1 = require("../../graphql/crm/mutations");
14
14
  const queries_1 = require("../../graphql/crm/queries");
15
15
  const service_1 = require("../service");
16
- class UserService extends service_1.Service {
16
+ class CrmService extends service_1.Service {
17
17
  constructor(endpoint, orgId, storeId) {
18
18
  super(endpoint, orgId, storeId);
19
19
  }
@@ -182,4 +182,4 @@ class UserService extends service_1.Service {
182
182
  });
183
183
  }
184
184
  }
185
- exports.UserService = UserService;
185
+ exports.CrmService = CrmService;
@@ -20,6 +20,15 @@ export declare class OrderService extends Service {
20
20
  * @throws If an error occurs while creating the order.
21
21
  */
22
22
  createOrder(orderData: any, platform: string, createDraft: boolean): Promise<any>;
23
+ /**
24
+ * Creates a temporary order.
25
+ *
26
+ * @param orderData - The data for the order.
27
+ * @param platform - The platform for the order.
28
+ * @returns A promise that resolves to the response from the server.
29
+ * @throws If an error occurs during the API call.
30
+ */
31
+ createOrderTemp(orderData: any, platform: string): Promise<any>;
23
32
  /**
24
33
  * Completes multiple orders.
25
34
  * @param orderIds - The IDs of the orders to complete.
@@ -46,6 +46,28 @@ class OrderService extends service_1.Service {
46
46
  }
47
47
  });
48
48
  }
49
+ /**
50
+ * Creates a temporary order.
51
+ *
52
+ * @param orderData - The data for the order.
53
+ * @param platform - The platform for the order.
54
+ * @returns A promise that resolves to the response from the server.
55
+ * @throws If an error occurs during the API call.
56
+ */
57
+ createOrderTemp(orderData, platform) {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/${platform}/temp`; // Replace with your actual endpoint
60
+ const method = "POST";
61
+ try {
62
+ const response = yield this.restApiCallWithToken(endpoint, method, orderData);
63
+ return response;
64
+ }
65
+ catch (error) {
66
+ console.log(`Error in createOrder: ${error}`);
67
+ throw error;
68
+ }
69
+ });
70
+ }
49
71
  /**
50
72
  * Completes multiple orders.
51
73
  * @param orderIds - The IDs of the orders to complete.
@@ -0,0 +1,6 @@
1
+ import { Service } from "../service";
2
+ export declare class PaymentService extends Service {
3
+ constructor(endpoint: string, orgId: string, storeId: string);
4
+ getPaymentMethod(): Promise<any>;
5
+ createPaymentOrder(paymentOrderData: any): Promise<any>;
6
+ }
@@ -0,0 +1,50 @@
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.PaymentService = void 0;
13
+ const mutations_1 = require("../../graphql/payment/mutations");
14
+ const queries_1 = require("../../graphql/payment/queries");
15
+ const service_1 = require("../service");
16
+ class PaymentService extends service_1.Service {
17
+ constructor(endpoint, orgId, storeId) {
18
+ super(endpoint, orgId, storeId);
19
+ }
20
+ getPaymentMethod() {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ const query = queries_1.GET_PAYMENT_METHOD;
23
+ const variables = {
24
+ orgId: this.orgId,
25
+ };
26
+ try {
27
+ const response = yield this.graphqlQuery(query, variables);
28
+ return response.paymentMethod;
29
+ }
30
+ catch (error) {
31
+ console.log(`Error fetching get payment method: ${error}`);
32
+ throw error;
33
+ }
34
+ });
35
+ }
36
+ createPaymentOrder(paymentOrderData) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ const data = Object.assign({ orgId: this.orgId, storeId: this.storeId }, paymentOrderData);
39
+ try {
40
+ const response = yield this.graphqlMutation(mutations_1.CREATE_PAYMENT_ORDER_MUTATION, data);
41
+ return response.data.createPaymentOrder;
42
+ }
43
+ catch (error) {
44
+ console.log(`Error in createPaymentOrder: ${error}`);
45
+ throw error;
46
+ }
47
+ });
48
+ }
49
+ }
50
+ exports.PaymentService = PaymentService;
@@ -88,7 +88,7 @@ class Service {
88
88
  return response.data;
89
89
  }
90
90
  catch (error) {
91
- console.log(`Error in restApiCall: ${error}`);
91
+ console.log(`Error in restApiCallWithToken: ${error}`);
92
92
  throw error;
93
93
  }
94
94
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longvansoftware/storefront-js-client",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "files": [