-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from Relewise/feat/product-search-constraints
Feat: implements product search constraints
- Loading branch information
Showing
5 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/client/src/builders/search/searchConstraintBuilder.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ProductSearchResultConstraint, ResultMustHaveVariantConstraint } from '../../models/data-contracts'; | ||
|
||
export class SearchConstraintBuilder { | ||
private resultConstraint: ProductSearchResultConstraint | null = null; | ||
|
||
public setResultMustHaveVariantConstraint(constaint: { exceptWhenProductHasNoVariants: boolean }): this { | ||
const constraint: ResultMustHaveVariantConstraint = { | ||
$type: 'Relewise.Client.Requests.Search.Settings.ResultMustHaveVariantConstraint, Relewise.Client', | ||
...constaint, | ||
}; | ||
|
||
this.resultConstraint = constraint; | ||
return this; | ||
} | ||
|
||
build(): ResultMustHaveVariantConstraint | null { | ||
// Do to how the data contracts are generated, resultsConstraints on searchSettings expect this specific type | ||
// Once more types are added it will expect the generic type and this cast should be removed and the generic type should be returned | ||
return this.resultConstraint as ResultMustHaveVariantConstraint | null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters