Skip to content

Commit

Permalink
added PhoneResponse (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandrErohin authored Aug 16, 2021
1 parent 228d7e0 commit e452be4
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 4 deletions.
Binary file added dadata-bundle.zip
Binary file not shown.
22 changes: 22 additions & 0 deletions src/Model/Response/Suggest/PartyResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,34 @@ class PartyResponse extends SuggestResponse
*/
public $licenses;

/**
* @var EmailResponse[] Адреса эл. почты
*/
public $emails;

/**
* @var PhoneResponse[] Телефоны
*/
public $phones;

public function __construct(array $data)
{
parent::__construct($data);

if (isset($data['data']['address'])) {
$this->address = new AddressResponse($data['data']['address']);
}

if (isset($data['data']['emails']) && is_array($data['data']['emails'])) {
foreach ($data['data']['emails'] as $data) {
$this->emails[] = new EmailResponse($data);
}
}

if (isset($data['data']['phones']) && is_array($data['data']['phones'])) {
foreach ($data['data']['phones'] as $data) {
$this->phones[] = new PhoneResponse($data);
}
}
}
}
12 changes: 12 additions & 0 deletions src/Model/Response/Suggest/PhoneResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace Velhron\DadataBundle\Model\Response\Suggest;

use Velhron\DadataBundle\Traits\Phone;

class PhoneResponse extends SuggestResponse
{
use Phone;
}
5 changes: 5 additions & 0 deletions src/Traits/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

trait Email
{
/**
* @var string email одной строкой как в ЕГРЮЛ
*/
public $source;

/**
* @var string Локальная часть адреса (то, что до «собачки»)
*/
Expand Down
58 changes: 58 additions & 0 deletions src/Traits/Phone.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

declare(strict_types=1);

namespace Velhron\DadataBundle\Traits;

trait Phone
{
/**
* @var string телефон одной строкой как в ЕГРЮЛ
*/
public $source;

/**
* @var string тип телефона (мобильный, стационарный, ...)
*/
public $type;

/**
* @var string код страны
*/
public $countryCode;

/**
* @var string код города / DEF-код
*/
public $cityCode;

/**
* @var string локальный номер телефона
*/
public $number;

/**
* @var string оператор связи
*/
public $provider;

/**
* @var string регион
*/
public $region;

/**
* @var string город (только для стационарных телефонов)
*/
public $city;

/**
* @var string часовой пояс
*/
public $timezone;

/**
* @var string контактное лицо
*/
public $contact;
}
74 changes: 70 additions & 4 deletions tests/mocks/Find/party.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,41 @@
"qc": "0"
}
},
"phones": null,
"emails": null,
"phones": [
{
"value": "+7 911 1000000",
"unrestricted_value": "+7 911 1000000",
"data": {
"contact": null,
"source": "+7 911 1000000",
"qc": null,
"type": "Мобильный",
"number": "1000000",
"extension": null,
"provider": "ПАО \"Мобильные ТелеСистемы\"",
"country": null,
"region": "Санкт-Петербург и Ленинградская область",
"city": null,
"timezone": "UTC+3",
"country_code": "7",
"city_code": "911",
"qc_conflict": null
}
}
],
"emails": [
{
"value": "[email protected]",
"unrestricted_value": "[email protected]",
"data": {
"local": "test",
"domain": "example.com",
"type": null,
"source": "[email protected]",
"qc": null
}
}
],
"ogrn_date": 1029456000000,
"okved_type": "2014",
"employee_count": null
Expand Down Expand Up @@ -287,8 +320,41 @@
"qc": "0"
}
},
"phones": null,
"emails": null,
"phones": [
{
"value": "+7 911 2000000",
"unrestricted_value": "+7 911 2000000",
"data": {
"contact": null,
"source": "+7 911 2000000",
"qc": null,
"type": "Мобильный",
"number": "2000000",
"extension": null,
"provider": "ПАО \"Мобильные ТелеСистемы\"",
"country": null,
"region": "Санкт-Петербург и Ленинградская область",
"city": null,
"timezone": "UTC+3",
"country_code": "7",
"city_code": "911",
"qc_conflict": null
}
}
],
"emails": [
{
"value": "[email protected]",
"unrestricted_value": "[email protected]",
"data": {
"local": "test",
"domain": "example.com",
"type": null,
"source": "[email protected]",
"qc": null
}
}
],
"ogrn_date": null,
"okved_type": null,
"employee_count": null
Expand Down

0 comments on commit e452be4

Please sign in to comment.