Skip to content

Commit

Permalink
fixup! Support for Italy PickupPoints
Browse files Browse the repository at this point in the history
  • Loading branch information
yekovalenkoa committed Feb 6, 2024
1 parent 5ea9532 commit 510ec1f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 18 deletions.
4 changes: 1 addition & 3 deletions src/Command/FindPoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Answear\InpostBundle\Client\Client;
use Answear\InpostBundle\Client\Serializer;
use Answear\InpostBundle\ConfigProvider;
use Answear\InpostBundle\Request\FindPointsRequest;
use Answear\InpostBundle\Response\FindPointsResponse;
use GuzzleHttp\Psr7\Request as HttpRequest;
Expand All @@ -18,7 +17,6 @@ class FindPoints extends AbstractCommand
private Serializer $serializer;

public function __construct(
private readonly ConfigProvider $configProvider,
Client $client,
Serializer $serializer,
) {
Expand All @@ -30,7 +28,7 @@ public function findPoints(FindPointsRequest $request): FindPointsResponse
{
$httpRequest = new HttpRequest(
$request->getMethod(),
new Uri($this->configProvider->apiVersion . $request->getRequestUrl()),
new Uri($request->getRequestUrl()),
[
'Content-type' => 'application/json',
],
Expand Down
9 changes: 3 additions & 6 deletions src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@

class ConfigProvider
{
private const BASE_URL = 'https://api-shipx-pl.easypack24.net/';
private const API_VERSION = 'v1';
private const BASE_URL = 'https://api-shipx-pl.easypack24.net/v1';

public function __construct(
public readonly string $baseUrl = self::BASE_URL,
public readonly string $apiVersion = self::API_VERSION,
) {
public function __construct(public readonly string $baseUrl = self::BASE_URL)
{
}
}
5 changes: 1 addition & 4 deletions src/DependencyInjection/AnswearInpostExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ public function load(array $configs, ContainerBuilder $container): void
$this->setConfig($container, $configs);

$definition = $container->getDefinition(ConfigProvider::class);
$definition->setArguments([
$this->config['baseUrl'],
$this->config['apiVersion'],
]);
$definition->setArguments([$this->config['baseUrl']]);
}

private function setConfig(ContainerBuilder $container, array $configs): void
Expand Down
1 change: 0 additions & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public function getConfigTreeBuilder(): TreeBuilder
$treeBuilder->getRootNode()
->children()
?->scalarNode('baseUrl')->defaultNull()->end()
?->scalarNode('apiVersion')->defaultNull()->end()
?->end();

return $treeBuilder;
Expand Down
7 changes: 3 additions & 4 deletions tests/Integration/Command/FindPointsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class FindPointsTest extends TestCase
use MockGuzzleTrait;

private Client $client;
private ConfigProvider $configProvider;

private const POLAND = 'Poland';
private const ITALY = 'Italy';
Expand All @@ -35,8 +34,8 @@ public function setUp(): void
{
parent::setUp();

$this->configProvider = new ConfigProvider();
$this->client = new Client($this->configProvider, $this->setupGuzzleClient());
$configProvider = new ConfigProvider();
$this->client = new Client($configProvider, $this->setupGuzzleClient());
}

/**
Expand Down Expand Up @@ -169,7 +168,7 @@ public function successfulFindPointsItaly(): void

private function getCommand(): FindPoints
{
return new FindPoints($this->configProvider, $this->client, new Serializer());
return new FindPoints($this->client, new Serializer());
}

private function getSuccessfulBody(string $country): string
Expand Down

0 comments on commit 510ec1f

Please sign in to comment.