1 | <?php |
||
22 | class Entities implements EntitiesContract |
||
23 | { |
||
24 | protected $client; |
||
25 | protected $mapper; |
||
26 | |||
27 | public function __construct(GuzzleClient $client, MapperContract $mapper) |
||
32 | |||
33 | /** |
||
34 | * Get countries. |
||
35 | * |
||
36 | * @param array $parameters |
||
37 | * @return Paginator |
||
38 | */ |
||
39 | public function getCountries(array $parameters = []): Paginator |
||
45 | |||
46 | /** |
||
47 | * Get country by id. |
||
48 | * |
||
49 | * @param int $id |
||
50 | * @param array $parameters |
||
51 | * @return Country|null |
||
52 | */ |
||
53 | public function getCountry(int $id, array $parameters = []): ?Country |
||
59 | |||
60 | /** |
||
61 | * Get currencies. |
||
62 | * |
||
63 | * @param array $parameters |
||
64 | * @return Paginator |
||
65 | */ |
||
66 | public function getCurrencies(array $parameters = []): Paginator |
||
72 | |||
73 | /** |
||
74 | * Get currency by id. |
||
75 | * |
||
76 | * @param int $id |
||
77 | * @param array $parameters |
||
78 | * @return Currency|null |
||
79 | */ |
||
80 | public function getCurrency(int $id, array $parameters = []): ?Currency |
||
86 | |||
87 | /** |
||
88 | * Get agents. |
||
89 | * |
||
90 | * @param array $parameters |
||
91 | * @return Paginator |
||
92 | */ |
||
93 | public function getAgents(array $parameters = []): Paginator |
||
99 | |||
100 | /** |
||
101 | * Get merchants. |
||
102 | * |
||
103 | * @param array $parameters |
||
104 | * @return Paginator |
||
105 | */ |
||
106 | public function getMerchants(array $parameters = []): Paginator |
||
112 | |||
113 | /** |
||
114 | * Get merchant by id. |
||
115 | * |
||
116 | * @param int $id |
||
117 | * @param array $parameters |
||
118 | * @return Merchant|null |
||
119 | */ |
||
120 | public function getMerchant(int $id, array $parameters = []): ?Merchant |
||
126 | |||
127 | /** |
||
128 | * Get merchant sites. |
||
129 | * |
||
130 | * @param Merchant $merchant |
||
131 | * @param array $parameters |
||
132 | * |
||
133 | * @return Paginator |
||
134 | */ |
||
135 | public function getSites(Merchant $merchant, array $parameters = []): Paginator |
||
141 | |||
142 | /** |
||
143 | * Get merchant site. |
||
144 | * |
||
145 | * @param Merchant $merchant |
||
146 | * @param int $id |
||
147 | * @param array $parameters |
||
148 | * |
||
149 | * @return Site|null |
||
150 | */ |
||
151 | public function getSite(Merchant $merchant, int $id, array $parameters = []): ?Site |
||
157 | |||
158 | /** |
||
159 | * Get site by id. |
||
160 | * |
||
161 | * @param int $id |
||
162 | * @param array $parameters |
||
163 | * @return Site|null |
||
164 | */ |
||
165 | public function getSiteById(int $id, array $parameters = []): ?Site |
||
171 | |||
172 | /** |
||
173 | * Get products. |
||
174 | * |
||
175 | * @param Merchant $merchant |
||
176 | * @param Site $site |
||
177 | * @param array $parameters |
||
178 | * |
||
179 | * @return Paginator |
||
180 | */ |
||
181 | public function getProducts(Merchant $merchant, Site $site, array $parameters = []): Paginator |
||
191 | |||
192 | /** |
||
193 | * Get merchant site's product. |
||
194 | * |
||
195 | * @param Merchant $merchant |
||
196 | * @param Site $site |
||
197 | * @param int $id |
||
198 | * @param array $parameters |
||
199 | * |
||
200 | * @return Product|null |
||
201 | */ |
||
202 | public function getProduct(Merchant $merchant, Site $site, int $id, array $parameters = []): ?Product |
||
212 | |||
213 | /** |
||
214 | * Get product by id. |
||
215 | * |
||
216 | * @param int $id |
||
217 | * @param array $parameters |
||
218 | * @return Product|null |
||
219 | */ |
||
220 | public function getProductById(int $id, array $parameters = []): ?Product |
||
230 | |||
231 | /** |
||
232 | * @param string $method |
||
233 | * @param string $url |
||
234 | * @param array $options |
||
235 | * |
||
236 | * @return mixed |
||
237 | * @throws RuntimeException |
||
238 | * @throws InvalidArgumentException |
||
239 | */ |
||
240 | protected function makeRequest(string $method, string $url, array $options) |
||
251 | |||
252 | /** |
||
253 | * Transform data. |
||
254 | * |
||
255 | * @param string $entity |
||
256 | * @param stdClass|array $data |
||
257 | * @param bool $list |
||
258 | * @return mixed |
||
259 | */ |
||
260 | private function transform(string $entity, $data, bool $list = false) |
||
274 | } |
||
275 |