@longvansoftware/service-js-client 2.8.8 → 2.8.9

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.
@@ -25,6 +25,7 @@ export declare const environmentEndpoints: {
25
25
  marketplace: string;
26
26
  storefront: string;
27
27
  dynamic_collection: string;
28
+ cashbook: string;
28
29
  };
29
30
  live: {
30
31
  product: string;
@@ -52,5 +53,6 @@ export declare const environmentEndpoints: {
52
53
  marketplace: string;
53
54
  storefront: string;
54
55
  dynamic_collection: string;
56
+ cashbook: string;
55
57
  };
56
58
  };
@@ -28,7 +28,8 @@ exports.environmentEndpoints = {
28
28
  content_api: "https://api-gateway.longvan.dev/content-api/graphql",
29
29
  marketplace: "https://api-gateway.longvan.dev/marketplace/graphql",
30
30
  storefront: "https://api-gateway.longvan.dev/storefront-service/graphql",
31
- dynamic_collection: "https://api-gateway.longvan.dev/dynamic-collection"
31
+ dynamic_collection: "https://api-gateway.longvan.dev/dynamic-collection",
32
+ cashbook: "https://api-gateway.longvan.dev/cashbook-service/graphql"
32
33
  },
33
34
  live: {
34
35
  product: "https://product-service.longvan.vn/product-service/graphql",
@@ -56,6 +57,7 @@ exports.environmentEndpoints = {
56
57
  content_api: "https://portal.longvan.vn/content-api/graphql",
57
58
  marketplace: "https://api-gateway.longvan.vn/marketplace/graphql",
58
59
  storefront: "https://api-gateway.longvan.vn/storefront-service/graphql",
59
- dynamic_collection: "https://portal.longvan.vn/dynamic-collection"
60
+ dynamic_collection: "https://portal.longvan.vn/dynamic-collection",
61
+ cashbook: "https://api-gateway.longvan.dev/cashbook-service/graphql"
60
62
  }
61
63
  };
