1 | <?php |
||
18 | class Main |
||
19 | { |
||
20 | /** |
||
21 | * API URL root of Battlerite. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | private static $apiUrl = "https://api.dc01.gamelockerapp.com/shards/global/"; |
||
26 | |||
27 | /** |
||
28 | * Guzzle Client variable to send all requests. |
||
29 | * |
||
30 | * @var object<GuzzleHttp\Client> |
||
31 | */ |
||
32 | private $client; |
||
33 | |||
34 | /** |
||
35 | * API Key of your development battlerite account. |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | private $apiKey; |
||
40 | |||
41 | /** |
||
42 | * @var \guastallaigor\PhpBattlerite\Config |
||
43 | */ |
||
44 | private $config; |
||
45 | |||
46 | /** |
||
47 | * Main constructor. |
||
48 | * |
||
49 | * @param \guastallaigor\PhpBattlerite\Config $config |
||
50 | */ |
||
51 | 2 | public function __construct(Config $config) |
|
56 | |||
57 | /** |
||
58 | * Method to set your API Key provided by your Battlerite development account. |
||
59 | * |
||
60 | * @param string $apiKey |
||
61 | * |
||
62 | * @return void |
||
63 | */ |
||
64 | 2 | public function setAPIKey($apiKey) |
|
68 | |||
69 | /** |
||
70 | * Function that is going to make all the requests you need. |
||
71 | * |
||
72 | * @param string $method |
||
73 | * @param string $request |
||
74 | * @param array $filter |
||
75 | * |
||
76 | * @return array |
||
77 | */ |
||
78 | 2 | public function sendRequest($method, $request, $filter = []) |
|
103 | |||
104 | /** |
||
105 | * Get a single player request. |
||
106 | * |
||
107 | * @param string $id |
||
108 | * |
||
109 | * @return array |
||
110 | */ |
||
111 | 1 | public function getPlayer($id) |
|
115 | |||
116 | /** |
||
117 | * Get a collection of players. |
||
118 | * |
||
119 | * @param string $ids |
||
120 | * @param string $type |
||
121 | * |
||
122 | * @return array |
||
123 | */ |
||
124 | 1 | public function getPlayers($ids, $type = 'playerIds') |
|
129 | |||
130 | /** |
||
131 | * Get a collection of teams. |
||
132 | * |
||
133 | * @param array $filter |
||
134 | * |
||
135 | * @return array |
||
136 | */ |
||
137 | public function getTeams($filter = []) |
||
141 | |||
142 | /** |
||
143 | * Get Battlerite status. |
||
144 | * |
||
145 | * @return array |
||
146 | */ |
||
147 | public function getStatus() |
||
151 | |||
152 | public function getTelemetry() |
||
159 | |||
160 | /** |
||
161 | * Function to handle unexpected errors. |
||
162 | * |
||
163 | * @param RequestException $error |
||
164 | * |
||
165 | * @return void |
||
166 | */ |
||
167 | protected function statusCodeHandling($error) |
||
176 | } |
||
177 |