Skip to content

Commit cc02652

Browse files
committed
refactor(client): accept EnvironmentConfig and CertConfig in constructor
Signed-off-by: Vitor Mattos <vitor@php.rio>
1 parent cb0bb5e commit cc02652

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/Http/NfseClient.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace LibreCodeCoop\NfsePHP\Http;
99

10+
use LibreCodeCoop\NfsePHP\Config\CertConfig;
11+
use LibreCodeCoop\NfsePHP\Config\EnvironmentConfig;
1012
use LibreCodeCoop\NfsePHP\Contracts\NfseClientInterface;
1113
use LibreCodeCoop\NfsePHP\Contracts\SecretStoreInterface;
1214
use LibreCodeCoop\NfsePHP\Contracts\XmlSignerInterface;
@@ -25,25 +27,19 @@
2527
*
2628
* Communicates with the SEFIN gateway to issue, query, and cancel NFS-e.
2729
* All requests carry a signed DPS XML payload.
28-
*
29-
* Gateway sandbox base URL: https://hml.nfse.fazenda.gov.br/NFS-e/api/v1
30-
* Gateway production base URL: https://nfse.fazenda.gov.br/NFS-e/api/v1
3130
*/
3231
class NfseClient implements NfseClientInterface
3332
{
34-
private const BASE_URL_PROD = 'https://nfse.fazenda.gov.br/NFS-e/api/v1';
35-
private const BASE_URL_SANDBOX = 'https://hml.nfse.fazenda.gov.br/NFS-e/api/v1';
36-
3733
private readonly string $baseUrl;
3834
private readonly XmlSignerInterface $signer;
3935

4036
public function __construct(
37+
private readonly EnvironmentConfig $environment,
38+
private readonly CertConfig $cert,
4139
private readonly SecretStoreInterface $secretStore,
42-
private readonly bool $sandboxMode = false,
43-
?string $baseUrlOverride = null,
4440
?XmlSignerInterface $signer = null,
4541
) {
46-
$this->baseUrl = $baseUrlOverride ?? ($sandboxMode ? self::BASE_URL_SANDBOX : self::BASE_URL_PROD);
42+
$this->baseUrl = $environment->baseUrl;
4743
$this->signer = $signer ?? new DpsSigner($secretStore);
4844
}
4945

0 commit comments

Comments
 (0)