From 028e799cc852b61e24c097081b7681c5a6b34018 Mon Sep 17 00:00:00 2001 From: mg Date: Tue, 23 Apr 2024 14:24:58 +0300 Subject: [PATCH 1/2] feat: suggest RequestPrams Language field added --- api/suggest/model.go | 1 + 1 file changed, 1 insertion(+) diff --git a/api/suggest/model.go b/api/suggest/model.go index db170e7..619e2e7 100644 --- a/api/suggest/model.go +++ b/api/suggest/model.go @@ -42,6 +42,7 @@ type ( RequestParams struct { Query string `json:"query"` // user input for suggestion Count int `json:"count"` // ligmit for results + Language string `json:"language"` Locations []*RequestParamsLocation `json:"locations"` RestrictValue bool `json:"restrict_value"` // don't show restricts (region) on results From ef76f4831c5de626a2d8b7402eef4306b4b2f00d Mon Sep 17 00:00:00 2001 From: Alexander Zhuravlev Date: Wed, 8 May 2024 19:46:32 +0300 Subject: [PATCH 2/2] Fix merge conflicts. Added tests. --- api/suggest/model.go | 2 +- dadata_test.go | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/api/suggest/model.go b/api/suggest/model.go index 851952e..8203934 100644 --- a/api/suggest/model.go +++ b/api/suggest/model.go @@ -43,7 +43,7 @@ type ( Type *PartyType `json:"type,omitempty"` // party type for the suggestion (user input) Query string `json:"query"` // user input for suggestion Count int `json:"count"` // ligmit for results - Language *string `json:"language,omitempty"` + Language string `json:"language,omitempty"` Locations []*RequestParamsLocation `json:"locations"` RestrictValue bool `json:"restrict_value"` // don't show restricts (region) on results diff --git a/dadata_test.go b/dadata_test.go index 31e44b5..cfbdc7a 100644 --- a/dadata_test.go +++ b/dadata_test.go @@ -53,6 +53,34 @@ func (s *ApiSuggestIntegrationTest) TestAddress() { s.NotEmpty(res) } +func (s *ApiSuggestIntegrationTest) TestAddressWithLanguageParamRU() { + api := NewSuggestApi() + + params := suggest.RequestParams{ + Query: "ул Свободы", + Language: "RU", + } + + res, err := api.Address(context.Background(), ¶ms) + + s.NoError(err) + s.NotEmpty(res) +} + +func (s *ApiSuggestIntegrationTest) TestAddressWithLanguageParamEN() { + api := NewSuggestApi() + + params := suggest.RequestParams{ + Query: "ул Свободы", + Language: "EN", + } + + res, err := api.Address(context.Background(), ¶ms) + + s.NoError(err) + s.NotEmpty(res) +} + func (s *ApiSuggestIntegrationTest) TestBank() { api := NewSuggestApi() params := suggest.RequestParams{