/** * Flushes the buffer by POSTing the stats in JSON format to Stat Hat. */ public function postBatch() { foreach ($this->buffer as $ezKey => $stats) { if (!empty($stats)) { $params = ['ezkey' => $ezKey, 'data' => $stats]; $isPosted = $this->client->post('/ez', $params, 'application/json'); if ($isPosted) { $this->resetBuffer($ezKey); } } } }
/** * Flushes the buffer by POSTing the stats in JSON format to Stat Hat. */ public function postBatch() { if ($this->hasStats()) { foreach ($this->buffer['counters'] as $params) { $this->client->post('/c', $params); } foreach ($this->buffer['values'] as $params) { $this->client->post('/v', $params); } $this->resetBuffer(); } }
/** * Performs http GET request. * @param string $url * @throws \LogicException when no http client attached to provider. * @throws \Exception when any http client exception occuried. * @return string */ protected function httpRequest($url) { if (!($http = $this->getHttpClient())) { throw new \LogicException('No http client defined.'); } return $this->httpClient->get($url); }
/** * Gets the list of available assets * * @return response * @throws \Exception */ public function getAssetList() { $params = array(); try { return $this->client->sendRequest('assets', $params, 'GET'); } catch (\Exception $ex) { throw $ex; } }