Added FMS unit suggest.
This commit is contained in:
parent
f2190dd855
commit
572fa9e535
|
@ -54,6 +54,15 @@ const (
|
|||
SuggestBoundHouse BoundValue = "house" // Дом
|
||||
)
|
||||
|
||||
// FMS unit type
|
||||
// https://dadata.ru/api/suggest/fms_unit/
|
||||
const (
|
||||
FMSTypeFMS = 0 // Подразделение ФМС
|
||||
FMSTypeMVD = 1 // ГУВД или МВД региона
|
||||
FMSTypeOVD = 2 // УВД или ОВД района или города
|
||||
FMSTypePoliceState = 3 // Отделение полиции
|
||||
)
|
||||
|
||||
type (
|
||||
// BoundValue type wrapper for suggest bounds
|
||||
// full documentation https://confluence.hflabs.ru/pages/viewpage.action?pageId=222888017
|
||||
|
@ -301,4 +310,13 @@ type (
|
|||
NameShort string `json:"name_short"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// FMSUnit is a FMS unit data model
|
||||
// https://dadata.ru/api/suggest/fms_unit/
|
||||
FMSUnit struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
RegionCode string `json:"region_code"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
)
|
||||
|
|
|
@ -77,6 +77,11 @@ type (
|
|||
Suggestions []*CountrySuggestion `json:"suggestions"`
|
||||
}
|
||||
|
||||
// FMSUnitResponse result slice for FMS unit suggestions
|
||||
FMSUnitResponse struct {
|
||||
Suggestions []*FMSUnitSuggestion `json:"suggestions"`
|
||||
}
|
||||
|
||||
// GeoIPResponse response for GeoIP
|
||||
GeoIPResponse struct {
|
||||
Location *AddressSuggestion `json:"location"`
|
||||
|
@ -122,4 +127,12 @@ type (
|
|||
UnrestrictedValue string `json:"unrestricted_value"`
|
||||
Data *model.Email `json:"data"`
|
||||
}
|
||||
|
||||
// FMSUnitSuggestion is a FMS unit suggestion
|
||||
// https://dadata.ru/api/suggest/fms_unit/
|
||||
FMSUnitSuggestion struct {
|
||||
Value string `json:"value"`
|
||||
UnrestrictedValue string `json:"unrestricted_value"`
|
||||
Data *model.FMSUnit `json:"data"`
|
||||
}
|
||||
)
|
||||
|
|
|
@ -86,6 +86,17 @@ func (a *Api) Country(ctx context.Context, params *RequestParams) (ret []*Countr
|
|||
return
|
||||
}
|
||||
|
||||
// FMSUnit try to return suggest FMS unit by params
|
||||
func (a *Api) FMSUnit(ctx context.Context, params *RequestParams) (ret []*FMSUnitSuggestion, err error) {
|
||||
var result = &FMSUnitResponse{}
|
||||
err = a.Client.Post(ctx, "suggest/fms_unit", params, result)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ret = result.Suggestions
|
||||
return
|
||||
}
|
||||
|
||||
// AddressByID find addresses by Fias or Kladr
|
||||
// see full documentation https://confluence.hflabs.ru/pages/viewpage.action?pageId=312016944
|
||||
func (a *Api) AddressByID(ctx context.Context, id string) (addresses []*AddressSuggestion, err error) {
|
||||
|
|
|
@ -82,6 +82,16 @@ func (s *ApiSuggestIntegrationTest) TestEmail() {
|
|||
s.NotEmpty(res)
|
||||
}
|
||||
|
||||
func (s *ApiSuggestIntegrationTest) TestFMSUnit() {
|
||||
api := NewSuggestApi()
|
||||
params := suggest.RequestParams{
|
||||
Query: "увд",
|
||||
}
|
||||
res, err := api.FMSUnit(context.Background(), ¶ms)
|
||||
s.NoError(err)
|
||||
s.NotEmpty(res)
|
||||
}
|
||||
|
||||
func TestSuggestApiIntegration(t *testing.T) {
|
||||
suite.Run(t, &ApiSuggestIntegrationTest{})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user