Skip to content

Commit

Permalink
Se agrega user-agent según estándar.
Browse files Browse the repository at this point in the history
  • Loading branch information
estebandelaf committed Dec 5, 2024
1 parent d65bf32 commit 3a452b9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
"symfony/cache": "^7.1",
"symfony/filesystem": "^7.1",
"symfony/mime": "^7.1",
"symfony/yaml": "^7.1",
"tecnickcom/tcpdf": "^6.7"
"symfony/yaml": "^7.1"
},
"require-dev": {
"ext-xdebug": "*",
Expand Down
5 changes: 0 additions & 5 deletions src/Sii/HttpClient/SiiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@ public function getDocumentValidator(): DocumentValidator
* Entrega una instancia con la implementación de una caché para ser
* utilizada en la biblioteca.
*
* NOTE: Este método a propósito tiene las clases con su FQCN y no utiliza
* los use. Esto es para que PHP no cargue las clases automáticamente a
* menos que realmente se vayan a utilizar. Pues en una situación normal,
* la caché debería ser inyectada y no usarse las opciones por defecto.
*
* @return CacheInterface Implementación de caché PSR-16.
*/
private function getCache(): CacheInterface
Expand Down
3 changes: 1 addition & 2 deletions src/Sii/HttpClient/WebService/DocumentUploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ private function uploadXml(array $data, int $retry): XmlDocument

// Cabeceras HTTP de la solicitud que se hará al SII.
$headers = [
'User-Agent: Mozilla/4.0 (compatible; PROG 1.0; LibreDTE)',
'Referer: https://www.libredte.cl',
'User-Agent: Mozilla/5.0 (compatible; PROG 1.0; +https://www.libredte.cl)',
'Cookie: TOKEN=' . $token,
];

Expand Down
6 changes: 3 additions & 3 deletions src/Sii/HttpClient/WsdlConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,9 @@ public function sendRequest(
?int $retry = null
): XmlDocument {
// Revisar si se pasó en $args el valor de $retry.
// @scrutinizer ignore-type-check
if (is_int($args)) {
$retry = (int) $args;
$retry = $args;
$args = [];
}

Expand Down Expand Up @@ -383,8 +384,7 @@ private function createSoapClientOptions(): array
'stream_context' => [
'http' => [
'header' => [
'User-Agent: Mozilla/4.0 (compatible; PROG 1.0; LibreDTE)',
'Referer: https://www.libredte.cl',
'User-Agent: Mozilla/5.0 (compatible; PROG 1.0; +https://www.libredte.cl)',
],
],
],
Expand Down
6 changes: 5 additions & 1 deletion src/Xml/XmlEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ public static function encode(
if ($key === '@attributes') {
// Solo se agregan atributos si el valor es un arreglo.
if (is_array($value)) {
self::nodeAddAttributes($parent, $value);
// En la primera iteración de recursividad se debe revisar
// que $parent sea DOMElement. Y solo en ese caso seguir.
if ($parent instanceof DOMElement) {
self::nodeAddAttributes($parent, $value);
}
}
}

Expand Down

0 comments on commit 3a452b9

Please sign in to comment.