-
Notifications
You must be signed in to change notification settings - Fork 0
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
Added support for Italy parcel points #9
Conversation
fa80564
to
3c417b1
Compare
2221633
to
5adf2f0
Compare
|
||
class DeliveryItaly implements DeliveryCountryInterface | ||
{ | ||
private const BASE_URL = 'https://api-it-local-points.easypack24.net/'; |
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.
Consider saving the link in env and then you don't have to change the bundle every time a new market develops. Am I right that only the base url is different?
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 idea, let's use configProvider
cd6baf3
to
744fec6
Compare
phpstan.neon
Outdated
- | ||
message: '#.*Extension::processConfiguration.*#' | ||
path: ./src/DependencyInjection |
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 can add enter to clean the files from the red alert's as here
?ClientInterface $client = null, | ||
) { | ||
$this->client = $client ?? new GuzzleClient( | ||
[ | ||
'base_uri' => ConfigProvider::BASE_URL, | ||
'base_uri' => $this->configProvider->baseUrl, |
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.
API version can be included in base url? Since we have base url in env, we can change api version dynamically.
What I mean is removing the API version env variable.
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 my opinion, it is better to keep the version as a variable and not put it in base_url
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.
Any specific reason? :D
Take a look at the variables in env that end with _URL
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 agree with @olekans
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.
Changed :)
src/Command/FindPoints.php
Outdated
@@ -27,7 +30,7 @@ public function findPoints(FindPointsRequest $request): FindPointsResponse | |||
{ | |||
$httpRequest = new HttpRequest( | |||
$request->getMethod(), | |||
new Uri(ConfigProvider::API_VERSION . $request->getRequestUrl()), | |||
new Uri($this->configProvider->apiVersion . $request->getRequestUrl()), |
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.
Refers to the comment above ☝️ Then the API version does not need to be appended to every request. Am I right?
if (!isset($operatingHours['customer'])) { | ||
return $self; | ||
} | ||
|
||
if (!is_array($operatingHours['customer'])) { | ||
return $self; | ||
} |
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.
if (!isset($operatingHours['customer'])) { | |
return $self; | |
} | |
if (!is_array($operatingHours['customer'])) { | |
return $self; | |
} | |
if (!empty($operatingHours['customer'] ?? [])) { | |
return $self; | |
} |
#whatever
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 my opinion, the suggested code does not check whether a variable is an array
} | ||
|
||
foreach ($operatingHours['customer'] as $day => $hours) { | ||
if (isset($self->{strtolower($day)})) { |
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.
Please note that if the partner changes the API or naming convention, the data will be invalid or not parsed correctly.
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 a phenomenon that applies to every integration in the world and to every field in the response API, not just this specific case. For this reason, the partner provides us with a versioned API. So we trust the partner and at the same time we do not display this field if it is empty, verifying carefully a few lines back.
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.
Ok, but you have hardcoded the names of the days of the week.
Be careful with this because it is slippery: $self->{strtolower($day)}
.
fd66bfb
to
bdb5f58
Compare
bdb5f58
to
5ea9532
Compare
No description provided.