apigatewaycl /
apigateway-api-client-php
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | /** |
||
| 6 | * API Gateway: Cliente de API en PHP. |
||
| 7 | * Copyright (C) API Gateway <https://www.apigateway.cl> |
||
| 8 | * |
||
| 9 | * Este programa es software libre: usted puede redistribuirlo y/o modificarlo |
||
| 10 | * bajo los términos de la GNU Lesser General Public License (LGPL) publicada |
||
| 11 | * por la Fundación para el Software Libre, ya sea la versión 3 de la Licencia, |
||
| 12 | * o (a su elección) cualquier versión posterior de la misma. |
||
| 13 | * |
||
| 14 | * Este programa se distribuye con la esperanza de que sea útil, pero SIN |
||
| 15 | * GARANTÍA ALGUNA; ni siquiera la garantía implícita MERCANTIL o de APTITUD |
||
| 16 | * PARA UN PROPÓSITO DETERMINADO. Consulte los detalles de la GNU Lesser General |
||
| 17 | * Public License (LGPL) para obtener una información más detallada. |
||
| 18 | * |
||
| 19 | * Debería haber recibido una copia de la GNU Lesser General Public License |
||
| 20 | * (LGPL) junto a este programa. En caso contrario, consulte |
||
| 21 | * <http://www.gnu.org/licenses/lgpl.html>. |
||
| 22 | */ |
||
| 23 | |||
| 24 | namespace apigatewaycl\api_client\sii; |
||
| 25 | |||
| 26 | use Psr\Http\Message\ResponseInterface; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Módulo para consultas de DTEs recibidos al Portal MIPYME del SII. |
||
| 30 | * |
||
| 31 | * Para más información sobre la API, consulte la `documentación completa de DTEs |
||
| 32 | * recibidos en el Portal MIPYME <https://developers.apigateway.cl/#24456c78-2c1d-4e91-a0b3-450eab612e7e>`_. |
||
| 33 | * |
||
| 34 | * Cliente específico para gestionar DTE recibidos en el Portal Mipyme. |
||
| 35 | * Proporciona métodos para obtener documentos, PDF y XML de DTE recibidos. |
||
| 36 | */ |
||
| 37 | class PortalMipymeDteRecibidos extends PortalMiPymeDte |
||
| 38 | { |
||
| 39 | /** |
||
| 40 | * Obtiene documentos de DTE recibidos por un receptor. |
||
| 41 | * |
||
| 42 | * @param string $receptor RUT del receptor. |
||
| 43 | * @param array $filtros Filtros adicionales para la consulta. |
||
| 44 | * @return \Psr\Http\Message\ResponseInterface Documentos de DTE recibidos. |
||
| 45 | */ |
||
| 46 | public function obtenerDtesRecibidos( |
||
| 47 | string $receptor, |
||
| 48 | array $filtros = [] |
||
| 49 | ): ResponseInterface { |
||
| 50 | $url = sprintf( |
||
| 51 | '/sii/mipyme/recibidos/documentos/%s', |
||
| 52 | $receptor |
||
| 53 | ); |
||
| 54 | |||
| 55 | $body = [ |
||
| 56 | 'auth' => $this->getAuthPass(), |
||
| 57 | 'filtros' => $filtros, |
||
| 58 | ]; |
||
| 59 | $response = $this->post(resource: $url, data: $body); |
||
| 60 | return $response; |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * Obtiene el PDF de un DTE recibido. |
||
| 65 | * |
||
| 66 | * @param string $receptor RUT del receptor. |
||
| 67 | * @param string $emisor RUT del emisor. |
||
| 68 | * @param string $dte Tipo de DTE o código del DTE recibido si no se pasa folio. |
||
| 69 | * @param string $folio Número de folio del DTE (opcional). |
||
| 70 | * @return \Psr\Http\Message\ResponseInterface Contenido del PDF del DTE recibido. |
||
| 71 | */ |
||
| 72 | public function descargarPdfDteRecibido( |
||
| 73 | string $receptor, |
||
| 74 | string $emisor, |
||
| 75 | string $dte, |
||
| 76 | string $folio = null |
||
| 77 | ): ResponseInterface { |
||
| 78 | $url = $folio != null ? sprintf( |
||
|
0 ignored issues
–
show
|
|||
| 79 | '/sii/mipyme/recibidos/pdf/%s/%s/%s/%s', |
||
| 80 | $receptor, |
||
| 81 | $emisor, |
||
| 82 | $dte, |
||
| 83 | $folio |
||
| 84 | ) : sprintf( |
||
| 85 | '/sii/mipyme/recibidos/pdf/%s/%s/%s', |
||
| 86 | $receptor, |
||
| 87 | $emisor, |
||
| 88 | $dte, |
||
| 89 | ); |
||
| 90 | |||
| 91 | $body = [ |
||
| 92 | 'auth' => $this->getAuthPass(), |
||
| 93 | ]; |
||
| 94 | $response = $this->post(resource: $url, data: $body); |
||
| 95 | return $response; |
||
|
0 ignored issues
–
show
|
|||
| 96 | } |
||
| 97 | |||
| 98 | /** |
||
| 99 | * Obtiene el XML de un DTE recibido. |
||
| 100 | * |
||
| 101 | * @param string $receptor RUT del receptor. |
||
| 102 | * @param string $emisor RUT del emisor. |
||
| 103 | * @param string $dte Tipo de DTE. |
||
| 104 | * @param string $folio Número de folio del DTE. |
||
| 105 | * @return \Psr\Http\Message\ResponseInterface Contenido del XML del |
||
| 106 | * DTE recibido. |
||
| 107 | */ |
||
| 108 | public function descargarXmlDteRecibido( |
||
| 109 | string $receptor, |
||
| 110 | string $emisor, |
||
| 111 | string $dte, |
||
| 112 | string $folio |
||
| 113 | ): ResponseInterface { |
||
| 114 | $url = sprintf( |
||
| 115 | '/sii/mipyme/recibidos/xml/%s/%s/%s/%s', |
||
| 116 | $receptor, |
||
| 117 | $emisor, |
||
| 118 | $dte, |
||
| 119 | $folio |
||
| 120 | ); |
||
| 121 | |||
| 122 | $body = [ |
||
| 123 | 'auth' => $this->getAuthPass(), |
||
| 124 | ]; |
||
| 125 | $response = $this->post(resource: $url, data: $body); |
||
| 126 | return $response; |
||
|
0 ignored issues
–
show
|
|||
| 127 | } |
||
| 128 | } |
||
| 129 |