Skip to content

Commit 1022c1e

Browse files
Merge pull request #3 from answear/city-street-requests
Add requests related to cities and streets
2 parents 034c2e2 + c644af1 commit 1022c1e

20 files changed

+636
-15
lines changed

src/Enum/RequestEnum.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,36 @@ class RequestEnum extends Enum
1010
{
1111
public const SEARCH_DIVISIONS = 'searchDivisions';
1212

13+
public const GET_API_VERSION = 'getApiVersion';
14+
15+
public const SEARCH_CITY_BY_POST_CODE = 'searchCityByPostCode';
16+
17+
public const SEARCH_CITY = 'searchCity';
18+
19+
public const SEARCH_STREET_BY_NAME_AND_CITY_ID_REF = 'searchStreetByNameAndCityIdRef';
20+
1321
public static function searchDivisions(): self
1422
{
1523
return static::get(static::SEARCH_DIVISIONS);
1624
}
25+
26+
public static function getApiVersion(): self
27+
{
28+
return static::get(static::GET_API_VERSION);
29+
}
30+
31+
public static function searchCityByPostCode(): self
32+
{
33+
return static::get(static::SEARCH_CITY_BY_POST_CODE);
34+
}
35+
36+
public static function searchCity(): self
37+
{
38+
return static::get(static::SEARCH_CITY);
39+
}
40+
41+
public static function searchStreetByNameAndCityIdRef(): self
42+
{
43+
return static::get(static::SEARCH_STREET_BY_NAME_AND_CITY_ID_REF);
44+
}
1745
}

src/Enum/ResponseEnum.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,18 @@ class ResponseEnum
88
{
99
public const SEARCH_DIVISIONS = 'searchDivisionsResponse';
1010

11+
public const GET_API_VERSION = 'getApiVersionResponse';
12+
13+
public const SEARCH_CITY_BY_POST_CODE = 'searchCityByPostCodeResponse';
14+
15+
public const SEARCH_CITY = 'searchCityResponse';
16+
17+
public const SEARCH_STREET_BY_NAME_AND_CITY_ID_REF = 'searchStreetByNameAndCityIdRefResponse';
18+
19+
// inner DTOs
1120
public const DIVISION_DTO = 'divisionApiBean';
21+
22+
public const CITY_DTO = 'cityApiBean';
23+
24+
public const STREET_DTO = 'streetApiBean';
1225
}

src/Exception/MeestException.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Answear\MeestBundle\Exception;
6+
7+
class MeestException extends \RuntimeException
8+
{
9+
public function __construct(\SoapFault $soapFault)
10+
{
11+
parent::__construct('Meest B2B API error has occurred.', 0, $soapFault);
12+
}
13+
}

src/Request/GetApiVersion.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Answear\MeestBundle\Request;
6+
7+
use Answear\MeestBundle\Enum\RequestEnum;
8+
9+
class GetApiVersion implements RequestInterface
10+
{
11+
public function __construct()
12+
{
13+
}
14+
15+
public function getEndpoint(): RequestEnum
16+
{
17+
return RequestEnum::getApiVersion();
18+
}
19+
20+
public function toArray(): array
21+
{
22+
return [];
23+
}
24+
}

src/Request/RequestInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
interface RequestInterface
1010
{
11-
public function getMethod(): RequestEnum;
11+
public function getEndpoint(): RequestEnum;
1212

1313
public function toArray(): array;
1414
}

src/Request/SearchCity.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Answear\MeestBundle\Request;
6+
7+
use Answear\MeestBundle\Enum\RequestEnum;
8+
9+
class SearchCity implements RequestInterface
10+
{
11+
/**
12+
* @var string
13+
*/
14+
private $cityName;
15+
16+
public function __construct(string $cityName)
17+
{
18+
$this->cityName = $cityName;
19+
}
20+
21+
public function getEndpoint(): RequestEnum
22+
{
23+
return RequestEnum::searchCity();
24+
}
25+
26+
public function toArray(): array
27+
{
28+
return [
29+
'arg0' => $this->cityName,
30+
];
31+
}
32+
}

src/Request/SearchCityByPostCode.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Answear\MeestBundle\Request;
6+
7+
use Answear\MeestBundle\Enum\RequestEnum;
8+
use Webmozart\Assert\Assert;
9+
10+
class SearchCityByPostCode implements RequestInterface
11+
{
12+
/**
13+
* @var string
14+
*/
15+
private $postCode;
16+
17+
public function __construct(string $postCode)
18+
{
19+
Assert::length($postCode, 5);
20+
Assert::digits($postCode);
21+
$this->postCode = $postCode;
22+
}
23+
24+
public function getEndpoint(): RequestEnum
25+
{
26+
return RequestEnum::searchCityByPostCode();
27+
}
28+
29+
public function toArray(): array
30+
{
31+
return [
32+
'arg0' => $this->postCode,
33+
];
34+
}
35+
}

src/Request/SearchDivisions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct(?DivisionTypeEnum $divisionType = null, ?string $cit
2525
$this->cityId = $cityId;
2626
}
2727

28-
public function getMethod(): RequestEnum
28+
public function getEndpoint(): RequestEnum
2929
{
3030
return RequestEnum::searchDivisions();
3131
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Answear\MeestBundle\Request;
6+
7+
use Answear\MeestBundle\Enum\RequestEnum;
8+
9+
class SearchStreetByNameAndCityIdRef implements RequestInterface
10+
{
11+
/**
12+
* @var string
13+
*/
14+
private $cityId;
15+
16+
/**
17+
* @var string
18+
*/
19+
private $streetName;
20+
21+
public function __construct(string $cityId, string $streetName)
22+
{
23+
$this->cityId = $cityId;
24+
$this->streetName = $streetName;
25+
}
26+
27+
public function getEndpoint(): RequestEnum
28+
{
29+
return RequestEnum::searchStreetByNameAndCityIdRef();
30+
}
31+
32+
public function toArray(): array
33+
{
34+
return [
35+
'arg0' => $this->cityId,
36+
'arg1' => $this->streetName,
37+
];
38+
}
39+
}

src/Response/DTO/CityDTO.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Answear\MeestBundle\Response\DTO;
6+
7+
class CityDTO
8+
{
9+
/**
10+
* @var string
11+
*/
12+
public $cityIdRef;
13+
14+
/**
15+
* @var string
16+
*/
17+
public $descriptionUA;
18+
19+
/**
20+
* @var string|null
21+
*/
22+
public $descriptionRU;
23+
24+
/**
25+
* @var string|null
26+
*/
27+
public $descriptionEN;
28+
29+
/**
30+
* @var string
31+
*/
32+
public $regionDescriptionUA;
33+
34+
/**
35+
* @var string|null
36+
*/
37+
public $regionDescriptionRU;
38+
39+
/**
40+
* @var string|null
41+
*/
42+
public $regionDescriptionEN;
43+
44+
/**
45+
* @var string
46+
*/
47+
public $districtDescriptionUA;
48+
49+
/**
50+
* @var string|null
51+
*/
52+
public $districtDescriptionRU;
53+
54+
/**
55+
* @var string|null
56+
*/
57+
public $districtDescriptionEN;
58+
59+
}

0 commit comments

Comments
 (0)