@@ -19,7 +19,7 @@ |
||
19 | 19 | * <http://www.gnu.org/licenses/lgpl.html>. |
20 | 20 | */ |
21 | 21 | |
22 | - namespace apigatewaycl\api_client; |
|
22 | + namespace apigatewaycl\api_client; |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * Cliente de la API de API Gateway. |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | throw new ApiException('No hay una respuesta HTTP previa para obtener el cuerpo.'); |
148 | 148 | } |
149 | 149 | |
150 | - return (string)$this->last_response->getBody(); |
|
150 | + return (string) $this->last_response->getBody(); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | $decodedBody = json_decode($body, true); |
168 | 168 | |
169 | 169 | if (json_last_error() !== JSON_ERROR_NONE) { |
170 | - throw new ApiException('Error al decodificar JSON: ' . json_last_error_msg()); |
|
170 | + throw new ApiException('Error al decodificar JSON: '.json_last_error_msg()); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | return $decodedBody; |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | } elseif (!empty($body['exception'])) { |
217 | 217 | $body = $this->getError()->message; |
218 | 218 | } else { |
219 | - $body = 'Error no determinado: ' . json_encode($body); |
|
219 | + $body = 'Error no determinado: '.json_encode($body); |
|
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
@@ -307,11 +307,11 @@ discard block |
||
307 | 307 | } |
308 | 308 | $method = $method ?: ($data ? 'POST' : 'GET'); |
309 | 309 | $client = new \GuzzleHttp\Client(); |
310 | - $this->last_url = $this->api_url . $this->api_prefix . '/'. $this->api_version . $resource; |
|
310 | + $this->last_url = $this->api_url.$this->api_prefix.'/'.$this->api_version.$resource; |
|
311 | 311 | |
312 | 312 | // preparar cabeceras que se usarán |
313 | 313 | $options[\GuzzleHttp\RequestOptions::HEADERS] = array_merge([ |
314 | - 'Authorization' => 'Bearer ' . $this->api_token, |
|
314 | + 'Authorization' => 'Bearer '.$this->api_token, |
|
315 | 315 | 'Content-Type' => 'application/json', |
316 | 316 | 'Accept' => 'application/json', |
317 | 317 | ], $headers); |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | |
327 | 327 | // Forzar el valor de auth_cache en la llamada a la API. |
328 | 328 | $this->last_url = $this->forceUrlParams($this->last_url, [ |
329 | - 'auth_cache' => (int)$auth_cache, |
|
329 | + 'auth_cache' => (int) $auth_cache, |
|
330 | 330 | ]); |
331 | 331 | |
332 | 332 | // Ejecutar consulta al SII. |
@@ -383,12 +383,12 @@ discard block |
||
383 | 383 | $parsedUrl['query'] = http_build_query($queryParams); |
384 | 384 | |
385 | 385 | // Reconstruir y devolver la URL completa. |
386 | - return (isset($parsedUrl['scheme']) ? "{$parsedUrl['scheme']}://" : '') . |
|
387 | - (isset($parsedUrl['user']) ? "{$parsedUrl['user']}" . (isset($parsedUrl['pass']) ? ":{$parsedUrl['pass']}" : '') .'@' : '') . |
|
388 | - (isset($parsedUrl['host']) ? "{$parsedUrl['host']}" : '') . |
|
389 | - (isset($parsedUrl['port']) ? ":{$parsedUrl['port']}" : '') . |
|
390 | - (isset($parsedUrl['path']) ? "{$parsedUrl['path']}" : '') . |
|
391 | - (isset($parsedUrl['query']) ? "?{$parsedUrl['query']}" : '') . |
|
386 | + return (isset($parsedUrl['scheme']) ? "{$parsedUrl['scheme']}://" : ''). |
|
387 | + (isset($parsedUrl['user']) ? "{$parsedUrl['user']}".(isset($parsedUrl['pass']) ? ":{$parsedUrl['pass']}" : '').'@' : ''). |
|
388 | + (isset($parsedUrl['host']) ? "{$parsedUrl['host']}" : ''). |
|
389 | + (isset($parsedUrl['port']) ? ":{$parsedUrl['port']}" : ''). |
|
390 | + (isset($parsedUrl['path']) ? "{$parsedUrl['path']}" : ''). |
|
391 | + (isset($parsedUrl['query']) ? "?{$parsedUrl['query']}" : ''). |
|
392 | 392 | (isset($parsedUrl['fragment']) ? "#{$parsedUrl['fragment']}" : '') |
393 | 393 | ; |
394 | 394 | } |
@@ -419,10 +419,10 @@ discard block |
||
419 | 419 | |
420 | 420 | // Se maneja el caso donde no se encuentra un mensaje de error específico |
421 | 421 | if (!$message || $message === '') { |
422 | - $message = '[API Gateway] Código HTTP ' . $code . ': ' . $reasonPhrase; |
|
422 | + $message = '[API Gateway] Código HTTP '.$code.': '.$reasonPhrase; |
|
423 | 423 | } |
424 | 424 | |
425 | - return (object)[ |
|
425 | + return (object) [ |
|
426 | 426 | 'code' => $code, |
427 | 427 | 'message' => $message, |
428 | 428 | ]; |