1 | <?php |
||
31 | class ApiClient |
||
32 | { |
||
33 | const REGION_BR = 'br'; |
||
34 | const REGION_EUNE = 'eune'; |
||
35 | const REGION_EUW = 'euw'; |
||
36 | const REGION_JP = 'jp'; |
||
37 | const REGION_KR = 'kr'; |
||
38 | const REGION_LAN = 'lan'; |
||
39 | const REGION_LAS = 'las'; |
||
40 | const REGION_NA = 'na'; |
||
41 | const REGION_OCE = 'oce'; |
||
42 | const REGION_TR = 'tr'; |
||
43 | const REGION_RU = 'ru'; |
||
44 | |||
45 | const REGION_BR_ID = 'br1'; |
||
46 | const REGION_EUNE_ID = 'eun1'; |
||
47 | const REGION_EUW_ID = 'euw1'; |
||
48 | const REGION_JP_ID = 'jp1'; |
||
49 | const REGION_KR_ID = 'kr'; |
||
50 | const REGION_LAN_ID = 'la1'; |
||
51 | const REGION_LAS_ID = 'la2'; |
||
52 | const REGION_NA_ID = 'na1'; |
||
53 | const REGION_OCE_ID = 'oc1'; |
||
54 | const REGION_TR_ID = 'tr1'; |
||
55 | const REGION_RU_ID = 'ru'; |
||
56 | |||
57 | /** |
||
58 | * @var array |
||
59 | */ |
||
60 | public static $availableRegions = [ |
||
61 | self::REGION_BR, |
||
62 | self::REGION_EUNE, |
||
63 | self::REGION_EUW, |
||
64 | self::REGION_KR, |
||
65 | self::REGION_LAN, |
||
66 | self::REGION_LAS, |
||
67 | self::REGION_NA, |
||
68 | self::REGION_OCE, |
||
69 | self::REGION_RU, |
||
70 | self::REGION_TR, |
||
71 | ]; |
||
72 | |||
73 | public static $regionsWithIds = [ |
||
74 | self::REGION_BR => self::REGION_BR_ID, |
||
75 | self::REGION_EUNE => self::REGION_EUNE_ID, |
||
76 | self::REGION_EUW => self::REGION_EUW_ID, |
||
77 | self::REGION_KR => self::REGION_KR_ID, |
||
78 | self::REGION_LAN => self::REGION_LAN_ID, |
||
79 | self::REGION_LAS => self::REGION_LAS_ID, |
||
80 | self::REGION_NA => self::REGION_NA_ID, |
||
81 | self::REGION_OCE => self::REGION_OCE_ID, |
||
82 | self::REGION_RU => self::REGION_RU_ID, |
||
83 | self::REGION_TR => self::REGION_TR_ID, |
||
84 | ]; |
||
85 | |||
86 | 3 | /** |
|
87 | * @var string |
||
88 | 3 | */ |
|
89 | 1 | protected $region; |
|
90 | |||
91 | /** |
||
92 | 2 | * @var bool |
|
93 | 2 | */ |
|
94 | 2 | protected $endpointStandardization; |
|
95 | 2 | ||
96 | 2 | /** |
|
97 | * @var string |
||
98 | */ |
||
99 | protected $apiKey; |
||
100 | |||
101 | 1 | /** |
|
102 | * @var Client |
||
103 | 1 | */ |
|
104 | 1 | protected $httpClient; |
|
105 | |||
106 | /** |
||
107 | * @var CacheProvider |
||
108 | */ |
||
109 | 1 | protected $cacheProvider; |
|
110 | |||
111 | 1 | /** |
|
112 | * @param string $region |
||
113 | * @param string $apiKey |
||
114 | * @param CacheProvider $cacheProvider |
||
115 | * @param Client $client |
||
116 | * @param bool $endpointStandardization |
||
117 | 1 | * |
|
118 | * @throws InvalidRegionException |
||
119 | 1 | */ |
|
120 | public function __construct($region, $apiKey, CacheProvider $cacheProvider = null, Client $client = null, $endpointStandardization = false) |
||
132 | |||
133 | 1 | /** |
|
134 | * @param CacheProvider $cacheProvider |
||
135 | 1 | */ |
|
136 | public function setCacheProvider(CacheProvider $cacheProvider) |
||
140 | |||
141 | 1 | /** |
|
142 | * @return CacheProvider |
||
143 | 1 | */ |
|
144 | public function getCacheProvider() |
||
148 | |||
149 | 1 | /** |
|
150 | * @return Client |
||
151 | 1 | */ |
|
152 | public function getHttpClient() |
||
156 | |||
157 | 1 | /** |
|
158 | * @return string |
||
159 | 1 | */ |
|
160 | public function getRegion() |
||
164 | |||
165 | 1 | /** |
|
166 | * @return string |
||
167 | 1 | */ |
|
168 | public function getApiKey() |
||
172 | |||
173 | 1 | /** |
|
174 | * @return MatchListApi |
||
175 | 1 | */ |
|
176 | public function getMatchListApi() |
||
180 | |||
181 | 1 | /** |
|
182 | * @return MatchApi |
||
183 | 1 | */ |
|
184 | public function getMatchApi() |
||
188 | |||
189 | 1 | /** |
|
190 | * @return SummonerApi |
||
191 | 1 | */ |
|
192 | public function getSummonerApi() |
||
196 | |||
197 | 1 | /** |
|
198 | * @return ChampionApi |
||
199 | 1 | */ |
|
200 | public function getChampionApi() |
||
204 | |||
205 | 1 | /** |
|
206 | * @return FeaturedGamesApi |
||
207 | 1 | */ |
|
208 | public function getFeaturedGamesApi() |
||
212 | |||
213 | 1 | /** |
|
214 | * @return StatsApi |
||
215 | 1 | */ |
|
216 | public function getStatsApi() |
||
220 | |||
221 | 1 | /** |
|
222 | * @return MasteryApi |
||
223 | 1 | */ |
|
224 | public function getMasteriesApi() |
||
228 | |||
229 | 1 | /** |
|
230 | * @return RuneApi |
||
231 | 1 | */ |
|
232 | public function getRunesApi() |
||
236 | |||
237 | 1 | /** |
|
238 | * @return GameApi |
||
239 | 1 | */ |
|
240 | public function getGameApi() |
||
244 | |||
245 | 1 | /** |
|
246 | * @return CurrentGameApi |
||
247 | 1 | */ |
|
248 | public function getCurrentGameApi() |
||
252 | |||
253 | 1 | /** |
|
254 | * @return LeagueApi |
||
255 | 1 | */ |
|
256 | public function getLeagueApi() |
||
260 | |||
261 | 1 | /** |
|
262 | * @return StaticDataApi |
||
263 | 1 | */ |
|
264 | public function getStaticDataApi() |
||
268 | |||
269 | /** |
||
270 | 1 | * @return StatusApi |
|
271 | */ |
||
272 | 1 | public function getStatusApi() |
|
276 | |||
277 | /** |
||
278 | * @return ChampionMasteryApi |
||
279 | */ |
||
280 | public function getChampionMasteryApi() |
||
284 | |||
285 | /** |
||
286 | * @param bool $endpointStandardization |
||
287 | * |
||
288 | * @return string |
||
289 | */ |
||
290 | public function getBaseUrl($endpointStandardization = false) |
||
298 | |||
299 | /** |
||
300 | * @return string |
||
301 | */ |
||
302 | public function getGlobalUrl() |
||
306 | |||
307 | /** |
||
308 | * @return string |
||
309 | */ |
||
310 | public function getStatusUrl() |
||
314 | |||
315 | /** |
||
316 | * @param ApiResult $apiResult |
||
317 | * @param int $ttl |
||
318 | */ |
||
319 | public function cacheApiResult(ApiResult $apiResult, $ttl = 60) |
||
323 | } |
||
324 |