Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/glendemon/dadata-suggestions
Integration with Dadata suggestions API.
https://github.com/glendemon/dadata-suggestions
dadata dadata-suggestions php
Last synced: 3 months ago
JSON representation
Integration with Dadata suggestions API.
- Host: GitHub
- URL: https://github.com/glendemon/dadata-suggestions
- Owner: glendemon
- License: mit
- Created: 2016-05-13T09:09:23.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-05-26T14:38:16.000Z (over 4 years ago)
- Last Synced: 2024-09-19T23:18:00.176Z (3 months ago)
- Topics: dadata, dadata-suggestions, php
- Language: PHP
- Homepage:
- Size: 25.4 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
DadataSuggestions
=================Integration with Dadata suggestions API.
[![Latest Stable Version](https://poser.pugx.org/glendemon/dadata-suggestions/v/stable)](https://packagist.org/packages/glendemon/dadata-suggestions)
[![Total Downloads](https://poser.pugx.org/glendemon/dadata-suggestions/downloads)](https://packagist.org/packages/glendemon/dadata-suggestions)
[![Latest Unstable Version](https://poser.pugx.org/glendemon/dadata-suggestions/v/unstable)](https://packagist.org/packages/glendemon/dadata-suggestions)
[![License](https://poser.pugx.org/glendemon/dadata-suggestions/license)](https://packagist.org/packages/glendemon/dadata-suggestions)Installation
-------------This extension is available at packagist.org and can be installed via composer by following command:
`composer require glendemon/dadata-suggestions`
Configuration
---------You can customize debug panel behavior with this options:
- `token` - private api token [required].
- `url` - path to suggestions api [optional].
- `client` - GuzzleHttp\Client [optional].Example:
```php
$service = new \DadataSuggestions\DadataSuggestionsService();
$service->setUrl('https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/');
$service->setToken('...');
``````php
public function testSuggestAddressFlat()
{
$service = $this->getService();
$response = $service->suggestAddress('мск балтийская 6к1 5');
foreach ($response->getSuggestions() as $suggestion) {
$this->assertEquals('г Москва, ул Балтийская, д 6 к 1, кв 5', $suggestion->getValue());
$this->assertEquals('г Москва, ул Балтийская, д 6 к 1, кв 5', $suggestion->getUnrestrictedValue());
$data = $suggestion->getData();
$this->assertInstanceOf(\DadataSuggestions\Data\Address::class, $data);
$this->assertEquals('Россия', $data->country);
$this->assertEquals('Москва', $data->city);
$this->assertEquals('ул Балтийская', $data->street_with_type);
$this->assertEquals('6', $data->house);
$this->assertEquals('1', $data->block);
$this->assertEquals('5', $data->flat);
}
}
/**
* @return \DadataSuggestions\DadataSuggestionsService
*/
protected function getService()
{
$service = new \DadataSuggestions\DadataSuggestionsService();
$service->setToken('...');
return $service;
}
```Links
------
[API documentation](https://dadata.ru/api/suggest/)