Skip to content

Commit

Permalink
Add searchExact and searchPrecise support to game filters (#2)
Browse files Browse the repository at this point in the history
* Add searchExact and searchPrecise support to game filters; update test to support searchExact and searchPrecise

Co-authored-by: Gianluca Lain <[email protected]>
  • Loading branch information
OsD977 and Gianluca Lain authored May 28, 2022
1 parent d1c94e4 commit 4f9c741
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
12 changes: 12 additions & 0 deletions filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,18 @@ func (filter *GamesFilter) WithoutGameSeries() *GamesFilter {
return filter
}

// WithSearchExact sets "search_exact" parameter
func (filter *GamesFilter) WithSearchExact() *GamesFilter {
filter.searchExact = true
return filter
}

// WithSearchPrecise sets "search_precise" parameter
func (filter *GamesFilter) WithSearchPrecise() *GamesFilter {
filter.searchPrecise = true
return filter
}

// SetOrdering sets results ordering
func (filter *GamesFilter) SetOrdering(ordering string) *GamesFilter {
filter.ordering = ordering
Expand Down
6 changes: 5 additions & 1 deletion filters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ func TestNewGamesFilter(t *testing.T) {
WithoutParents().
WithoutGameSeries().
SetOrdering("-name").
SetMetacritic(20, 80)
SetMetacritic(20, 80).
WithSearchExact().
WithSearchPrecise()

assert.Equal(t, map[string]interface{}{
"creators": "28,mike-morasky",
Expand All @@ -54,6 +56,8 @@ func TestNewGamesFilter(t *testing.T) {
"exclude_collection": 123,
"exclude_game_series": true,
"exclude_parents": true,
"search_exact": true,
"search_precise": true,
"genres": "9,action,indie",
"ordering": "-name",
"page": 1,
Expand Down

0 comments on commit 4f9c741

Please sign in to comment.