Skip to content

Commit

Permalink
feaet: add more filters
Browse files Browse the repository at this point in the history
  • Loading branch information
mzanoni committed Jun 28, 2024
1 parent aaa7d52 commit 1f168a2
Show file tree
Hide file tree
Showing 5 changed files with 208 additions and 35 deletions.
54 changes: 51 additions & 3 deletions packages/client/src/builders/filterBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ export class FilterBuilder {
}

/**
* Adds a brand is disabled filter to the request - only works for product queries, not in searches or recommendations
* Adds a brand is disabled filter to the request - only works for brand queries, not in searches or recommendations
* @param key
* @param negated
* @param options
Expand All @@ -559,7 +559,7 @@ export class FilterBuilder {
}

/**
* Adds a company is disabled filter to the request - only works for product queries, not in searches or recommendations
* Adds a company is disabled filter to the request - only works for company queries, not in searches or recommendations
* @param key
* @param negated
* @param options
Expand Down Expand Up @@ -603,7 +603,7 @@ export class FilterBuilder {
}

/**
* Adds a content category is disabled filter to the request - only works for product queries, not in searches or recommendations
* Adds a content category is disabled filter to the request - only works for content queries, not in searches or recommendations
* @param key
* @param negated
* @param options
Expand All @@ -618,6 +618,54 @@ export class FilterBuilder {
return this;
}

public addContentDataHasKeyFilter(key: string, negated: boolean = false, options?: FilterOptions): this {
this.contentFilterBuilder.addContentDataHasKeyFilter(key, negated, options);
return this;
}

/**
* Adds a content is disabled filter to the request - only works for content queries, not in searches or recommendations
* @param key
* @param negated
* @param options
*/
public addContentDisabledFilter(negated: boolean = false, options?: FilterOptions): this {
this.contentFilterBuilder.addContentDisabledFilter(negated, options);
return this;
}

public addContentRecentlyViewedByUserFilter(sinceMinutesAgo: number, negated: boolean = false, options?: FilterOptions): this {
this.contentFilterBuilder.addContentRecentlyViewedByUserFilter(sinceMinutesAgo, negated, options);
return this;
}

public addContentHasCategoriesFilter(negated: boolean = false, options?: FilterOptions): this {
this.contentFilterBuilder.addContentHasCategoriesFilter(negated, options);
return this;
}

/**
* Adds a product is disabled filter to the request - only works for product queries, not in searches or recommendations
* @param key
* @param negated
* @param options
*/
public addProductDisabledFilter(negated: boolean = false, options?: FilterOptions): this {
this.productFilterBuilder.addProductDisabledFilter(negated, options);
return this;
}

public addProductDataHasKeyFilter(key: string, negated: boolean = false, options?: FilterOptions): this {
this.productFilterBuilder.addProductDataHasKeyFilter(key, negated, options);
return this;
}


public addProductHasCategoriesFilter(negated: boolean = false, options?: FilterOptions): this {
this.productFilterBuilder.addProductHasCategoriesFilter(negated, options);
return this;
}