@@ -0,0 +1,5 @@
1
+ import { DocumentNode } from "graphql";
2
+ export declare const CREATE_CASH_ACCOUNT_CUSTOMER: (fields?: string[]) => DocumentNode;
3
+ export declare const UPDATE_CASH_ACCOUNT_CUSTOMER: (fields?: string[]) => DocumentNode;
4
+ export declare const DELETE_CASH_ACCOUNT_CUSTOMER: (fields?: string[]) => DocumentNode;
5
+ export declare const CONFIRM_DELETE_CASH_ACCOUNT_CUSTOMER: (fields?: string[]) => DocumentNode;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CONFIRM_DELETE_CASH_ACCOUNT_CUSTOMER = exports.DELETE_CASH_ACCOUNT_CUSTOMER = exports.UPDATE_CASH_ACCOUNT_CUSTOMER = exports.CREATE_CASH_ACCOUNT_CUSTOMER = void 0;
7
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
+ const helpers_1 = require("../../utils/helpers");
9
+ const CREATE_CASH_ACCOUNT_CUSTOMER = (fields = []) => {
10
+ return (0, graphql_tag_1.default) `
11
+ mutation CreateCashAccountCustomer(
12
+ $partnerId: String!
13
+ $bankCode: String!
14
+ $name: String!
15
+ $accountNumber: String!
16
+ $typeCard: CardType!
17
+ $partyId: String!
18
+ ) {
19
+ createCashAccountCustomer(
20
+ input: {
21
+ partnerId: $partnerId
22
+ bankCode: $bankCode
23
+ name: $name
24
+ accountNumber: $accountNumber
25
+ typeCard: $typeCard
26
+ partyId: $partyId
27
+ }
28
+ ) ${(0, helpers_1.hasFields)(fields) ? `{ ${(0, helpers_1.joinField)(fields)} }` : ""}
29
+ }
30
+ `;
31
+ };
32
+ exports.CREATE_CASH_ACCOUNT_CUSTOMER = CREATE_CASH_ACCOUNT_CUSTOMER;
33
+ const UPDATE_CASH_ACCOUNT_CUSTOMER = (fields = []) => {
34
+ return (0, graphql_tag_1.default) `
35
+ mutation UpdateCashAccountCustomer(
36
+ $id: ID!
37
+ $partnerId: String!
38
+ $bankCode: String
39
+ $name: String
40
+ $accountNumber: String
41
+ $typeCard: CardType
42
+ $isDefault: Boolean
43
+ $partyId: String!
44
+ ) {
45
+ updateCashAccountCustomer(
46
+ input: {
47
+ id: $id
48
+ partnerId: $partnerId
49
+ bankCode: $bankCode
50
+ name: $name
51
+ accountNumber: $accountNumber
52
+ typeCard: $typeCard
53
+ isDefault: $isDefault
54
+ partyId: $partyId
55
+ }
56
+ ) ${(0, helpers_1.hasFields)(fields) ? `{ ${(0, helpers_1.joinField)(fields)} }` : ""}
57
+ }
58
+ `;
59
+ };
60
+ exports.UPDATE_CASH_ACCOUNT_CUSTOMER = UPDATE_CASH_ACCOUNT_CUSTOMER;
61
+ const DELETE_CASH_ACCOUNT_CUSTOMER = (fields = []) => {
62
+ return (0, graphql_tag_1.default) `
63
+ mutation DeleteCashAccountCustomer(
64
+ $id: ID!
65
+ $partnerId: String!
66
+ $partyId: String!
67
+ ) {
68
+ deleteCashAccountCustomer(
69
+ id: $id
70
+ partnerId: $partnerId
71
+ partyId: $partyId
72
+ ) ${(0, helpers_1.hasFields)(fields) ? `{ ${(0, helpers_1.joinField)(fields)} }` : ""}
73
+ }
74
+ `;
75
+ };
76
+ exports.DELETE_CASH_ACCOUNT_CUSTOMER = DELETE_CASH_ACCOUNT_CUSTOMER;
77
+ const CONFIRM_DELETE_CASH_ACCOUNT_CUSTOMER = (fields = []) => {
78
+ return (0, graphql_tag_1.default) `
79
+ mutation ConfirmDeleteCashAccountCustomer(
80
+ $id: ID!
81
+ $partnerId: String!
82
+ $partyId: String!
83
+ $otp: String!
84
+ ) {
85
+ confirmDeleteCashAccountCustomer(
86
+ id: $id
87
+ partnerId: $partnerId
88
+ partyId: $partyId
89
+ otp: $otp
90
+ ) ${(0, helpers_1.hasFields)(fields) ? `{ ${(0, helpers_1.joinField)(fields)} }` : ""}
91
+ }
92
+ `;
93
+ };
94
+ exports.CONFIRM_DELETE_CASH_ACCOUNT_CUSTOMER = CONFIRM_DELETE_CASH_ACCOUNT_CUSTOMER;
@@ -0,0 +1,3 @@
1
+ import { DocumentNode } from "graphql";
2
+ export declare const GET_CASH_ACCOUNT_CUSTOMERS: (fields?: string[]) => DocumentNode;
3
+ export declare const GET_BANK_CODES: (fields?: string[]) => DocumentNode;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GET_BANK_CODES = exports.GET_CASH_ACCOUNT_CUSTOMERS = void 0;
4
+ const graphql_tag_1 = require("graphql-tag");
5
+ const helpers_1 = require("../../utils/helpers");
6
+ const GET_CASH_ACCOUNT_CUSTOMERS = (fields = []) => {
7
+ return (0, graphql_tag_1.gql) `
8
+ query GetCashAccountCustomers(
9
+ $partnerId: String!
10
+ $partyId: String!
11
+ ) {
12
+ getCashAccountCustomers(
13
+ partnerId: $partnerId
14
+ partyId: $partyId
15
+ ) ${(0, helpers_1.hasFields)(fields) ? `{ ${(0, helpers_1.joinField)(fields)} }` : ""}
16
+ }
17
+ `;
18
+ };
19
+ exports.GET_CASH_ACCOUNT_CUSTOMERS = GET_CASH_ACCOUNT_CUSTOMERS;
20
+ const GET_BANK_CODES = (fields = []) => {
21
+ return (0, graphql_tag_1.gql) `
22
+ query GetBankCodes {
23
+ getBankCodes ${(0, helpers_1.hasFields)(fields) ? `{ ${(0, helpers_1.joinField)(fields)} }` : ""}
24
+ }
25
+ `;
26
+ };
27
+ exports.GET_BANK_CODES = GET_BANK_CODES;
@@ -23,6 +23,7 @@ import { ContentApiService } from "./content_api";
23
23
  import { MarketPlaceService } from "./marketplace";
