-
-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Coordinates by Location Name endpoint #189
base: main
Are you sure you want to change the base?
Implement Coordinates by Location Name endpoint #189
Conversation
This package is required, largely for testing, so that Guzzle requests can be mocked instead of making live calls to the API.
This is a simplistic implementation of the endpoint. It's not complete, yet, but it's a start. Its implementation is required to implement the one call API endpoint.
I didn't look deeply enough at Location previously to realise that City already extended it. Given that, this change effectively reverts the previous refactor of Location to put the changes where they should be, on City.
As the method's private, it can't be tested directly. However, that's not to say that it cannot be tested. So this test does that to ensure that the URL it returns is always correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this PR, I left a few comments.
$handlerStack = HandlerStack::create($mock); | ||
$httpClient = new Client( | ||
new GuzzleClient(['handler' => $handlerStack]) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use TestHttpClient
from the tests folder instead of introducing a new dependency?
$cities[] = new City( | ||
-1, | ||
$datum->name, | ||
$datum->lat, | ||
$datum->lon, | ||
$datum->country, | ||
null, | ||
null, | ||
$datum->state, | ||
(array)$datum->local_names | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you create a new City
class specifically for this API call? I don't like how the newly added fields are only used by this API, and how this API never sets some of the fields. Maybe call it Location
?
This PR implements the Coordinates by Location Name endpoint.
While working through the API docs and the library's documentation, I didn't see anything that queried this endpoint. Given that, and I was in need of it, I created this PR.