1 | <?php |
||
21 | class Entities implements EntitiesContract |
||
22 | { |
||
23 | protected $client; |
||
24 | protected $mapper; |
||
25 | |||
26 | protected $resources = [ |
||
27 | Country::class => 'countries', |
||
28 | Currency::class => 'currencies', |
||
29 | Merchant::class => 'merchants', |
||
30 | Product::class => 'products', |
||
31 | Site::class => 'sites', |
||
32 | Agent::class => 'agents', |
||
33 | ]; |
||
34 | |||
35 | public function __construct(GuzzleClient $client, MapperContract $mapper) |
||
40 | |||
41 | /** |
||
42 | * Get countries. |
||
43 | * |
||
44 | * @param array $parameters |
||
45 | * @return Collection |
||
46 | */ |
||
47 | public function getCountries(array $parameters = []): Collection |
||
53 | |||
54 | /** |
||
55 | * Get country by id. |
||
56 | * |
||
57 | * @param int $id |
||
58 | * @param array $parameters |
||
59 | * @return Country|null |
||
60 | */ |
||
61 | public function getCountry(int $id, array $parameters = []): ?Country |
||
67 | |||
68 | /** |
||
69 | * Get currencies. |
||
70 | * |
||
71 | * @param array $parameters |
||
72 | * @return Collection |
||
73 | */ |
||
74 | public function getCurrencies(array $parameters = []): Collection |
||
80 | |||
81 | /** |
||
82 | * Get currency by id. |
||
83 | * |
||
84 | * @param int $id |
||
85 | * @param array $parameters |
||
86 | * @return Currency|null |
||
87 | */ |
||
88 | public function getCurrency(int $id, array $parameters = []): ?Currency |
||
94 | |||
95 | /** |
||
96 | * Get agents. |
||
97 | * |
||
98 | * @param array $parameters |
||
99 | * @return Collection |
||
100 | */ |
||
101 | public function getAgents(array $parameters = []): Collection |
||
107 | |||
108 | /** |
||
109 | * Get merchant by id. |
||
110 | * |
||
111 | * @param int $id |
||
112 | * @param array $parameters |
||
113 | * @return Merchant|null |
||
114 | */ |
||
115 | public function getMerchant(int $id, array $parameters = []): ?Merchant |
||
121 | |||
122 | /** |
||
123 | * Get merchant sites. |
||
124 | * |
||
125 | * @param Merchant $merchant |
||
126 | * @param array $parameters |
||
127 | * |
||
128 | * @return Collection |
||
129 | */ |
||
130 | public function getSites(Merchant $merchant, array $parameters = []): Collection |
||
136 | |||
137 | /** |
||
138 | * Get merchant site. |
||
139 | * |
||
140 | * @param Merchant $merchant |
||
141 | * @param int $id |
||
142 | * @param array $parameters |
||
143 | * |
||
144 | * @return Site|null |
||
145 | */ |
||
146 | public function getSite(Merchant $merchant, int $id, array $parameters = []): ?Site |
||
152 | |||
153 | /** |
||
154 | * Get products. |
||
155 | * |
||
156 | * @param Merchant $merchant |
||
157 | * @param Site $site |
||
158 | * @param array $parameters |
||
159 | * @return Collection |
||
160 | */ |
||
161 | public function getProducts(Merchant $merchant, Site $site, array $parameters = []): Collection |
||
171 | |||
172 | /** |
||
173 | * Get merchant site's product. |
||
174 | * |
||
175 | * @param Merchant $merchant |
||
176 | * @param Site $site |
||
177 | * @param int $id |
||
178 | * @param array $parameters |
||
179 | * @return Product|null |
||
180 | */ |
||
181 | public function getProduct(Merchant $merchant, Site $site, int $id, array $parameters = []): ?Product |
||
191 | |||
192 | /** |
||
193 | * @param string $method |
||
194 | * @param string $url |
||
195 | * @param array $options |
||
196 | * @return mixed |
||
197 | * @throws RuntimeException |
||
198 | * @throws InvalidArgumentException |
||
199 | */ |
||
200 | protected function makeRequest(string $method, string $url, array $options) |
||
208 | |||
209 | /** |
||
210 | * Transform data. |
||
211 | * |
||
212 | * @param $data |
||
213 | * @param string $entity |
||
214 | * @return mixed |
||
215 | */ |
||
216 | private function transform($data, string $entity) |
||
228 | } |
||
229 |