@longvansoftware/service-js-client 1.0.3 → 1.0.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.
@@ -9,3 +9,5 @@ export declare const GET_BRANDS_BY_CATEGORY_QUERY = "\nquery GetBrandsByCategory
9
9
  export declare const GET_BRAND_DETAIL_QUERY = "\n query GetBrandDetail($partnerId: String!, $brandId: String!, $storeChannel: String!) {\n getDetail(partnerId: $partnerId, brandId: $brandId, storeChannel: $storeChannel) {\n id\n name\n image\n imageIcon\n }\n }\n";
10
10
  export declare const GET_PRODUCT_OPTION: import("graphql").DocumentNode;
11
11
  export declare const GET_POLICY: import("graphql").DocumentNode;
12
+ export declare const GET_PRODUCTS: import("graphql").DocumentNode;
13
+ export declare const GET_HANDLE_BY_SERVICETYPE: import("graphql").DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GET_POLICY = exports.GET_PRODUCT_OPTION = exports.GET_BRAND_DETAIL_QUERY = exports.GET_BRANDS_BY_CATEGORY_QUERY = exports.GET_BRANDS_QUERY = exports.GET_CATEGORY_BY_ID_QUERY = exports.GET_CATEGORY_BY_HANDLE_QUERY = exports.GET_CATEGORIES_QUERY = exports.GET_SIMPLE_PRODUCTS_QUERY = exports.GET_PRODUCT_BY_SLUG_QUERY = exports.GET_PRODUCT_BY_ID_QUERY = void 0;
3
+ exports.GET_HANDLE_BY_SERVICETYPE = exports.GET_PRODUCTS = exports.GET_POLICY = exports.GET_PRODUCT_OPTION = exports.GET_BRAND_DETAIL_QUERY = exports.GET_BRANDS_BY_CATEGORY_QUERY = exports.GET_BRANDS_QUERY = exports.GET_CATEGORY_BY_ID_QUERY = exports.GET_CATEGORY_BY_HANDLE_QUERY = exports.GET_CATEGORIES_QUERY = exports.GET_SIMPLE_PRODUCTS_QUERY = exports.GET_PRODUCT_BY_SLUG_QUERY = exports.GET_PRODUCT_BY_ID_QUERY = void 0;
4
4
  const graphql_tag_1 = require("graphql-tag");
5
5
  // export const GET_PRODUCT_BY_ID_QUERY = gql`
6
6
  // query GetProductById(
@@ -429,3 +429,146 @@ exports.GET_POLICY = (0, graphql_tag_1.gql) `
429
429
  }
430
430
  }
431
431
  `;
