Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Поиск по почтовому индексу #2

Open
ruslanlatfulin opened this issue Aug 4, 2020 · 2 comments
Open

Поиск по почтовому индексу #2

ruslanlatfulin opened this issue Aug 4, 2020 · 2 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@ruslanlatfulin
Copy link

Добрый день!
Будет ли реализован поиск по почтовому индексу?

@illabo
Copy link
Owner

illabo commented Aug 5, 2020

А он работает:

try? dadata?.suggestAddress("105568") { try? $0.get().suggestions?.forEach { print($0.unrestrictedValue) } }

Отдает список улиц с этим индексом.

Возможно, вы пытаетесь отправить запрос вроде такого:

let q = AddressSuggestionQuery("105568")
q.resultsCount = 1
try? dadata?.suggestAddress(q) { try? $0.get().suggestions?.forEach { print($0.unrestrictedValue) } }

Дадата по-другому ищет запросы с лимитом 1 и по индексу не находит соответствия, но тут вопрос к службе поддержки.
Можете написать им обращение с примером курлового запроса:

curl -X "POST" "https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/address" \
     -H 'Authorization: Token [Your token here]' \
     -H 'Content-Type: application/json' \
     -d $'{
  "query": "105568",
  "count": 1
}'

В ответе возвращается 0 подсказок, но если снять лимит или установить лимит 2 — подсказки будут.

Если ваш вопрос про поиск ближайшего почтового отделения — меня этот функционал не интересовал, но если добавите — приму пул-реквест.
Для этого в AddressQueryType нужно добавить еще один эндпойнт suggest/postal_unit и дописать новый класс, наследующий от DadataQueryProtocol.

@illabo illabo added enhancement New feature or request question Further information is requested labels Aug 5, 2020
@illabo
Copy link
Owner

illabo commented Aug 5, 2020

@ruslanlatfulin Написал на форуме поддержки Дадаты. Ответили, что поведение при лимите 1 верно, в таком случае подсказки по индексу не будет.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants