-
Notifications
You must be signed in to change notification settings - Fork 523
Add Here Provider #844
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
Add Here Provider #844
Conversation
Nyholm
left a comment
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.
This looks great. Good job!
We just need to add some tests. It is integration tests. So you basically need to select an address and verify the result is as you expect.
When you run the tests (with your API key) some files in .cached_responses will be created. These should also be checked in to the repo.
You run the test simply by
cd src/Procider/Here
composer update
composer test
src/Provider/Here/CHANGELOG.md
Outdated
|
|
||
| The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release. | ||
|
|
||
| ## 4.0.0 |
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.
Lets do 1.0.0 for a new provider.
src/Provider/Here/Here.php
Outdated
| private $appCode = null; | ||
|
|
||
| /** | ||
| * @param HttpAdapterInterface $adapter An HTTP adapter. |
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.
This is wrong. This should be HttpClient
+ * @param string $apoCode An App code.
|
Thanks for making a PR @sheub! I've been needing this provider support for a while. |
|
So, if I skip the Ipv4 Test ($testIpv4 = false;) I get results: OK, but incomplete, skipped, or risky tests! |
src/Provider/Here/Here.php
Outdated
| * @param string $appId An App ID. | ||
| * @param string $apoCode An App code. | ||
| */ | ||
| public function __construct(HttpClient $client, $appId, $appCode) |
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.
I would typehint the $appId and appCode parameters as string. Than we can remove the exception in the constructor.
src/Provider/Here/LICENSE
Outdated
| @@ -0,0 +1,21 @@ | |||
| The MIT License (MIT) | |||
|
|
|||
| Copyright (c) 2011 — William Durand <william.durand1@gmail.com> | |||
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.
Maybe you want to change it to your name?
src/Provider/Here/Tests/HereTest.php
Outdated
| $provider = new Here( | ||
| $this->getMockedHttpClient( | ||
| '{ | ||
| "type": { |
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.
You should use spaces instead of tabs.
| use Http\Client\HttpClient; | ||
|
|
||
| /** | ||
| * @author Sébastien Barré <sebastien@sheub.eu> |
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.
In the Here class you annotate the class with info@zoestha.de and here with sebastien@sheub.eu. Is this intended or do you want to fix this?
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.
Thanks for the Review. I have corrected the Here Class.
|
Thank you. |
|
Hey there, |
|
Can anyone give me instructions on how to finalize this PR? In advance Thank you. |
|
Hey @sheub, the TravisCI checks must be passed. A failing PR can't get merged. |
|
Hey @Baachi, The errors from Travis are : But he integration tests passed when I run them at home with my credentials. I have commit all the files created in Tests/.cached_responses and I have added in phpunit.xml.dist I see also (at home) that when I rerun the I don't understand why Travis is not executing the tests on the ./cached_responses |
|
Hi, it seems that the files created in the ./cached_responses will get a different Hash code for each see: For that reason the tests is not run on the ./cached_responses. Any Idea? Thanks for your support. |
|
Hi @Nyholm , |
|
Hi @Nyholm , I could find out why the tests wouldn't run on the cached files. and only one apiKey is searched for and replaced in the body part of the cacheKey: public function sendRequest(RequestInterface $request)
{
$url = (string) $request->getUri();
$host = (string) $request->getUri()->getHost();
if (!empty($this->apiKey)) {
$url = str_replace($this->apiKey, '[apikey]', $url);
}
$file = sprintf('%s/%s_%s', $this->cacheDir, $host, sha1($url));
if (is_file($file) && is_readable($file)) {
return new Response(200, [], (new StreamFactory())->createStream(unserialize(file_get_contents($file))));
}
$response = $this->delegate->sendRequest($request);
file_put_contents($file, serialize($response->getBody()->getContents()));
return $response;
}I could get it work properly at home, but I had to (slightly) modify three files from
In a way that both the This solution is working, but it requires that the |
|
Hello @sheub , I didn't check in details but Google Maps provider also requires 2 parameters (ClientId and APIKey) ; so I guess it should also work with HERE without having to modify the Have a look at https://github.com/geocoder-php/Geocoder/blob/master/src/Provider/GoogleMaps/ |
|
I'll have a look, but I am using the Google Maps provider with only one key (GOOGLEMAP_API_KEY) |
|
Maybe someone could tell me if it is for sure possible to get the caching to work with the 2 Credential keys, before I spend some more hours on it. Thank you. |
…ys (appID and AppCode) of the Here Provider
…erseQuery and testReverseQueryWithNoResults
|
So, The TravisCI build have passed :). I still had to do an override of the class This override could be omitted simply by adding the variable to Geocoder\IntegrationTest\CachedResponseClient directly. This is a slight modification which would not change anything for the other providers. |
Nyholm
left a comment
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.
Great work!
Thanks for all the reviews and your work
| /** | ||
| * @var string | ||
| */ | ||
| private $appCode = null; |
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.
You do not need the = null
| ```bash | ||
| composer require geocoder-php/here-provider | ||
| ``` | ||
| ### Note |
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.
This line should be removed.
| composer require geocoder-php/here-provider | ||
| ``` | ||
| ### Note | ||
| ## App Id and App Code |
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.
Use ### instead of ##
| ## App Id and App Code | ||
| Get your Here credentials at https://developer.here.com/ | ||
|
|
||
| ## Language parameter |
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.
Use ### instead of ##
| * | ||
| * @author Sébastien Barré <sebastien@sheub.eu> override the provider-integration-tests: CachedResponseClient class | ||
| */ | ||
| class HereCachedResponseClient extends CachedResponseClient |
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.
Good
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.
This is the best solution I could think of. I suggest to modify the CachedResponseClient only if other providers also need this functionality.
|
I added some notes. These are just minors. I will merge this PR now and prepare the package. |
|
The package is added: https://packagist.org/packages/geocoder-php/here-provider You could improve your tests now when 1.1.0 is released of the integration tests. That version includes your PR. Let me know when I should tag version 1.0.0 of this new package. (Ie after you test it a little bit) |
* Add Here Provider * Rename here.php to Here.php * Update Here.php * Update HereAddress.php * Update Here.php * Update HereAddress.php * Update Here.php * Update Here.php * Review Corrections * + * @param string $appId An App ID. + * @param string $apoCode An App code. * Add Tests files * Add phpunit.xml.dist * Corrections after running tests * use{} * FIX IT! * Few Styles #844 * HereMaps->Here * .Some more tests * style * Build Test OK if $testIpv4 = false; * Update HereTest.php * Code review from Baachi * Update Here.php * Update Readme.md * updated Here_Test and cached_responses * Add <server name="HERE_APP_ID" value="YOUR_APP_ID" /> <server name="HERE_APP_CODE" value="YOUR_APP_CODE" /> * Update Readme.md * Reworking of the Tests with adjustments to fit the two Credentials keys (appID and AppCode) of the Here Provider * style-ci correction + override testGeocodeQueryWithNoResults, testReverseQuery and testReverseQueryWithNoResults * Styles * Update IntegrationTest.php * Correct the extends and the naming (to HereCachedResponseClient) * Remove Overriding file HereCachedResponseClient.php * update cached_responses * set provider-integration-tests requirement 1.1.0 * Update Readme.md * Update Readme.md * Update composer.json
Happy to contribute with the Here provider.