Skip to content
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

Merged
merged 2 commits into from
Feb 6, 2024
Merged

Conversation

yekovalenkoa
Copy link
Contributor

No description provided.

@yekovalenkoa yekovalenkoa marked this pull request as ready for review February 1, 2024 08:43
@olekans olekans self-requested a review February 2, 2024 09:31
Base automatically changed from refactor-php-81 to develop February 2, 2024 09:38

class DeliveryItaly implements DeliveryCountryInterface
{
private const BASE_URL = 'https://api-it-local-points.easypack24.net/';
Copy link

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?

Copy link
Contributor Author

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

@yekovalenkoa yekovalenkoa marked this pull request as draft February 2, 2024 10:20
@yekovalenkoa yekovalenkoa force-pushed the add-italy-country branch 9 times, most recently from cd6baf3 to 744fec6 Compare February 2, 2024 13:54
@yekovalenkoa yekovalenkoa marked this pull request as ready for review February 2, 2024 14:30
phpstan.neon Outdated
-
message: '#.*Extension::processConfiguration.*#'
path: ./src/DependencyInjection
Copy link

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,
Copy link

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.

Copy link
Contributor Author

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

Copy link

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

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @olekans

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed :)

@@ -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()),
Copy link

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?

Comment on lines +21 to +48
if (!isset($operatingHours['customer'])) {
return $self;
}

if (!is_array($operatingHours['customer'])) {
return $self;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!isset($operatingHours['customer'])) {
return $self;
}
if (!is_array($operatingHours['customer'])) {
return $self;
}
if (!empty($operatingHours['customer'] ?? [])) {
return $self;
}

#whatever

Copy link
Contributor Author

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)})) {
Copy link

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.

Copy link
Contributor Author

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.

Copy link

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)}.

@yekovalenkoa yekovalenkoa force-pushed the add-italy-country branch 4 times, most recently from fd66bfb to bdb5f58 Compare February 4, 2024 09:20
@yekovalenkoa yekovalenkoa merged commit 8e12b06 into develop Feb 6, 2024
5 checks passed
@yekovalenkoa yekovalenkoa deleted the add-italy-country branch February 6, 2024 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants