refactor(fer-19) : url de base unique pour le pont-bascule

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-21 13:59:25 +02:00
parent d6992aa549
commit 9c9cc2f252
4 changed files with 5 additions and 5 deletions

2
.env
View File

@@ -19,4 +19,4 @@ COOKIE_SECURE=
DATABASE_URL= DATABASE_URL=
PONT_BASCULE_BYPASS= PONT_BASCULE_BYPASS=
PONT_BASCULE_URL= PONT_BASCULE_BASE_URL=

View File

@@ -24,7 +24,7 @@ services:
App\Service\PontBasculeService: App\Service\PontBasculeService:
arguments: arguments:
$endpoint: '%env(PONT_BASCULE_URL)%' $baseUrl: '%env(PONT_BASCULE_BASE_URL)%'
$bypass: '%env(bool:PONT_BASCULE_BYPASS)%' $bypass: '%env(bool:PONT_BASCULE_BYPASS)%'
# add more service definitions when explicit configuration is needed # add more service definitions when explicit configuration is needed

View File

@@ -15,7 +15,7 @@ final class PontBasculeService
public function __construct( public function __construct(
private readonly HttpClientInterface $httpClient, private readonly HttpClientInterface $httpClient,
private readonly PontBasculePayloadDecoder $payloadDecoder, private readonly PontBasculePayloadDecoder $payloadDecoder,
private readonly string $endpoint, private readonly string $baseUrl,
private readonly bool $bypass, private readonly bool $bypass,
) {} ) {}
@@ -28,7 +28,7 @@ final class PontBasculeService
$body = $this->getBypassPayload(); $body = $this->getBypassPayload();
} else { } else {
try { try {
$response = $this->httpClient->request('POST', $this->endpoint); $response = $this->httpClient->request('POST', $this->baseUrl.'/send/dsd');
$body = $response->getContent(false); $body = $response->getContent(false);
} catch (TransportExceptionInterface $exception) { } catch (TransportExceptionInterface $exception) {
throw PontBasculeException::transportFailure($exception->getMessage()); throw PontBasculeException::transportFailure($exception->getMessage());

View File

@@ -47,7 +47,7 @@ final class PontBasculeServiceTest extends TestCase
$httpClient $httpClient
->expects(self::once()) ->expects(self::once())
->method('request') ->method('request')
->with('POST', 'http://example.test') ->with('POST', 'http://example.test/send/dsd')
->willReturn($response) ->willReturn($response)
; ;