Skip to content

Commit

Permalink
Merge pull request nfephp-org#166 from laurocj/patch-7
Browse files Browse the repository at this point in the history
Ajusta consulta R4020
  • Loading branch information
robmachado authored Mar 20, 2024
2 parents fdb90a9 + ed37145 commit e9127ec
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -1144,23 +1144,23 @@ private static function urlR4020(stdClass $std): string
{
$required = [
'perapur' => '/^20([0-9][0-9])-(0[1-9]|1[0-2])$/',
'tpinscestab' => '/^(1|4)$/',
'nrinscestab' => '/^[0-9]{12}|[0-9]{14}$/',
'tpinscestab' => '/^(1|2|3)$/',
'nrinscestab' => '/^[0-9]{11}|[0-9]{14}$/',
];
$std = self::propertiesToLower($std);
if (!empty($std->cpfbenef)) {
$required['cpfbenef'] = '/^[0-9]{11}$/';
if (!empty($std->cnpjbenef)) {
$required['cnpjbenef'] = '/^[0-9]{14}$/';
}
$val = self::validateConsultData($required, $std);
if (!$val['status']) {
$message = implode("\n", $val['errors']);
throw new \RuntimeException('Campos foram passados com erro para a consulta. ' . $message);
}
$base = self::urlbase($std);
if (!empty($std->cpfbenef)) {
return "{$base}/{$std->perapur}/{$std->tpinscestab}/{$std->nrinscestab}/{$std->cpfbenef}";
if (!empty($std->cnpjbenef)) {
return "{$base}/{$std->perapur}/{$std->tpinscestab}/{$std->nrinscestab}/{$std->cnpjbenef}";
}
return "{$std->baseurl}/R4020/semCpfBeneficiario/{$std->tpinsc}/{$std->nrinsc}/{$std->perapur}"
return "{$std->baseurl}/R4020/semCnpjBeneficiario/{$std->tpinsc}/{$std->nrinsc}/{$std->perapur}"
. "/{$std->tpinscestab}/{$std->nrinscestab}";
}

Expand Down

0 comments on commit e9127ec

Please sign in to comment.