public reset(): this {
this.filters = [];
this.productFilterBuilder.reset();
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/builders/filters/brandFilterBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class BrandFilterBuilder extends FilterBuilderBase<BrandFilterBuilder> {
}

/**
* Adds a brand is disabled filter to the request - only works for product queries, not in searches or recommendations
* Adds a brand is disabled filter to the request - only works for brand queries, not in searches or recommendations
* @param key
* @param negated
* @param options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class CompanyFilterBuilder extends FilterBuilderBase<CompanyFilterBuilder
}

/**
* Adds a company is disabled filter to the request - only works for product queries, not in searches or recommendations
* Adds a company is disabled filter to the request - only works for company queries, not in searches or recommendations
* @param key
* @param negated
* @param options
Expand Down
74 changes: 72 additions & 2 deletions packages/client/src/builders/filters/contentFilterBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ContentAssortmentFilter, ContentCategoryAssortmentFilter, ContentCategoryHasAncestorFilter, ContentCategoryHasChildFilter, ContentCategoryHasContentsFilter, ContentCategoryHasParentFilter, ContentCategoryIdFilter, ContentCategoryLevelFilter, ContentCategoryDataFilter, ContentDataFilter, ContentIdFilter, ContentCategoryDataHasKeyFilter, ContentCategoryDisabledFilter, ContentCategoryRecentlyViewedByUserFilter } from 'src/models/data-contracts';
import { ContentAssortmentFilter, ContentCategoryAssortmentFilter, ContentCategoryHasAncestorFilter, ContentCategoryHasChildFilter, ContentCategoryHasContentsFilter, ContentCategoryHasParentFilter, ContentCategoryIdFilter, ContentCategoryLevelFilter, ContentCategoryDataFilter, ContentDataFilter, ContentIdFilter, ContentCategoryDataHasKeyFilter, ContentCategoryDisabledFilter, ContentCategoryRecentlyViewedByUserFilter, ContentDataHasKeyFilter, ContentDisabledFilter, ContentRecentlyViewedByUserFilter, ContentHasCategoriesFilter } from 'src/models/data-contracts';
import { ConditionBuilder } from '../conditionBuilder';
import { EntityDataFilterOptions, FilterOptions } from './filters.types.shared';
import { FilterSettingsBuilder } from '../filterSettingsBuilder';
Expand Down Expand Up @@ -286,7 +286,7 @@ export class ContentFilterBuilder extends FilterBuilderBase<ContentFilterBuilder
}

/**
* Adds a content category is disabled filter to the request - only works for product queries, not in searches or recommendations
* Adds a content category is disabled filter to the request - only works for content queries, not in searches or recommendations
* @param key
* @param negated
* @param options
Expand Down Expand Up @@ -319,4 +319,74 @@ export class ContentFilterBuilder extends FilterBuilderBase<ContentFilterBuilder

return this;
}

/**
* Adds a content has key filter to the request
* @param key
* @param negated
* @param options
*/
public addContentDataHasKeyFilter(key: string, negated: boolean = false, options?: FilterOptions): this {
const internalSettingsBuilder = new FilterSettingsBuilder();
options?.filterSettings?.(internalSettingsBuilder);

const filter: ContentDataHasKeyFilter = {
$type: 'Relewise.Client.Requests.Filters.ContentDataHasKeyFilter, Relewise.Client',
key: key,
negated: negated,
settings: internalSettingsBuilder.build(),
};
this.filters.push(filter);

return this;
}

/**
* Adds a content is disabled filter to the request - only works for content queries, not in searches or recommendations
* @param key
* @param negated
* @param options
*/
public addContentDisabledFilter(negated: boolean = false, options?: FilterOptions): this {
const internalSettingsBuilder = new FilterSettingsBuilder();
options?.filterSettings?.(internalSettingsBuilder);

const filter: ContentDisabledFilter = {
$type: 'Relewise.Client.Requests.Filters.ContentDisabledFilter, Relewise.Client',
negated: negated,
settings: internalSettingsBuilder.build(),
};
this.filters.push(filter);

return this;
}

public addContentRecentlyViewedByUserFilter(sinceMinutesAgo: number, negated: boolean = false, options?: FilterOptions): this {
const internalSettingsBuilder = new FilterSettingsBuilder();
options?.filterSettings?.(internalSettingsBuilder);

const filter: ContentRecentlyViewedByUserFilter = {
$type: 'Relewise.Client.Requests.Filters.ContentRecentlyViewedByUserFilter, Relewise.Client',
sinceMinutesAgo: sinceMinutesAgo,
negated: negated,
settings: internalSettingsBuilder.build(),
};
this.filters.push(filter);

return this;
}

public addContentHasCategoriesFilter(negated: boolean = false, options?: FilterOptions): this {
const internalSettingsBuilder = new FilterSettingsBuilder();
options?.filterSettings?.(internalSettingsBuilder);

const filter: ContentHasCategoriesFilter = {
$type: 'Relewise.Client.Requests.Filters.ContentHasCategoriesFilter, Relewise.Client',
negated: negated,
settings: internalSettingsBuilder.build(),
};
this.filters.push(filter);

return this;
}
}
Loading

0 comments on commit 1f168a2

Please sign in to comment.