| 368 | } |
| 369 | |
| 370 | private function getJsonData($url, $option) { |
| 371 | $headers = [ |
| 372 | 'User-Agent' => 'Analytics for Nextcloud', |
| 373 | 'Accept' => 'application/vnd.github.v3+json', |
| 374 | ]; |
| 375 | if (isset($option['token']) && $option['token'] !== '') { |
| 376 | $headers['Authorization'] = 'token ' . $option['token']; |
| 377 | } |
| 378 | $response = $this->httpClient->request($url, 'GET', $headers); |
| 379 | $data = json_decode($response['body'], true); |
| 380 | return [ |
| 381 | 'data' => is_array($data) ? $data : [], |
| 382 | 'http_code' => $response['status'], |
| 383 | 'request_error' => $response['error'], |
| 384 | ]; |
| 385 | } |
| 386 | |
| 387 | private function floatvalue($val) { |
| 388 | $val = str_replace(",", ".", $val); |