Implement Coordinates by Location Name endpoint#189
Open
settermjd wants to merge 4 commits intocmfcmf:mainfrom
Open
Implement Coordinates by Location Name endpoint#189settermjd wants to merge 4 commits intocmfcmf:mainfrom
settermjd wants to merge 4 commits intocmfcmf:mainfrom
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.
cmfcmf
requested changes
Jun 11, 2024
Owner
cmfcmf
left a comment
There was a problem hiding this comment.
Thank you for this PR, I left a few comments.
Comment on lines
+288
to
+291
| $handlerStack = HandlerStack::create($mock); | ||
| $httpClient = new Client( | ||
| new GuzzleClient(['handler' => $handlerStack]) | ||
| ); |
Owner
There was a problem hiding this comment.
Can you use TestHttpClient from the tests folder instead of introducing a new dependency?
Comment on lines
+692
to
+702
| $cities[] = new City( | ||
| -1, | ||
| $datum->name, | ||
| $datum->lat, | ||
| $datum->lon, | ||
| $datum->country, | ||
| null, | ||
| null, | ||
| $datum->state, | ||
| (array)$datum->local_names | ||
| ); |
Owner
There was a problem hiding this comment.
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.