432
+ exports.GET_PRODUCTS = (0, graphql_tag_1.gql) `
433
+ query GetProducts(
434
+ $partnerId: String!
435
+ $storeChannel: String!
436
+ $hash: String
437
+ $publicOnStore: Boolean
438
+ $category: String
439
+ $product: String
440
+ $group: String
441
+ $sku: String
442
+ $priceFrom: BigDecimal
443
+ $priceTo: BigDecimal
444
+ $tag: String
445
+ $status: String
446
+ $ecommerceId: String
447
+ $productIgnoresIds: String
448
+ $toDate: Long
449
+ $fromDate: Long
450
+ $productType: String
451
+ $sortOrder: String
452
+ $sortBy: String
453
+ $option: String
454
+ $brandId: String
455
+ $feature: String
456
+ $keyword: String
457
+ $external: String
458
+ $userId: String
459
+ $onlyFavorite: Boolean
460
+ $buildPriceStore: Boolean
461
+ $buildType: String
462
+ $buildPromotion: Boolean
463
+ $variant: Boolean
464
+ $deleteChild: Boolean
465
+ $display: String
466
+ $currentPage: Int
467
+ $maxResult: Int
468
+ $isSync: Boolean
469
+ $isMapped: Boolean
470
+ ) {
471
+ getProducts(
472
+ partnerId: $partnerId
473
+ storeChannel: $storeChannel
474
+ hash: $hash
475
+ publicOnStore: $publicOnStore
476
+ category: $category
477
+ product: $product
478
+ group: $group
479
+ sku: $sku
480
+ priceFrom: $priceFrom
481
+ priceTo: $priceTo
482
+ tag: $tag
483
+ status: $status
484
+ ecommerceId: $ecommerceId
485
+ productIgnoresIds: $productIgnoresIds
486
+ toDate: $toDate
487
+ fromDate: $fromDate
488
+ productType: $productType
489
+ sortOrder: $sortOrder
490
+ sortBy: $sortBy
491
+ option: $option
492
+ brandId: $brandId
493
+ feature: $feature
494
+ keyword: $keyword
495
+ external: $external
496
+ userId: $userId
497
+ onlyFavorite: $onlyFavorite
498
+ buildPriceStore: $buildPriceStore
499
+ buildType: $buildType
500
+ buildPromotion: $buildPromotion
501
+ variant: $variant
502
+ deleteChild: $deleteChild
503
+ display: $display
504
+ currentPage: $currentPage
505
+ maxResult: $maxResult
506
+ isSync: $isSync
507
+ isMapped: $isMapped
508
+ ) {
509
+ total
510
+ currentPage
511
+ maxResult
512
+ totalPage
513
+ data {
514
+ id
515
+ title
516
+ description
517
+ sku
518
+ shortDescription
519
+ weight
520
+ width
521
+ depth
522
+ height
523
+ vat
524
+ unitDTO {
525
+ id
526
+ name
527
+ }
528
+ productAttributes {
529
+ attributeName
530
+ attributeValue
531
+ }
532
+ qualify
533
+ parentId
534
+ handle
535
+ price
536
+ priceType
537
+ salePolicy
538
+ priceTypeName
539
+ priceVaries
540
+ available
541
+ tags
542
+ options
543
+ optionsRelationship
544
+ compareAtPrice
545
+ featuredImage
546
+ images
547
+ variants {
548
+ id
549
+ handle
550
+ title
551
+ price
552
+ compareAtPrice
553
+ options
554
+ optionsIds
555
+ featuredImage
556
+ sku
557
+ }
558
+ }
559
+ }
560
+ }
561
+ `;
562
+ exports.GET_HANDLE_BY_SERVICETYPE = (0, graphql_tag_1.gql) `
563
+ query GetHandleByServiceTypes(
564
+ $partnerId: String!
565
+ $storeChannel: String!
566
+ $serviceTypes: [String]!
567
+ ) {
568
+ getHandleByServiceTypes(
569
+ partnerId: $partnerId
570
+ storeChannel: $storeChannel
571
+ serviceTypes: $serviceTypes
572
+ )
573
+ }
574
+ `;
@@ -1,5 +1,5 @@
1
1
  import { Service } from "../serviceSDK";
2
- import { Product } from "../../types/product";
2
+ import { Product, getProduct } from "../../types/product";
3
3
  /**
4
4
  * Service class for managing product-related operations.
5
5
  */
@@ -34,4 +34,6 @@ export declare class ProductService extends Service {
34
34
  getSimpleProducts(variables: any): Promise<Product[] | null>;
35
35
  getProductOption(productId: string): Promise<any>;
36
36
  getPolicy(groupId: string): Promise<any>;
37
+ getProducts(param: getProduct): Promise<any>;
38
+ getHandleByServiceTypes(serviceTypes: [string]): Promise<any>;
37
39
  }
@@ -116,7 +116,7 @@ class ProductService extends serviceSDK_1.Service {
116
116
  return __awaiter(this, void 0, void 0, function* () {
117
117
  const query = queries_1.GET_POLICY;
118
118
  const variablesHandle = {
119
- groupId
119
+ groupId,
120
120
  };
121
121
  try {
122
122
  const response = yield this.graphqlQuery(query, variablesHandle);
@@ -128,5 +128,37 @@ class ProductService extends serviceSDK_1.Service {
128
128
  }
129
129
  });
130
130
  }
131
+ getProducts(param) {
132
+ return __awaiter(this, void 0, void 0, function* () {
133
+ const query = queries_1.GET_PRODUCTS;
134
+ const variablesHandle = Object.assign({ partnerId: this.orgId, storeChannel: this.storeId }, param);
135
+ try {
136
+ const response = yield this.graphqlQuery(query, variablesHandle);
137
+ return response.getProducts;
138
+ }
139
+ catch (error) {
140
+ console.log(`Error fetching getProducts : ${error}`);
141
+ throw error;
142
+ }
143
+ });
144
+ }
145
+ getHandleByServiceTypes(serviceTypes) {
146
+ return __awaiter(this, void 0, void 0, function* () {
147
+ const query = queries_1.GET_HANDLE_BY_SERVICETYPE;
148
+ const variablesHandle = {
149
+ partnerId: this.orgId,
150
+ storeChannel: this.storeId,
151
+ serviceTypes,
152
+ };
153
+ try {
154
+ const response = yield this.graphqlQuery(query, variablesHandle);
155
+ return response.getHandleByServiceTypes;
156
+ }
157
+ catch (error) {
158
+ console.log(`Error fetching getHandleByServiceTypes : ${error}`);
159
+ throw error;
160
+ }
161
+ });
162
+ }
131
163
  }
