| 381 | } |
| 382 | |
| 383 | private function getJsonData($url, $option) { |
| 384 | $headers = [ |
| 385 | 'User-Agent' => 'Analytics for Nextcloud', |
| 386 | 'Accept' => 'application/vnd.github.v3+json', |
| 387 | ]; |
| 388 | if (isset($option['token']) && $option['token'] !== '') { |
| 389 | $headers['Authorization'] = 'token ' . $option['token']; |
| 390 | } |
| 391 | $response = $this->httpClient->request($url, 'GET', $headers); |
| 392 | $data = json_decode($response['body'], true); |
| 393 | return [ |
| 394 | 'data' => is_array($data) ? $data : [], |
| 395 | 'http_code' => $response['status'], |
| 396 | 'request_error' => $response['error'], |
| 397 | ]; |
| 398 | } |
| 399 | |
| 400 | private function floatvalue($val) { |
| 401 | $val = str_replace(",", ".", $val); |