Skip to content

Commit a71ebe0

Browse files
makowskidclaude
andcommitted
Add makeGetRequest method for proper GET query parameter handling
This new method addresses a limitation in the existing makeRequest() method, which only properly handles POST requests with JSON or multipart data. The makeGetRequest() method: - Properly passes query parameters using Guzzle's 'query' option - Is specifically designed for utility endpoints that use GET requests - Maintains backward compatibility by not modifying existing methods - Follows the same pattern and conventions as makeRequest() Usage: $response = $this->makeGetRequest('/endpoint', ['param' => 'value']); This method is used by utility packages: - laravel-airports-database-flight-duration-calculator - laravel-web-scraping-api - laravel-skills-database-api - laravel-job-positions-api Also added branch alias for dev-master -> 1.1.x-dev to support local development with path repositories. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
1 parent af2dd49 commit a71ebe0

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,10 @@
2222
"email": "[email protected]"
2323
}
2424
],
25+
"extra": {
26+
"branch-alias": {
27+
"dev-master": "1.1.x-dev"
28+
}
29+
},
2530
"minimum-stability": "stable"
2631
}

src/Client/SharpApiClient.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,35 @@ protected function makeRequest(
222222
return $this->client->request($method, $this->getApiBaseUrl() . $url, $options);
223223
}
224224

225+
/**
226+
* Makes a GET request with proper query parameter handling.
227+
*
228+
* This method was added to properly support GET requests with query parameters
229+
* for utility endpoints (airports, web scraping, skills, job positions).
230+
* Unlike the generic makeRequest() method which only handles POST data,
231+
* this method correctly passes query parameters using Guzzle's 'query' option.
232+
*
233+
* @param string $url The API endpoint relative to the base URL.
234+
* @param array $queryParams Query parameters to append to the URL.
235+
* @return ResponseInterface The Guzzle response object.
236+
* @throws GuzzleException if the request fails.
237+
* @api
238+
*/
239+
protected function makeGetRequest(
240+
string $url,
241+
array $queryParams = []
242+
): ResponseInterface {
243+
$options = [
244+
'headers' => $this->getHeaders(),
245+
];
246+
247+
if (!empty($queryParams)) {
248+
$options['query'] = $queryParams;
249+
}
250+
251+
return $this->client->request('GET', $this->getApiBaseUrl() . $url, $options);
252+
}
253+
225254
/**
226255
* @param ResponseInterface $response
227256
* @return mixed

0 commit comments

Comments
 (0)