Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Fix consulta DNI #68

Merged
merged 4 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Peru/Jne/Async/Dni.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Peru/Jne/Dni.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '{"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)) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/Peru/Jne/Endpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}