Omit empty suggest params.

This commit is contained in:
Alexander Zhuravlev 2024-05-08 19:52:33 +03:00
parent d693536866
commit ab7e9437f3
2 changed files with 9 additions and 11 deletions

View File

@ -40,15 +40,15 @@ type (
// RequestParams Request struct
RequestParams struct {
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
Type PartyType `json:"type,omitempty"` // party type for the suggestion (user input)
Query string `json:"query"` // user input for suggestion
Count int `json:"count,omitempty"` // ligmit for results
Language string `json:"language,omitempty"`
Locations []*RequestParamsLocation `json:"locations"`
RestrictValue bool `json:"restrict_value"` // don't show restricts (region) on results
Locations []*RequestParamsLocation `json:"locations,omitempty"`
RestrictValue bool `json:"restrict_value,omitempty"` // don't show restricts (region) on results
FromBound *Bound `json:"from_bound"`
ToBound *Bound `json:"to_bound"`
FromBound *Bound `json:"from_bound,omitempty"`
ToBound *Bound `json:"to_bound,omitempty"`
}
// AddressResponse result slice for address suggestions

View File

@ -105,10 +105,9 @@ 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,
Type: suggest.PartyTypeLegal,
})
s.NoError(err)
@ -119,10 +118,9 @@ func (s *ApiSuggestIntegrationTest) TestPartyWithTypeNegative() {
api := NewSuggestApi()
// there are no one individual entrepreneur "сбербанк"
individualParty := suggest.PartyTypeIndividual
res, err := api.Party(context.Background(), &suggest.RequestParams{
Query: "сбербанк",
Type: &individualParty,
Type: suggest.PartyTypeIndividual,
})
s.NoError(err)