|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace BotGun\DaData\Methods\Address; |
| 4 | + |
| 5 | +use GuzzleHttp\Client; |
| 6 | +use BotGun\DaData\Http\Router; |
| 7 | +use BotGun\DaData\Methods\BaseMethod; |
| 8 | + |
| 9 | +/** |
| 10 | + * Find address by FIAS, GAR, KLADR code or cadastral number |
| 11 | + * |
| 12 | + * Searches for addresses using any part of the address, from region to apartment ("piter zelenkov 7a" → "194044, |
| 13 | + * Business Center 'Chagall', Zelenkov Lane, 7a lit Z, office 16"). It also searches by postal code ("194044" → "St. |
| 14 | + * Petersburg, Zelenkov Lane"). |
| 15 | + * Capabilities: |
| 16 | + * - Global Coverage: Works for all countries worldwide. In Russia, it provides detailed addresses down to the |
| 17 | + * apartment level; in Belarus, Kazakhstan, and Uzbekistan, |
| 18 | + * it provides addresses down to the house level; for other countries, it provides addresses down to the city |
| 19 | + * level. It searches and displays results in both. Russian ("Самара, пр-кт Металлургов") and English ("Russia, |
| 20 | + * gorod Samara, prospekt Metallurgov"). |
| 21 | + * - Historical and Synonym Search: Finds current addresses using historical names (e.g., "Свердловск" → |
| 22 | + * "Екатеринбург") and synonyms |
| 23 | + * (e.g., "Питер" → "Санкт-Петербург"). |
| 24 | + * - Partial Matching: Searches using partial matches for the last word in the query ("москва болот" → "г Москва, |
| 25 | + * Болотная наб"), but not for the initial words ("мос болот" will not find it). |
| 26 | + * - Error Correction: Corrects typos (e.g., "самара авиционная") and queries typed in the wrong keyboard layout |
| 27 | + * (e.g., "vjcrdf" → "москва"). |
| 28 | + * - Cadastral and FIAS Codes: Finds addresses using cadastral numbers ("77:02:0004008:4143") and FIAS codes |
| 29 | + * ("f26b876b-6857-4951-b060-ec6559f04a9a"). |
| 30 | + * - Detailed Breakdown: Returns addresses in administrative and municipal divisions, breaking down the selected |
| 31 | + * address into granular parts (from region to apartment). |
| 32 | + * - Granular Suggest: Provides granular suggestions for specific parts of the address (regions, cities, |
| 33 | + * streets, houses). |
| 34 | + * - Land Parcels: Identifies land parcels ("казань красная участок 109в" → "420025, Респ Татарстан, г Казань, |
| 35 | + * Советский р-н, ул Большая Красная (Малые Клыки), уч 109в"). |
| 36 | + * - Location Awareness: Takes into account your location (in conjunction with the method for determining the city |
| 37 | + * by IP address). |
| 38 | + * Limitations: |
| 39 | + * - Automated Processing: Cannot automatically (without human intervention) process addresses from a database |
| 40 | + * or file. |
| 41 | + * - Transliteration: Does not transliterate addresses (e.g., "moskva suhonskaja 11" → "127642, г Москва, ул |
| 42 | + * Сухонская, д 11"). |
| 43 | + * |
| 44 | + * @note: FIAS codes for buildings and apartments may change over time. To ensure data integrity, we recommend saving |
| 45 | + * the full address as a plain string in addition to the FIAS code. This will help preserve the address even if the |
| 46 | + * official code changes. |
| 47 | + * |
| 48 | + * |
| 49 | + * @link https://dadata.ru/api/find-address/ |
| 50 | + * |
| 51 | + * @property string $query |
| 52 | + * @property string $count |
| 53 | + * @property string $language |
| 54 | + * @property string $division |
| 55 | + * @property array $locations |
| 56 | + * @property string $locations_geo |
| 57 | + * @property string $locations_boost |
| 58 | + * @property string $from_bound |
| 59 | + * @property string $to_bound |
| 60 | + */ |
| 61 | +class FindByIdMethod extends BaseMethod |
| 62 | +{ |
| 63 | + protected string $method = 'POST'; |
| 64 | + protected string $entryPoint; |
| 65 | + protected string $expect = 'Address'; |
| 66 | + protected array $parameters = [ |
| 67 | + 'query' => 'string', |
| 68 | + 'count' => 'integer', |
| 69 | + 'language' => 'string', |
| 70 | + 'division' => 'string', |
| 71 | + 'locations' => 'array', |
| 72 | + 'locations_geo' => 'string', |
| 73 | + 'locations_boost' => 'string', |
| 74 | + 'from_bound' => 'string', |
| 75 | + 'to_bound' => 'string', |
| 76 | + ]; |
| 77 | + |
| 78 | + /** |
| 79 | + * @param Client $client |
| 80 | + * |
| 81 | + */ |
| 82 | + public function __construct(Client &$client) |
| 83 | + { |
| 84 | + $this->entryPoint = Router::suggestAddress(); |
| 85 | + |
| 86 | + parent::__construct($client); |
| 87 | + } |
| 88 | +} |
0 commit comments