-
Notifications
You must be signed in to change notification settings - Fork 12
/
DefaultSettingService.php
146 lines (112 loc) · 5.46 KB
/
DefaultSettingService.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
declare(strict_types=1);
namespace Inspirum\Balikobot\Service;
use Inspirum\Balikobot\Client\Client;
use Inspirum\Balikobot\Definitions\Method;
use Inspirum\Balikobot\Definitions\Version;
use Inspirum\Balikobot\Model\AdrUnit\AdrUnitCollection;
use Inspirum\Balikobot\Model\AdrUnit\AdrUnitFactory;
use Inspirum\Balikobot\Model\Attribute\AttributeCollection;
use Inspirum\Balikobot\Model\Attribute\AttributeFactory;
use Inspirum\Balikobot\Model\Carrier\Carrier;
use Inspirum\Balikobot\Model\Carrier\CarrierCollection;
use Inspirum\Balikobot\Model\Carrier\CarrierFactory;
use Inspirum\Balikobot\Model\Country\CountryCollection;
use Inspirum\Balikobot\Model\Country\CountryFactory;
use Inspirum\Balikobot\Model\ManipulationUnit\ManipulationUnitCollection;
use Inspirum\Balikobot\Model\ManipulationUnit\ManipulationUnitFactory;
use Inspirum\Balikobot\Model\Service\Service;
use Inspirum\Balikobot\Model\Service\ServiceCollection;
use Inspirum\Balikobot\Model\Service\ServiceFactory;
use Inspirum\Balikobot\Model\ZipCode\ZipCodeFactory;
use Inspirum\Balikobot\Model\ZipCode\ZipCodeIterator;
use function sprintf;
final class DefaultSettingService implements SettingService
{
public function __construct(
private readonly Client $client,
private readonly CarrierFactory $carrierFactory,
private readonly ServiceFactory $serviceFactory,
private readonly ManipulationUnitFactory $unitFactory,
private readonly CountryFactory $countryFactory,
private readonly ZipCodeFactory $zipCodeFactory,
private readonly AdrUnitFactory $adrUnitFactory,
private readonly AttributeFactory $attributeFactory,
) {
}
public function getCarriers(): CarrierCollection
{
$response = $this->client->call(Version::V2V1, null, Method::INFO_CARRIERS);
return $this->carrierFactory->createCollection($response);
}
public function getCarrier(string $carrier): Carrier
{
$response = $this->client->call(Version::V2V1, null, Method::INFO_CARRIERS, path: $carrier);
return $this->carrierFactory->create($carrier, $response);
}
public function getServices(string $carrier): ServiceCollection
{
$response = $this->client->call(Version::V2V1, $carrier, Method::SERVICES);
return $this->serviceFactory->createCollection($carrier, $response);
}
public function getActivatedServices(string $carrier): ServiceCollection
{
$response = $this->client->call(Version::V2V1, $carrier, Method::ACTIVATED_SERVICES);
return $this->serviceFactory->createCollection($carrier, $response);
}
public function getB2AServices(string $carrier): ServiceCollection
{
$response = $this->client->call(Version::V2V1, $carrier, Method::B2A_SERVICES);
return $this->serviceFactory->createCollection($carrier, $response);
}
public function getManipulationUnits(string $carrier): ManipulationUnitCollection
{
$response = $this->client->call(Version::V2V1, $carrier, Method::MANIPULATION_UNITS);
return $this->unitFactory->createCollection($carrier, $response);
}
public function getActivatedManipulationUnits(string $carrier): ManipulationUnitCollection
{
$response = $this->client->call(Version::V2V1, $carrier, Method::ACTIVATED_MANIPULATION_UNITS);
return $this->unitFactory->createCollection($carrier, $response);
}
public function getCodCountries(string $carrier): ServiceCollection
{
$response = $this->client->call(Version::V2V1, $carrier, Method::CASH_ON_DELIVERY_COUNTRIES);
return $this->serviceFactory->createCollection($carrier, $response);
}
public function getCountries(string $carrier): ServiceCollection
{
$response = $this->client->call(Version::V2V1, $carrier, Method::COUNTRIES);
return $this->serviceFactory->createCollection($carrier, $response);
}
public function getCountriesData(): CountryCollection
{
$response = $this->client->call(Version::V2V1, null, Method::GET_COUNTRIES_DATA);
return $this->countryFactory->createCollection($response);
}
public function getZipCodes(string $carrier, string $service, ?string $country = null): ZipCodeIterator
{
$response = $this->client->call(Version::V2V1, $carrier, Method::ZIP_CODES, path: sprintf('%s/%s', $service, $country));
return $this->zipCodeFactory->createIterator($carrier, $service, $country, $response);
}
public function getAdrUnits(string $carrier): AdrUnitCollection
{
$response = $this->client->call(Version::V2V1, $carrier, Method::FULL_ADR_UNITS);
return $this->adrUnitFactory->createCollection($carrier, $response);
}
public function getAddAttributes(string $carrier): AttributeCollection
{
$response = $this->client->call(Version::V2V1, $carrier, Method::ADD_ATTRIBUTES);
return $this->attributeFactory->createCollection($carrier, $response);
}
public function getAddServiceOptions(string $carrier): ServiceCollection
{
$response = $this->client->call(Version::V2V1, $carrier, Method::ADD_SERVICE_OPTIONS);
return $this->serviceFactory->createCollection($carrier, $response);
}
public function getAddServiceOptionsForService(string $carrier, string $service): Service
{
$response = $this->client->call(Version::V2V1, $carrier, Method::ADD_SERVICE_OPTIONS, path: $service);
return $this->serviceFactory->create($carrier, $response);
}
}