From aaaf73d19436d1ef3eeef9816c47cc093c2b0b48 Mon Sep 17 00:00:00 2001 From: Giancarlos Salas Date: Tue, 17 Oct 2023 07:25:35 -0500 Subject: [PATCH 1/4] Update endpoint --- src/Peru/Jne/Endpoints.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Peru/Jne/Endpoints.php b/src/Peru/Jne/Endpoints.php index 28d0807..721ee7c 100644 --- a/src/Peru/Jne/Endpoints.php +++ b/src/Peru/Jne/Endpoints.php @@ -6,5 +6,5 @@ final class Endpoints { - public const CONSULT = 'https://ww1.sunat.gob.pe/ol-ti-itatencionf5030/registro/solicitante?tipDocu=1&numDocu=%s&tipPers=1'; + public const CONSULT = 'https://ww1.sunat.gob.pe/ol-ti-itatencionf5030/registro/solicitante'; } From cafe401fce036c84cd6f930dda3bc21cd40cb0bb Mon Sep 17 00:00:00 2001 From: Giancarlos Salas Date: Tue, 17 Oct 2023 07:25:53 -0500 Subject: [PATCH 2/4] Change content-type --- src/Peru/Jne/Dni.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Peru/Jne/Dni.php b/src/Peru/Jne/Dni.php index 3460d25..e738e5f 100644 --- a/src/Peru/Jne/Dni.php +++ b/src/Peru/Jne/Dni.php @@ -56,8 +56,8 @@ public function setRequestToken(string $requestToken): void */ public function get(string $dni): ?Person { - $url = sprintf(Endpoints::CONSULT, $dni); - $json = $this->client->post($url, []); + $params = sprintf('{"tipDocu": "1", "numDocu": "%s", "tipPers":"1"}', $dni); + $json = $this->client->post(Endpoints::CONSULT, $params, ['Content-Type' => 'application/json']); if ($json === false || !($result = json_decode($json)) || !isset($result->nombreSoli)) { return null; From 917f2bf3af755930034949385dd1c1585d859868 Mon Sep 17 00:00:00 2001 From: Giancarlos Salas Date: Tue, 17 Oct 2023 07:29:20 -0500 Subject: [PATCH 3/4] Fix phpstan --- src/Peru/Jne/Dni.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Peru/Jne/Dni.php b/src/Peru/Jne/Dni.php index e738e5f..306e855 100644 --- a/src/Peru/Jne/Dni.php +++ b/src/Peru/Jne/Dni.php @@ -56,7 +56,7 @@ public function setRequestToken(string $requestToken): void */ public function get(string $dni): ?Person { - $params = sprintf('{"tipDocu": "1", "numDocu": "%s", "tipPers":"1"}', $dni); + $params = '{"tipDocu": "1", "numDocu": "'.$dni.'", "tipPers":"1"}'; $json = $this->client->post(Endpoints::CONSULT, $params, ['Content-Type' => 'application/json']); if ($json === false || !($result = json_decode($json)) || !isset($result->nombreSoli)) { From 014c74d529cb27127c485585a35bf4cd66a8a2d0 Mon Sep 17 00:00:00 2001 From: Giancarlos Salas Date: Tue, 17 Oct 2023 07:32:23 -0500 Subject: [PATCH 4/4] Fix warn --- src/Peru/Jne/Async/Dni.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Peru/Jne/Async/Dni.php b/src/Peru/Jne/Async/Dni.php index 56daee7..448b3a7 100644 --- a/src/Peru/Jne/Async/Dni.php +++ b/src/Peru/Jne/Async/Dni.php @@ -50,10 +50,10 @@ public function setRequestToken(string $requestToken): void */ public function get(string $dni): PromiseInterface { - $url = sprintf(Endpoints::CONSULT, $dni); + $params = '{"tipDocu": "1", "numDocu": "'.$dni.'", "tipPers":"1"}'; return $this->client - ->postAsync($url, null) + ->postAsync(Endpoints::CONSULT, $params, ['Content-Type' => 'application/json']) ->then(function ($json) use ($dni) { if ($json === false || !($result = json_decode($json)) || !isset($result->nombreSoli)) { return null;