suggest

package
v2.11.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NameGenderUnknown = "UNKNOWN" // не удалось однозначно определить
	NameGenderMale    = "MALE"
	NameGenderFemale  = "FEMALE"
)

Name gender values https://confluence.hflabs.ru/pages/viewpage.action?pageId=204669115

View Source
const (
	NamePartSurname    = "SURNAME"
	NamePartName       = "NAME"
	NamePartPatronymic = "PATRONYMIC"
)

Name parts https://dadata.ru/api/suggest/name/ https://confluence.hflabs.ru/pages/viewpage.action?pageId=204669115

View Source
const (
	PartyTypeLegal      PartyType = "LEGAL"
	PartyTypeIndividual PartyType = "INDIVIDUAL"

	PartyBranchTypeMain   PartyBranchType = "MAIN"
	PartyBranchTypeBranch PartyBranchType = "BRANCH"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressResponse

type AddressResponse struct {
	Suggestions []*AddressSuggestion `json:"suggestions"`
}

AddressResponse result slice for address suggestions

type AddressSuggestion

type AddressSuggestion struct {
	Value             string         `json:"value"`
	UnrestrictedValue string         `json:"unrestricted_value"`
	Data              *model.Address `json:"data"`
}

AddressSuggestion api response for address

type Api

type Api struct {
	Client Requester
}

Api provides suggestion API.

func (*Api) Address

func (a *Api) Address(ctx context.Context, params *RequestParams) (ret []*AddressSuggestion, err error)

Address try to return suggest addresses by params

func (*Api) AddressByID

func (a *Api) AddressByID(ctx context.Context, id string) (addresses []*AddressSuggestion, err error)

AddressByID find addresses by Fias or Kladr see full documentation https://confluence.hflabs.ru/pages/viewpage.action?pageId=312016944

func (*Api) Bank

func (a *Api) Bank(ctx context.Context, params *RequestParams) (ret []*BankSuggestion, err error)

Bank try to return suggest banks by params

func (*Api) Country

func (a *Api) Country(ctx context.Context, params *RequestParams) (ret []*CountrySuggestion, err error)

Country try to return suggest countries by params

func (*Api) CountryByID

func (a *Api) CountryByID(ctx context.Context, id string) (addresses []*CountrySuggestion, err error)

CountryByID find countries by ID

func (*Api) Email

func (a *Api) Email(ctx context.Context, params *RequestParams) (ret []*EmailSuggestion, err error)

Email try to return suggest emails by params

func (*Api) FMSUnit

func (a *Api) FMSUnit(ctx context.Context, params *RequestParams) (ret []*FMSUnitSuggestion, err error)

FMSUnit try to return suggest FMS unit by params

func (*Api) GeoIP

func (a *Api) GeoIP(ctx context.Context, ip string) (result *GeoIPResponse, err error)

GeoIP try to find address by IP see documentation on: https://dadata.ru/api/detect_address_by_ip/ ip string representation of ip-address (example 10.12.44.23) if ip=="" then dadata try to get ip-address from X-Forwarded-For header

func (*Api) Name

func (a *Api) Name(ctx context.Context, requestParams *RequestParams, opts ...NameOption) (ret []*NameSuggestion, err error)

Name try to return suggest names by params

func (*Api) Party

func (a *Api) Party(ctx context.Context, params *RequestParams) (ret []*PartySuggestion, err error)

Party try to return suggest parties by params

func (*Api) PartyByID

func (a *Api) PartyByID(ctx context.Context, params *PartyByIDParams) (ret []*PartySuggestion, err error)

Party find parties by ID https://dadata.ru/api/find-party/

type BankResponse

type BankResponse struct {
	Suggestions []*BankSuggestion `json:"suggestions"`
}

BankResponse result slice for bank suggestions

type BankSuggestion

type BankSuggestion struct {
	Value             string      `json:"value"`
	UnrestrictedValue string      `json:"unrestricted_value"`
	Data              *model.Bank `json:"data"`
}

BankSuggestion api response for bank

type Bound

type Bound struct {
	Value model.BoundValue `json:"value"`
}

Bound for granular sugestion full documentation https://confluence.hflabs.ru/pages/viewpage.action?pageId=222888017

type CountryResponse

type CountryResponse struct {
	Suggestions []*CountrySuggestion `json:"suggestions"`
}

CountryResponse result slice for country suggestions

type CountrySuggestion

type CountrySuggestion struct {
	Value string         `json:"value"`
	Data  *model.Country `json:"data"`
}

CountrySuggestion api response for country

type EmailResponse

type EmailResponse struct {
	Suggestions []*EmailSuggestion `json:"suggestions"`
}

EmailResponse result slice for email suggestions

type EmailSuggestion

type EmailSuggestion struct {
	Value             string       `json:"value"`
	UnrestrictedValue string       `json:"unrestricted_value"`
	Data              *model.Email `json:"data"`
}

EmailSuggestion api response for email

type FMSUnitResponse

type FMSUnitResponse struct {
	Suggestions []*FMSUnitSuggestion `json:"suggestions"`
}

FMSUnitResponse result slice for FMS unit suggestions

type FMSUnitSuggestion

type FMSUnitSuggestion struct {
	Value             string         `json:"value"`
	UnrestrictedValue string         `json:"unrestricted_value"`
	Data              *model.FMSUnit `json:"data"`
}

FMSUnitSuggestion is a FMS unit suggestion https://dadata.ru/api/suggest/fms_unit/

type GeoIPResponse

type GeoIPResponse struct {
	Location *AddressSuggestion `json:"location"`
}

GeoIPResponse response for GeoIP

type NameOption

type NameOption func(params *NameParams)

func WithNameGender

func WithNameGender(gender string) NameOption

WithNameGender adds `gender` parameter to suggest/fio request https://dadata.ru/api/suggest/name/ https://confluence.hflabs.ru/pages/viewpage.action?pageId=204669115

func WithNameParts

func WithNameParts(parts ...string) NameOption

WithNameParts adds `parts` parameter to suggest/fio request https://dadata.ru/api/suggest/name/ https://confluence.hflabs.ru/pages/viewpage.action?pageId=204669115

type NameParams

type NameParams struct {
	Query  string   `json:"query"`
	Count  int      `json:"count"`
	Parts  []string `json:"parts"`
	Gender string   `json:"gender"`
}

type NameResponse

type NameResponse struct {
	Suggestions []*NameSuggestion `json:"suggestions"`
}

NameResponse result slice for name suggestions

type NameSuggestion

type NameSuggestion struct {
	Value             string      `json:"value"`
	UnrestrictedValue string      `json:"unrestricted_value"`
	Data              *model.Name `json:"data"`
}

NameSuggestion api response for name

type PartyBranchType

type PartyBranchType string

type PartyByIDParams

type PartyByIDParams struct {
	Query      string           `json:"query"`
	Count      *int             `json:"count,omitempty"`
	KPP        *string          `json:"kpp,omitempty"`
	Type       *PartyType       `json:"type,omitempty"`
	BranchType *PartyBranchType `json:"branch_type,omitempty"`
}

func NewPartyByIDParams

func NewPartyByIDParams(query string) *PartyByIDParams

func (*PartyByIDParams) SetBranchType

func (o *PartyByIDParams) SetBranchType(t PartyBranchType) *PartyByIDParams

func (*PartyByIDParams) SetCount

func (o *PartyByIDParams) SetCount(count int) *PartyByIDParams

func (*PartyByIDParams) SetKPP

func (o *PartyByIDParams) SetKPP(kpp string) *PartyByIDParams

func (*PartyByIDParams) SetQuery

func (o *PartyByIDParams) SetQuery(query string) *PartyByIDParams

func (*PartyByIDParams) SetType

func (o *PartyByIDParams) SetType(t PartyType) *PartyByIDParams

type PartyResponse

type PartyResponse struct {
	Suggestions []*PartySuggestion `json:"suggestions"`
}

PartyResponse result slice for party suggestions

type PartySuggestion

type PartySuggestion struct {
	Value             string       `json:"value"`
	UnrestrictedValue string       `json:"unrestricted_value"`
	Data              *model.Party `json:"data"`
}

PartySuggestion api response for party https://confluence.hflabs.ru/pages/viewpage.action?pageId=204669122

type PartyType

type PartyType string

type RequestParams

type RequestParams struct {
	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

	FromBound *Bound `json:"from_bound"`
	ToBound   *Bound `json:"to_bound"`
}

RequestParams Request struct

type RequestParamsLocation

type RequestParamsLocation struct {
	FiasID               string `json:"fias_id,omitempty"`
	KladrID              string `json:"kladr_id,omitempty"`
	Region               string `json:"region,omitempty"`
	RegionFiasID         string `json:"region_fias_id,omitempty"`
	RegionKladrID        string `json:"region_kladr_id,omitempty"`
	RegionTypeFull       string `json:"region_type_full,omitempty"`
	City                 string `json:"city,omitempty"`
	CityFiasID           string `json:"city_fias_id,omitempty"` // search only in this area
	CityKladrID          string `json:"city_kladr_id,omitempty"`
	CityTypeFull         string `json:"city_type_full,omitempty"`
	CityDistrictTypeFull string `json:"city_district_type_full,omitempty"`
	Settlement           string `json:"settlement,omitempty"`
	SettlementFiasID     string `json:"settlement_fias_id,omitempty"`
	SettlementKladrID    string `json:"settlement_kladr_id,omitempty"`
	SettlementTypeFull   string `json:"settlement_type_full,omitempty"`
	Street               string `json:"street,omitempty"`
	StreetFiasID         string `json:"street_fias_id,omitempty"`
	StreetKladrID        string `json:"street_kladr_id,omitempty"`
	StreetTypeFull       string `json:"street_type_full,omitempty"`
	AreaTypeFull         string `json:"area_type_full,omitempty"`
	Country              string `json:"country,omitempty"`
	CountryISOCode       string `json:"country_iso_code,omitempty"`
}

RequestParamsLocation constraints for suggestion full documentation https://confluence.hflabs.ru/pages/viewpage.action?pageId=204669108

type Requester

type Requester interface {
	// Get makes a GET API call. Assumes sending params in a request query string.
	Get(ctx context.Context, apiMethod string, params url.Values, result interface{}) error
	// Post makes a POST API call. Assumes sending json-encoded params in a request body.
	Post(ctx context.Context, apiMethod string, params, result interface{}) error
}

Requester provides transport level API calls.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL