From 8f17cf3ff4bb5805e9bf3857d447713e8932363a Mon Sep 17 00:00:00 2001 From: Sergey Nikitin Date: Tue, 23 Apr 2024 08:51:53 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=D0=B8=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=20'Ty?= =?UTF-8?q?pe'=20=D0=B2=20=D0=B7=D0=B0=D0=BF=D1=80=D0=BE=D1=81=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B4=D1=81=D0=BA=D0=B0=D0=B7=D0=BE=D0=BA=20=D1=8E=D1=80?= =?UTF-8?q?=D0=BB=D0=B8=D1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/suggest/model.go | 5 +++-- dadata_test.go | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/api/suggest/model.go b/api/suggest/model.go index db170e7..da8a9bd 100644 --- a/api/suggest/model.go +++ b/api/suggest/model.go @@ -40,8 +40,9 @@ type ( // RequestParams Request struct RequestParams struct { - Query string `json:"query"` // user input for suggestion - Count int `json:"count"` // ligmit for results + 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 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 23e07e6..61fc02c 100644 --- a/dadata_test.go +++ b/dadata_test.go @@ -73,6 +73,34 @@ func (s *ApiSuggestIntegrationTest) TestParty() { s.NotEmpty(res) } +func (s *ApiSuggestIntegrationTest) TestPartyWithTypePositive() { + api := NewSuggestApi() + + // positive: there are some legal entities "сбербанк" + legalParty := suggest.PartyTypeLegal + res, err := api.Party(context.Background(), &suggest.RequestParams{ + Query: "сбербанк", + Type: &legalParty, + }) + + s.NoError(err) + s.NotEmpty(res) +} + +func (s *ApiSuggestIntegrationTest) TestPartyWithTypeMegative() { + api := NewSuggestApi() + + // there are no one individual entrepreneur "сбербанк" + individualParty := suggest.PartyTypeIndividual + res, err := api.Party(context.Background(), &suggest.RequestParams{ + Query: "сбербанк", + Type: &individualParty, + }) + + s.NoError(err) + s.Empty(res) +} + func (s *ApiSuggestIntegrationTest) TestPartyById() { api := NewSuggestApi()