132
164
  exports.ProductService = ProductService;
@@ -63,7 +63,7 @@ class Service {
63
63
  }
64
64
  catch (error) {
65
65
  console.log(`Error in graphqlQuery: ${error}`);
66
- throw error;
66
+ throw error.message;
67
67
  }
68
68
  });
69
69
  }
@@ -89,14 +89,14 @@ class Service {
89
89
  return data;
90
90
  }
91
91
  catch (error) {
92
- throw error;
92
+ throw error.message;
93
93
  }
94
94
  });
95
95
  }
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(Object.assign({}, headers), { PartnerId: this.orgId, Authorization: "Bearer " + this.token });
100
100
  const response = yield (0, axios_1.default)({
101
101
  url: this.endpoint + path,
102
102
  method,
@@ -106,7 +106,7 @@ class Service {
106
106
  return response.data;
107
107
  }
108
108
  catch (error) {
109
- throw error;
109
+ throw error.message;
110
110
  }
111
111
  });
112
112
  }
@@ -124,7 +124,7 @@ class Service {
124
124
  }
125
125
  catch (error) {
126
126
  console.log(`Error in restApiCallWithNoToken: ${error}`);
127
- throw error;
127
+ throw error.message;
128
128
  }
129
129
  });
130
130
  }
@@ -140,8 +140,8 @@ class Service {
140
140
  method: "POST",
141
141
  headers: {
142
142
  "Content-Type": "application/json",
143
- "PartnerId": this.orgId,
144
- "Authorization": 'Bearer ' + this.token,
143
+ PartnerId: this.orgId,
144
+ Authorization: "Bearer " + this.token,
145
145
  },
146
146
  },
147
147
  });
@@ -152,7 +152,7 @@ class Service {
152
152
  }
153
153
  catch (error) {
154
154
  console.log(`Error in graphqlQuery: ${error}`);
155
- throw error;
155
+ throw error.message;
156
156
  }
157
157
  });
158
158
  }
@@ -168,8 +168,8 @@ class Service {
168
168
  method: "POST",
169
169
  headers: {
170
170
  "Content-Type": "application/json",
171
- "PartnerId": this.orgId,
172
- "Authorization": 'Bearer ' + this.token,
171
+ PartnerId: this.orgId,
172
+ Authorization: "Bearer " + this.token,
173
173
  },
174
174
  },
175
175
  });
@@ -179,7 +179,7 @@ class Service {
179
179
  return data;
180
180
  }
181
181
  catch (error) {
182
- throw error;
182
+ throw error.message;
183
183
  }
184
184
  });
185
185
  }
@@ -61,3 +61,40 @@ export interface Brand {
61
61
  image: string;
62
62
  imageIcon: string;
63
63
  }
64
+ export interface getProduct {
65
+ hash: string;
66
+ publicOnStore: Boolean;
67
+ category: string;
68
+ product: string;
69
+ group: string;
70
+ sku: string;
71
+ priceFrom: any;
72
+ priceTo: any;
73
+ tag: string;
74
+ status: string;
75
+ ecommerceId: string;
76
+ productIgnoresIds: string;
77
+ toDate: Date;
78
+ fromDate: Date;
79
+ productType: string;
80
+ sortOrder: string;
81
+ sortBy: string;
82
+ option: string;
83
+ brandId: string;
84
+ feature: string;
85
+ keyword: string;
86
+ external: string;
87
+ userId: string;
88
+ onlyFavorite: Boolean;
89
+ buildPriceStore: Boolean;
90
+ buildType: string;
91
+ buildPromotion: Boolean;
92
+ variant: Boolean;
93
+ deleteChild: Boolean;
94
+ display: string;
95
+ subType: string;
96
+ currentPage: number;
97
+ maxResult: number;
98
+ isSync: Boolean;
99
+ isMapped: Boolean;
100
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longvansoftware/service-js-client",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "files": [