1 | <?php |
||
21 | class Entities implements EntitiesContract |
||
22 | { |
||
23 | protected $client; |
||
24 | protected $mapper; |
||
25 | |||
26 | public function __construct(GuzzleClient $client, MapperContract $mapper) |
||
31 | |||
32 | /** |
||
33 | * Get countries. |
||
34 | * |
||
35 | * @param array $parameters |
||
36 | * @return Collection |
||
37 | */ |
||
38 | public function getCountries(array $parameters = []): Collection |
||
44 | |||
45 | /** |
||
46 | * Get country by id. |
||
47 | * |
||
48 | * @param int $id |
||
49 | * @param array $parameters |
||
50 | * @return Country|null |
||
51 | */ |
||
52 | public function getCountry(int $id, array $parameters = []): ?Country |
||
58 | |||
59 | /** |
||
60 | * Get currencies. |
||
61 | * |
||
62 | * @param array $parameters |
||
63 | * @return Collection |
||
64 | */ |
||
65 | public function getCurrencies(array $parameters = []): Collection |
||
71 | |||
72 | /** |
||
73 | * Get currency by id. |
||
74 | * |
||
75 | * @param int $id |
||
76 | * @param array $parameters |
||
77 | * @return Currency|null |
||
78 | */ |
||
79 | public function getCurrency(int $id, array $parameters = []): ?Currency |
||
85 | |||
86 | /** |
||
87 | * Get agents. |
||
88 | * |
||
89 | * @param array $parameters |
||
90 | * @return Collection |
||
91 | */ |
||
92 | public function getAgents(array $parameters = []): Collection |
||
98 | |||
99 | /** |
||
100 | * Get merchants. |
||
101 | * |
||
102 | * @param array $parameters |
||
103 | * @return Collection |
||
104 | */ |
||
105 | public function getMerchants(array $parameters = []): Collection |
||
111 | |||
112 | /** |
||
113 | * Get merchant by id. |
||
114 | * |
||
115 | * @param int $id |
||
116 | * @param array $parameters |
||
117 | * @return Merchant|null |
||
118 | */ |
||
119 | public function getMerchant(int $id, array $parameters = []): ?Merchant |
||
125 | |||
126 | /** |
||
127 | * Get merchant sites. |
||
128 | * |
||
129 | * @param Merchant $merchant |
||
130 | * @param array $parameters |
||
131 | * |
||
132 | * @return Collection |
||
133 | */ |
||
134 | public function getSites(Merchant $merchant, array $parameters = []): Collection |
||
140 | |||
141 | /** |
||
142 | * Get merchant site. |
||
143 | * |
||
144 | * @param Merchant $merchant |
||
145 | * @param int $id |
||
146 | * @param array $parameters |
||
147 | * |
||
148 | * @return Site|null |
||
149 | */ |
||
150 | public function getSite(Merchant $merchant, int $id, array $parameters = []): ?Site |
||
156 | |||
157 | /** |
||
158 | * Get products. |
||
159 | * |
||
160 | * @param Merchant $merchant |
||
161 | * @param Site $site |
||
162 | * @param array $parameters |
||
163 | * @return Collection |
||
164 | */ |
||
165 | public function getProducts(Merchant $merchant, Site $site, array $parameters = []): Collection |
||
175 | |||
176 | /** |
||
177 | * Get merchant site's product. |
||
178 | * |
||
179 | * @param Merchant $merchant |
||
180 | * @param Site $site |
||
181 | * @param int $id |
||
182 | * @param array $parameters |
||
183 | * @return Product|null |
||
184 | */ |
||
185 | public function getProduct(Merchant $merchant, Site $site, int $id, array $parameters = []): ?Product |
||
195 | |||
196 | /** |
||
197 | * @param string $method |
||
198 | * @param string $url |
||
199 | * @param array $options |
||
200 | * @return mixed |
||
201 | * @throws RuntimeException |
||
202 | * @throws InvalidArgumentException |
||
203 | */ |
||
204 | protected function makeRequest(string $method, string $url, array $options) |
||
212 | |||
213 | /** |
||
214 | * Transform data. |
||
215 | * |
||
216 | * @param $data |
||
217 | * @param string $entity |
||
218 | * @return mixed |
||
219 | */ |
||
220 | private function transform($data, string $entity) |
||
232 | } |
||
233 |