24
24
  import { StorefrontService } from "./storefront";
25
25
  import { DynamicCollectionService } from "./dynamic_collection";
26
+ import { Cashbook } from "./cashbook";
26
27
  export interface Endpoints {
27
28
  product: string;
28
29
  crm: string;
@@ -49,6 +50,7 @@ export interface Endpoints {
49
50
  marketplace: string;
50
51
  storefront: string;
51
52
  dynamic_collection: string;
53
+ cashbook: string;
52
54
  }
53
55
  export declare class SDK {
54
56
  orgId: string;
@@ -80,6 +82,7 @@ export declare class SDK {
80
82
  storefront: StorefrontService;
81
83
  content_api: ContentApiService;
82
84
  dynamic_collection: DynamicCollectionService;
85
+ cashbook: Cashbook;
83
86
  token: string | null;
84
87
  private endpoints;
85
88
  constructor(orgId: string, storeId: string, storefrontAccessToken: string, environment: string);
@@ -29,6 +29,7 @@ const content_api_1 = require("./content_api");
29
29
  const marketplace_1 = require("./marketplace");
30
30
  const storefront_1 = require("./storefront");
31
31
  const dynamic_collection_1 = require("./dynamic_collection");
32
+ const cashbook_1 = require("./cashbook");
32
33
  class SDK {
33
34
  constructor(orgId, storeId, storefrontAccessToken, environment) {
34
35
  this.orgId = orgId;
@@ -66,6 +67,7 @@ class SDK {
66
67
  this.dynamic_collection = new dynamic_collection_1.DynamicCollectionService(this.endpoints.dynamic_collection, orgId, storeId);
67
68
  // Initialize other services here
68
69
  this.storefront = new storefront_1.StorefrontService(this.endpoints.storefront, orgId, storeId);
70
+ this.cashbook = new cashbook_1.Cashbook(this.endpoints.cashbook, orgId, storeId);
69
71
  }
70
72
  setToken(token) {
71
73
  this.token = token;
@@ -95,6 +97,7 @@ class SDK {
95
97
  this.marketplace.setToken(token);
96
98
  this.storefront.setToken(token);
97
99
  this.dynamic_collection.setToken(token);
100
+ this.cashbook.setToken(token);
98
101
  // Set token for other services here
99
102
  }
100
103
  // các module export từ serviceSDK.ts set storeId vào serviceSDK.ts
@@ -127,6 +130,7 @@ class SDK {
127
130
  this.marketplace = new marketplace_1.MarketPlaceService(this.endpoints.marketplace, this.orgId, storeId);
128
131
  this.storefront = new storefront_1.StorefrontService(this.endpoints.storefront, this.orgId, storeId);
129
132
  this.dynamic_collection = new dynamic_collection_1.DynamicCollectionService(this.endpoints.dynamic_collection, this.orgId, storeId);
133
+ this.cashbook = new cashbook_1.Cashbook(this.endpoints.cashbook, this.orgId, storeId);
130
134
  }
131
135
  }
132
136
  exports.SDK = SDK;
@@ -1,6 +1,26 @@
1
1
  import { Service } from "../serviceSDK";
2
- export declare class CashbookService extends Service {
2
+ export declare class Cashbook extends Service {
3
3
  constructor(endpoint: string, orgId: string, storeId: string);
4
- searchTransactions(keyword: string, dateFrom: number, dateTo: number, currentPage: number, pageSize: number): Promise<any>;
5
- getCashbookTransactionDetail(cashTransactionId: string): Promise<any>;
4
+ setToken(token: string): void;
5
+ setStoreId(storeId: string): void;
6
+ getCashAccountCustomers(partyId: string, fields?: string[]): Promise<any>;
7
+ getBankCodes(fields?: string[]): Promise<any>;
8
+ createCashAccountCustomer(input: {
9
+ bankCode: string;
10
+ name: string;
11
+ accountNumber: string;
12
+ typeCard: string;
13
+ partyId: string;
14
+ }, fields?: string[]): Promise<any>;
15
+ updateCashAccountCustomer(input: {
16
+ id: string;
17
+ partyId: string;
18
+ bankCode?: string;
19
+ name?: string;
20
+ accountNumber?: string;
21
+ typeCard?: string;
22
+ isDefault?: boolean;
23
+ }, fields?: string[]): Promise<any>;
24
+ deleteCashAccountCustomer(id: string, partyId: string, fields?: string[]): Promise<any>;
25
+ confirmDeleteCashAccountCustomer(id: string, partyId: string, otp: string, fields?: string[]): Promise<any>;
6
26
  }
@@ -9,48 +9,118 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.CashbookService = void 0;
12
+ exports.Cashbook = void 0;
13
+ const mutation_1 = require("../../graphql/cashbook/mutation");
14
+ const query_1 = require("../../graphql/cashbook/query");
13
15
  const serviceSDK_1 = require("../serviceSDK");
14
- const queries_1 = require("../../graphql/cashbook/queries");
15
- class CashbookService extends serviceSDK_1.Service {
16
+ class Cashbook extends serviceSDK_1.Service {
16
17
  constructor(endpoint, orgId, storeId) {
17
18
  super(endpoint, orgId, storeId);
18
19
  }
19
- searchTransactions(keyword, dateFrom, dateTo, currentPage, pageSize) {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- const query = queries_1.SEARCH_TRANSACTIONS;
20
+ setToken(token) {
21
+ this.token = token;
22
+ }
23
+ setStoreId(storeId) {
24
+ this.storeId = storeId;
25
+ }
26
+ getCashAccountCustomers(partyId_1) {
27
+ return __awaiter(this, arguments, void 0, function* (partyId, fields = ["id", "partnerId", "bankCode", "name", "accountNumber", "typeCard", "partyId", "isDefault", "customAttributes", "bankName"]) {
28
+ const query = (0, query_1.GET_CASH_ACCOUNT_CUSTOMERS)(fields);
29
+ const variables = { partnerId: this.orgId, partyId };
30
+ try {
31
+ const response = yield this.graphqlQuery(query, variables);
32
+ return response.getCashAccountCustomers;
33
+ }
34
+ catch (error) {
35
+ console.log(`Error getCashAccountCustomers: ${error}`);
36
+ throw error;
37
+ }
38
+ });
39
+ }
40
+ getBankCodes() {
41
+ return __awaiter(this, arguments, void 0, function* (fields = ["bankCode", "shortName", "description"]) {
42
+ const query = (0, query_1.GET_BANK_CODES)(fields);
43
+ try {
44
+ const response = yield this.graphqlQuery(query, {});
45
+ return response.getBankCodes;
46
+ }
47
+ catch (error) {
48
+ console.log(`Error getBankCodes: ${error}`);
49
+ throw error;
50
+ }
51
+ });
52
+ }
53
+ createCashAccountCustomer(input_1) {
54
+ return __awaiter(this, arguments, void 0, function* (input, fields = ["id", "partnerId", "bankCode", "name", "accountNumber", "typeCard", "partyId", "isDefault", "customAttributes"]) {
55
+ const mutation = (0, mutation_1.CREATE_CASH_ACCOUNT_CUSTOMER)(fields);
22
56
  const variables = {
23
57
  partnerId: this.orgId,
24
- keyword,
25
- dateFrom,
26
- dateTo,
27
- currentPage,
28
- pageSize,
58
+ partyId: input.partyId,
59
+ bankCode: input.bankCode,
60
+ name: input.name,
61
+ accountNumber: input.accountNumber,
62
+ typeCard: input.typeCard
29
63
  };
30
64
  try {
31
- const response = yield this.graphqlQueryV3(query, variables);
32
- return response.searchTransactions;
65
+ const response = yield this.graphqlMutationV2(mutation, variables);
66
+ return response.createCashAccountCustomer;
33
67
  }
34
68
  catch (error) {
69
+ console.log(`Error createCashAccountCustomer: ${error}`);
35
70
  throw error;
36
71
  }
37
72
  });
38
73
  }
39
- getCashbookTransactionDetail(cashTransactionId) {
40
- return __awaiter(this, void 0, void 0, function* () {
41
- const query = queries_1.GET_CASHBOOK_TRANSACTION_DETAIL;
74
+ updateCashAccountCustomer(input_1) {
75
+ return __awaiter(this, arguments, void 0, function* (input, fields = ["id", "partnerId", "bankCode", "name", "accountNumber", "typeCard", "partyId", "isDefault", "customAttributes"]) {
76
+ const mutation = (0, mutation_1.UPDATE_CASH_ACCOUNT_CUSTOMER)(fields);
42
77
  const variables = {
78
+ id: input.id,
43
79
  partnerId: this.orgId,
44
- cashTransactionId,
80
+ partyId: input.partyId,
81
+ bankCode: input.bankCode,
82
+ name: input.name,
83
+ accountNumber: input.accountNumber,
84
+ typeCard: input.typeCard,
85
+ isDefault: input.isDefault
45
86
  };
46
87
  try {
47
- const response = yield this.graphqlQueryV3(query, variables);
48
- return response.getCashbookTransactionDetail;
88
+ const response = yield this.graphqlMutationV2(mutation, variables);
89
+ return response.updateCashAccountCustomer;
90
+ }
91
+ catch (error) {
92
+ console.log(`Error updateCashAccountCustomer: ${error}`);
93
+ throw error;
94
+ }
95
+ });
96
+ }
97
+ deleteCashAccountCustomer(id_1, partyId_1) {
98
+ return __awaiter(this, arguments, void 0, function* (id, partyId, fields = ["message", "status", "otpRequired", "otpExpiresInSeconds", "otpMaxAttempts"]) {
99
+ const mutation = (0, mutation_1.DELETE_CASH_ACCOUNT_CUSTOMER)(fields);
100
+ const variables = { id, partnerId: this.orgId, partyId };
101
+ try {
102
+ const response = yield this.graphqlMutationV2(mutation, variables);
103
+ return response.deleteCashAccountCustomer;
104
+ }
105
+ catch (error) {
106
+ console.log(`Error deleteCashAccountCustomer: ${error}`);
107
+ throw error;
108
+ }
109
+ });
110
+ }
111
+ confirmDeleteCashAccountCustomer(id_1, partyId_1, otp_1) {
112
+ return __awaiter(this, arguments, void 0, function* (id, partyId, otp, fields = ["message", "status", "otpRequired", "otpExpiresInSeconds", "otpMaxAttempts"]) {
113
+ const mutation = (0, mutation_1.CONFIRM_DELETE_CASH_ACCOUNT_CUSTOMER)(fields);
114
+ const variables = { id, partnerId: this.orgId, partyId, otp };
115
+ try {
116
+ const response = yield this.graphqlMutationV2(mutation, variables);
117
+ return response.confirmDeleteCashAccountCustomer;
49
118
  }
50
119
  catch (error) {
120
+ console.log(`Error confirmDeleteCashAccountCustomer: ${error}`);
51
121
  throw error;
52
122
  }
53
123
  });
54
124
  }
55
125
  }
56
- exports.CashbookService = CashbookService;
126
+ exports.Cashbook = Cashbook;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longvansoftware/service-js-client",
3
- "version": "2.8.8",
3
+ "version": "2.8.9",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "files": [