@longvansoftware/service-js-client 2.5.2 → 2.5.4

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.
@@ -1,6 +1,7 @@
1
1
  import { DocumentNode } from "graphql";
2
2
  export declare const SEARCH_PRODUCT_QUANTITY_PROMOTION_ACTION: DocumentNode;
3
3
  export declare const GET_CAMPAIGN_ACTION_BY_ID: DocumentNode;
4
+ export declare const GET_PRODUCT_DISCOUNT_BUY_WITH_DYNAMIC: (fields?: string[]) => DocumentNode;
4
5
  export declare const SUGGEST_VOUCHER: DocumentNode;
5
6
  export declare const GET_VOUCHERS: DocumentNode;
6
7
  export declare const GET_AVERAGE_RATING: DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GET_VOUCHERS_FOR_USER = exports.GET_CONDITION_BY_ORGID_CAMPAIGN_ACTIONIDS = exports.SEARCH_CAMPAIGN = exports.GET_VOUCHERS_V2 = exports.SEARCH_PRODUCT_GIFT_PROMOTION_RESPONSE = exports.GET_NUMBER_OF_TICKET_EVALUATION = exports.GET_URL_EVALUATION = exports.GET_AVERAGE_RATING = exports.GET_VOUCHERS = exports.SUGGEST_VOUCHER = exports.GET_CAMPAIGN_ACTION_BY_ID = exports.SEARCH_PRODUCT_QUANTITY_PROMOTION_ACTION = void 0;
3
+ exports.GET_VOUCHERS_FOR_USER = exports.GET_CONDITION_BY_ORGID_CAMPAIGN_ACTIONIDS = exports.SEARCH_CAMPAIGN = exports.GET_VOUCHERS_V2 = exports.SEARCH_PRODUCT_GIFT_PROMOTION_RESPONSE = exports.GET_NUMBER_OF_TICKET_EVALUATION = exports.GET_URL_EVALUATION = exports.GET_AVERAGE_RATING = exports.GET_VOUCHERS = exports.SUGGEST_VOUCHER = exports.GET_PRODUCT_DISCOUNT_BUY_WITH_DYNAMIC = exports.GET_CAMPAIGN_ACTION_BY_ID = exports.SEARCH_PRODUCT_QUANTITY_PROMOTION_ACTION = void 0;
4
4
  const graphql_tag_1 = require("graphql-tag");
5
5
  exports.SEARCH_PRODUCT_QUANTITY_PROMOTION_ACTION = (0, graphql_tag_1.gql) `
6
6
  query SearchProductQuantityPromotionAction(
@@ -41,6 +41,26 @@ exports.GET_CAMPAIGN_ACTION_BY_ID = (0, graphql_tag_1.gql) `
41
41
  }
42
42
  }
43
43
  `;
44
+ const GET_PRODUCT_DISCOUNT_BUY_WITH_DYNAMIC = (fields = []) => {
45
+ const fieldStr = fields.join('\n ');
46
+ const hasFields = fields.length > 0;
47
+ return (0, graphql_tag_1.gql) `
48
+ query GetProductDiscountBuyWith(
49
+ $partnerId: String!
50
+ $storeId: String!
51
+ $productId: String!
52
+ ) {
53
+ getProductDiscountBuyWith(
54
+ partnerId: $partnerId
55
+ storeId: $storeId
56
+ productId: $productId
57
+ ) {
58
+ ${hasFields ? `${fieldStr}` : ''}
59
+ }
60
+ }
61
+ `;
62
+ };
63
+ exports.GET_PRODUCT_DISCOUNT_BUY_WITH_DYNAMIC = GET_PRODUCT_DISCOUNT_BUY_WITH_DYNAMIC;
44
64
  // export const SUGGEST_VOUCHER = gql`
45
65
  // query SuggestVoucher (
46
66
  // searchVoucherRequest: { partyId: String, customerId: String }
@@ -33,12 +33,12 @@ const UPDATE_CLIENT_GROUP_NAME_DYNAMIC = (fields = []) => {
33
33
  mutation UpdateClientGroupName(
34
34
  $groupId: String!
35
35
  $name: String!
36
- $createdBy: String!
36
+ $updatedBy: String!
37
37
  ) {
38
38
  updateClientGroupName(
39
39
  groupId: $groupId
40
40
  name: $name
41
- createdBy: $createdBy
41
+ updatedBy: $updatedBy
42
42
  )
43
43
  }
44
44
  `;
@@ -6,6 +6,7 @@ export declare class CrmCampingService extends Service {
6
6
  searchProductQuantityPromotionAction(productId: string): Promise<any>;
7
7
  addCustomerToVoucher(userId: string, voucherCode: string): Promise<any>;
8
8
  getCampaignActionById(campaignActionId: string): Promise<any>;
9
+ getProductDiscountBuyWithDynamic(productId: string, fields: string[]): Promise<any>;
9
10
  suggestVoucher(customerId: string, scopeIgnore: string | null, scope: string | null, isNewCustomer: boolean, voucherCode: string | null): Promise<any>;
10
11
  searchVouchers(campaignId: String, campaignActionId: String, campaignActionType: String, customerId: String, pageNumber: number, pageSize: number): Promise<any>;
11
12
  getAverageRating(targetIds: [string], customerId: string, evaluationType: string): Promise<any>;
@@ -73,22 +73,24 @@ class CrmCampingService extends serviceSDK_1.Service {
73
73
  }
74
74
  });
75
75
  }
76
- // async suggestVoucher(customerId: String){
77
- // const query = SUGGEST_VOUCHER;
78
- // const variables = {
79
- // partyId: this.orgId,
80
- // customerId
81
- // };
82
- // console.log("🚀 Query:", SUGGEST_VOUCHER);
83
- // console.log("🚀 Variables:", { partyId: this.orgId, customerId });
84
- // try {
85
- // const response = await this.graphqlQueryV2(query, variables);
86
- // return response.suggestVoucher;
87
- // } catch (error) {
88
- // console.log(`Error in suggestVoucher: ${error}`);
89
- // throw error;
90
- // }
91
- // }
76
+ getProductDiscountBuyWithDynamic(productId, fields) {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ const query = (0, queries_1.GET_PRODUCT_DISCOUNT_BUY_WITH_DYNAMIC)(fields);
79
+ const variables = {
80
+ partnerId: this.orgId,
81
+ storeId: this.storeId,
82
+ productId,
83
+ };
84
+ try {
85
+ const response = yield this.graphqlQueryV2(query, variables);
86
+ return response.getProductDiscountBuyWith;
87
+ }
88
+ catch (error) {
89
+ console.log(`Error in getProductDiscountBuyWithDynamic: ${error}`);
90
+ throw error;
91
+ }
92
+ });
93
+ }
92
94
  suggestVoucher(customerId, scopeIgnore, scope, isNewCustomer, voucherCode) {
93
95
  return __awaiter(this, void 0, void 0, function* () {
94
96
  const query = queries_1.SUGGEST_VOUCHER;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longvansoftware/service-js-client",
3
- "version": "2.5.2",
3
+ "version": "2.5.4",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "files": [