Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add new Product and Content filters #65

Merged
merged 3 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 80 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,83 @@ 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 addProductRecentlyPurchasedByCompanyFilter(sinceMinutesAgo: number, companyIds: string | string[], negated: boolean = false, options?: FilterOptions): this {
this.productFilterBuilder.addProductRecentlyPurchasedByCompanyFilter(sinceMinutesAgo, companyIds, negated, options);
return this;
}

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

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

public addProductRecentlyViewedByCompanyFilter(sinceMinutesAgo: number, companyIds: string | string[], negated: boolean = false, options?: FilterOptions): this {
this.productFilterBuilder.addProductRecentlyViewedByCompanyFilter(sinceMinutesAgo, companyIds, negated, options);
return this;
}

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

public addProductRecentlyViewedByUserParentCompanyFilter(sinceMinutesAgo: number, negated: boolean = false, options?: FilterOptions): this {
this.productFilterBuilder.addProductRecentlyViewedByUserParentCompanyFilter(sinceMinutesAgo, 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
Loading