From abe6382ad3bce0716f31ac583178335bbfd4f389 Mon Sep 17 00:00:00 2001 From: minasm Date: Sun, 13 Oct 2024 21:24:37 +0100 Subject: [PATCH] Fix return type of getApiUri() method Updated `getApiUri` to return `string` and added proper type hinting for `get` method parameters. Included handling for `GuzzleException` to ensure better error management during HTTP requests. --- src/Api/EodClient.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Api/EodClient.php b/src/Api/EodClient.php index e4604b9..18fc347 100644 --- a/src/Api/EodClient.php +++ b/src/Api/EodClient.php @@ -2,6 +2,7 @@ namespace RadicalLoop\Eod\Api; +use GuzzleHttp\Exception\GuzzleException; use RadicalLoop\Eod\Config; use GuzzleHttp\Client as GuzzleHttpClient; @@ -45,9 +46,9 @@ public function __construct(Config $config) /** * get api uri * - * @return void + * @return string */ - public function getApiUri() + public function getApiUri(): string { return rtrim($this->config->getApiUrl(), '/') . $this->urlSegment; } @@ -55,11 +56,12 @@ public function getApiUri() /** * send request for api * - * @param string $symbol - * @param array $params + * @param string $symbol + * @param array $params * @return string|json + * @throws GuzzleException */ - public function get($symbol, $params = []) + public function get(string $symbol, array $params = []) { $segment = $symbol ? ('/' . $symbol) : ''; $httpQuery = http_build_query(array_merge($params, ['api_token' => $this->config->getApiToken()]));