1 | <?php |
||
18 | class Main |
||
19 | { |
||
20 | /** |
||
21 | * Guzzle Client variable to send all requests. |
||
22 | * |
||
23 | * @var object<GuzzleHttp\Client> |
||
24 | */ |
||
25 | private $client; |
||
26 | |||
27 | /** |
||
28 | * API Key of your development battlerite account. |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | private $apiKey; |
||
33 | |||
34 | /** |
||
35 | * @var \guastallaigor\PhpBattlerite\Config |
||
36 | */ |
||
37 | private $config; |
||
38 | |||
39 | /** |
||
40 | * Main constructor. |
||
41 | * |
||
42 | * @param \guastallaigor\PhpBattlerite\Config $config |
||
43 | */ |
||
44 | 3 | public function __construct(Config $config) |
|
49 | |||
50 | /** |
||
51 | * Method to set your API Key provided by your Battlerite development account. |
||
52 | * |
||
53 | * @param string $apiKey |
||
54 | * |
||
55 | * @return void |
||
56 | */ |
||
57 | 3 | public function setAPIKey($apiKey) |
|
61 | |||
62 | /** |
||
63 | * Function that is going to make all the requests you need. |
||
64 | * |
||
65 | * @param string $method |
||
66 | * @param string $request |
||
67 | * @param array $filter |
||
68 | * |
||
69 | * @return array |
||
70 | */ |
||
71 | 3 | public function sendRequest($method, $request, $filter = [], $global = true) |
|
98 | |||
99 | /** |
||
100 | * Get a single player request. |
||
101 | * |
||
102 | * @param string $id |
||
103 | * |
||
104 | * @return array |
||
105 | */ |
||
106 | 1 | public function getPlayer($id) |
|
110 | |||
111 | /** |
||
112 | * Get a collection of players. |
||
113 | * |
||
114 | * @param string $ids |
||
115 | * @param string $type |
||
116 | * |
||
117 | * @return array |
||
118 | */ |
||
119 | 1 | public function getPlayers($ids, $type = 'playerIds') |
|
124 | |||
125 | /** |
||
126 | * Get a collection of teams. |
||
127 | * |
||
128 | * @param array $filter |
||
129 | * |
||
130 | * @return array |
||
131 | */ |
||
132 | public function getTeams($filter) |
||
136 | |||
137 | /** |
||
138 | * Get Battlerite status. |
||
139 | * |
||
140 | * @return array |
||
141 | */ |
||
142 | 1 | public function getStatus() |
|
146 | |||
147 | public function getTelemetry() |
||
154 | |||
155 | /** |
||
156 | * Function to handle unexpected errors. |
||
157 | * |
||
158 | * @param RequestException $error |
||
159 | * |
||
160 | * @return void |
||
161 | */ |
||
162 | protected function statusCodeHandling($error) |
||
171 | } |
||
172 |