1
- import { AndFilter , BrandAssortmentFilter , BrandDataFilter , BrandIdFilter , CartDataFilter , ContentCategoryAssortmentFilter , ContentCategoryDataFilter , ContentCategoryHasAncestorFilter , ContentCategoryHasChildFilter , ContentCategoryHasParentFilter , ContentCategoryIdFilter , ContentCategoryLevelFilter , ContentDataFilter , ContentIdFilter , Filter , FilterCollection , OrFilter , ProductAndVariantId , ProductAndVariantIdFilter , ProductAssortmentFilter , ProductCategoryAssortmentFilter , ProductCategoryDataFilter , ProductCategoryHasAncestorFilter , ProductCategoryHasChildFilter , ProductCategoryHasParentFilter , ProductCategoryIdFilter , ProductCategoryLevelFilter , ProductDataFilter , ProductDisplayNameFilter , ProductHasVariantsFilter , ProductIdFilter , ProductListPriceFilter , ProductRecentlyPurchasedByUserFilter , ProductRecentlyViewedByUserFilter , ProductSalesPriceFilter , VariantAssortmentFilter , VariantDataFilter , VariantIdFilter , VariantListPriceFilter , VariantSalesPriceFilter , VariantSpecificationFilter } from '../models/data-contracts' ;
1
+ import { AndFilter , BrandAssortmentFilter , BrandDataFilter , BrandIdFilter , CartDataFilter , CompanyDataFilter , CompanyIdFilter , ContentAssortmentFilter , ContentCategoryAssortmentFilter , ContentCategoryDataFilter , ContentCategoryHasAncestorFilter , ContentCategoryHasChildFilter , ContentCategoryHasContentsFilter , ContentCategoryHasParentFilter , ContentCategoryIdFilter , ContentCategoryLevelFilter , ContentDataFilter , ContentIdFilter , Filter , FilterCollection , OrFilter , ProductAndVariantId , ProductAndVariantIdFilter , ProductAssortmentFilter , ProductCategoryAssortmentFilter , ProductCategoryDataFilter , ProductCategoryHasAncestorFilter , ProductCategoryHasChildFilter , ProductCategoryHasParentFilter , ProductCategoryHasProductsFilter , ProductCategoryIdFilter , ProductCategoryLevelFilter , ProductDataFilter , ProductDisplayNameFilter , ProductHasVariantsFilter , ProductIdFilter , ProductListPriceFilter , ProductRecentlyPurchasedByUserFilter , ProductRecentlyViewedByUserFilter , ProductSalesPriceFilter , VariantAssortmentFilter , VariantDataFilter , VariantIdFilter , VariantListPriceFilter , VariantSalesPriceFilter , VariantSpecificationFilter } from '../models/data-contracts' ;
2
2
import { FilterSettingsBuilder } from './filterSettingsBuilder' ;
3
3
import { ConditionBuilder } from './conditionBuilder' ;
4
4
@@ -16,20 +16,30 @@ export class FilterBuilder {
16
16
| BrandDataFilter
17
17
| BrandIdFilter
18
18
| CartDataFilter
19
+ | CompanyDataFilter
20
+ | CompanyIdFilter
21
+ | ContentAssortmentFilter
19
22
| ContentCategoryAssortmentFilter
20
23
| ContentCategoryDataFilter
24
+ | ContentCategoryHasAncestorFilter
25
+ | ContentCategoryHasChildFilter
26
+ | ContentCategoryHasContentsFilter
27
+ | ContentCategoryHasParentFilter
21
28
| ContentCategoryIdFilter
29
+ | ContentCategoryLevelFilter
22
30
| ContentDataFilter
23
31
| ContentIdFilter
24
- | ContentCategoryLevelFilter
25
- | ContentCategoryHasParentFilter
26
- | ContentCategoryHasChildFilter
27
- | ContentCategoryHasAncestorFilter
28
32
| OrFilter
33
+ | ProductAndVariantIdFilter
29
34
| ProductAssortmentFilter
30
35
| ProductCategoryAssortmentFilter
31
36
| ProductCategoryDataFilter
37
+ | ProductCategoryHasAncestorFilter
38
+ | ProductCategoryHasChildFilter
39
+ | ProductCategoryHasParentFilter
40
+ | ProductCategoryHasProductsFilter
32
41
| ProductCategoryIdFilter
42
+ | ProductCategoryLevelFilter
33
43
| ProductDataFilter
34
44
| ProductDisplayNameFilter
35
45
| ProductHasVariantsFilter
@@ -43,12 +53,7 @@ export class FilterBuilder {
43
53
| VariantIdFilter
44
54
| VariantListPriceFilter
45
55
| VariantSalesPriceFilter
46
- | VariantSpecificationFilter
47
- | ProductAndVariantIdFilter
48
- | ProductCategoryLevelFilter
49
- | ProductCategoryHasParentFilter
50
- | ProductCategoryHasChildFilter
51
- | ProductCategoryHasAncestorFilter ) [ ] = [ ] ;
56
+ | VariantSpecificationFilter ) [ ] = [ ] ;
52
57
53
58
/**
54
59
* Adds a product assortment filter to the request
@@ -121,6 +126,30 @@ export class FilterBuilder {
121
126
122
127
return this ;
123
128
}
129
+
130
+ /**
131
+ * Adds a content assortment filter to the request
132
+ * @param assortmentIds
133
+ * @param negated
134
+ */
135
+ public addContentAssortmentFilter ( assortmentIds : number [ ] | number , negated : boolean = false , options ?: FilterOptions ) : this {
136
+ const assortments : number [ ] = Array . isArray ( assortmentIds )
137
+ ? assortmentIds
138
+ : [ assortmentIds ] ;
139
+
140
+ const internalSettingsBuilder = new FilterSettingsBuilder ( ) ;
141
+ options ?. filterSettings ?.( internalSettingsBuilder ) ;
142
+
143
+ const filter : ContentAssortmentFilter = {
144
+ $type : 'Relewise.Client.Requests.Filters.ContentAssortmentFilter, Relewise.Client' ,
145
+ assortments : assortments ,
146
+ negated : negated ,
147
+ settings : internalSettingsBuilder . build ( ) ,
148
+ } ;
149
+ this . filters . push ( filter ) ;
150
+
151
+ return this ;
152
+ }
124
153
125
154
/**
126
155
* Adds a content category assortment filter to the request
@@ -318,6 +347,30 @@ export class FilterBuilder {
318
347
return this ;
319
348
}
320
349
350
+ /**
351
+ * Filters the request to only return the specificied contents
352
+ * @param companyIds
353
+ * @param negated
354
+ */
355
+ public addCompanyIdFilter ( companyIds : string | string [ ] , negated : boolean = false , options ?: FilterOptions ) : this {
356
+ const ids : string [ ] = Array . isArray ( companyIds )
357
+ ? companyIds
358
+ : [ companyIds ] ;
359
+
360
+ const internalSettingsBuilder = new FilterSettingsBuilder ( ) ;
361
+ options ?. filterSettings ?.( internalSettingsBuilder ) ;
362
+
363
+ const filter : CompanyIdFilter = {
364
+ $type : 'Relewise.Client.Requests.Filters.CompanyIdFilter, Relewise.Client' ,
365
+ companyIds : ids ,
366
+ negated : negated ,
367
+ settings : internalSettingsBuilder . build ( ) ,
368
+ } ;
369
+ this . filters . push ( filter ) ;
370
+
371
+ return this ;
372
+ }
373
+
321
374
/**
322
375
* Adds a range filter to the request ensuring the product has a certain range of variants
323
376
* @param lowerBound
@@ -757,6 +810,36 @@ export class FilterBuilder {
757
810
return this ;
758
811
}
759
812
813
+ /**
814
+ * Adds a compnany data filter to the request
815
+ * @param key
816
+ * @param conditionBuilder
817
+ * @param mustMatchAllConditions
818
+ * @param filterOutIfKeyIsNotFound
819
+ * @param negated
820
+ */
821
+ public addCompanyDataFilter ( key : string , conditionBuilder : ( builder : ConditionBuilder ) => void , mustMatchAllConditions : boolean = true , filterOutIfKeyIsNotFound : boolean = true , negated : boolean = false , options ?: EntityDataFilterOptions ) : this {
822
+ const builder = new ConditionBuilder ( ) ;
823
+ conditionBuilder ( builder ) ;
824
+
825
+ const internalSettingsBuilder = new FilterSettingsBuilder ( ) ;
826
+ options ?. filterSettings ?.( internalSettingsBuilder ) ;
827
+
828
+ const filter : CompanyDataFilter = {
829
+ $type : 'Relewise.Client.Requests.Filters.CompanyDataFilter, Relewise.Client' ,
830
+ key : key ,
831
+ filterOutIfKeyIsNotFound : filterOutIfKeyIsNotFound ,
832
+ mustMatchAllConditions : mustMatchAllConditions ,
833
+ conditions : builder . build ( ) ,
834
+ negated : negated ,
835
+ objectPath : options ?. objectPath ,
836
+ settings : internalSettingsBuilder . build ( ) ,
837
+ } ;
838
+ this . filters . push ( filter ) ;
839
+
840
+ return this ;
841
+ }
842
+
760
843
/**
761
844
* Adds a product display name filter to the request
762
845
* @param key
@@ -964,6 +1047,46 @@ export class FilterBuilder {
964
1047
return this ;
965
1048
}
966
1049
1050
+ /**
1051
+ * Adds a product category has products filter to the request ensuring that only categories with products in them are returned
1052
+ * @param categoryIds
1053
+ * @param negated
1054
+ */
1055
+ public addProductCategoryHasProductsFilter ( negated : boolean = false , options ?: FilterOptions ) : this {
1056
+ const internalSettingsBuilder = new FilterSettingsBuilder ( ) ;
1057
+ options ?. filterSettings ?.( internalSettingsBuilder ) ;
1058
+
1059
+ const filter : ProductCategoryHasProductsFilter = {
1060
+ $type : 'Relewise.Client.Requests.Filters.ProductCategoryHasProductsFilter, Relewise.Client' ,
1061
+
1062
+ negated : negated ,
1063
+ settings : internalSettingsBuilder . build ( ) ,
1064
+ } ;
1065
+ this . filters . push ( filter ) ;
1066
+
1067
+ return this ;
1068
+ }
1069
+
1070
+ /**
1071
+ * Adds a content category has contents filter to the request ensuring that only categories with content in them are returned
1072
+ * @param categoryIds
1073
+ * @param negated
1074
+ */
1075
+ public addContentCategoryHasContentsFilter ( negated : boolean = false , options ?: FilterOptions ) : this {
1076
+ const internalSettingsBuilder = new FilterSettingsBuilder ( ) ;
1077
+ options ?. filterSettings ?.( internalSettingsBuilder ) ;
1078
+
1079
+ const filter : ContentCategoryHasContentsFilter = {
1080
+ $type : 'Relewise.Client.Requests.Filters.ContentCategoryHasContentsFilter, Relewise.Client' ,
1081
+
1082
+ negated : negated ,
1083
+ settings : internalSettingsBuilder . build ( ) ,
1084
+ } ;
1085
+ this . filters . push ( filter ) ;
1086
+
1087
+ return this ;
1088
+ }
1089
+
967
1090
public reset ( ) : this {
968
1091
this . filters = [ ] ;
969
1092
0 commit comments