Skip to content

Commit

Permalink
Add method to get multiple tax payers details
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanalemunioz committed Jan 21, 2021
1 parent f15170b commit 762df57
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/Class/RegisterScopeFive.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function GetTaxpayerDetails($identifier)
);

try {
return $this->ExecuteRequest('getPersona', $params);
return $this->ExecuteRequest('getPersona_v2', $params);
} catch (Exception $e) {
if (strpos($e->getMessage(), 'No existe') !== FALSE)
return NULL;
Expand All @@ -65,6 +65,27 @@ public function GetTaxpayerDetails($identifier)
}
}

/**
* Asks to web service for taxpayers details
*
* @throws Exception if exists an error in response
*
* @return [object] returns web service full response
**/
public function GetTaxpayersDetails($identifiers)
{
$ta = $this->afip->GetServiceTA('ws_sr_padron_a5');

$params = array(
'token' => $ta->token,
'sign' => $ta->sign,
'cuitRepresentada' => $this->afip->CUIT,
'idPersona' => $identifiers
);

return $this->ExecuteRequest('getPersonaList_v2', $params)->persona;
}

/**
* Sends request to AFIP servers
*
Expand All @@ -79,7 +100,10 @@ public function ExecuteRequest($operation, $params = array())
{
$results = parent::ExecuteRequest($operation, $params);

return $results->{$operation == 'getPersona' ? 'personaReturn' : 'return'};
return $results->{
$operation === 'getPersona_v2' ? 'personaReturn' :
($operation === 'getPersonaList_v2' ? 'personaListReturn': 'return')
};
}
}

0 comments on commit 762df57

Please sign in to comment.