Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 33 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| SeniorRequestImport | |
0.00% |
0 / 33 |
|
0.00% |
0 / 1 |
90 | |
0.00% |
0 / 1 |
| execute | |
0.00% |
0 / 33 |
|
0.00% |
0 / 1 |
90 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Domain\Shared\Integrations\Senior; |
| 4 | |
| 5 | use SoapFault; |
| 6 | use function __; |
| 7 | use function is_null; |
| 8 | |
| 9 | use Domain\StockIO\DTOs\SeniorSyncOutputRequestDTO; |
| 10 | use Domain\Shared\Integrations\Senior\Exceptions\IntegrationSoapSeniorException; |
| 11 | |
| 12 | class SeniorRequestImport extends SeniorImportBase |
| 13 | { |
| 14 | /** |
| 15 | * @param string|null $numEme |
| 16 | * @param int $limit |
| 17 | * @return array |
| 18 | * @throws IntegrationSoapSeniorException |
| 19 | */ |
| 20 | public function execute(string $numEme = null, int $limit = 200): array |
| 21 | { |
| 22 | $wsdlURI = config('integration.url') . '/sapiens_Synccom_senior_g5_co_mcm_est_requisicoes?wsdl'; |
| 23 | try { |
| 24 | $params = [ |
| 25 | 'codEmp' => 1, |
| 26 | 'codFil' => 1, |
| 27 | 'identificadorSistema' => 'SOELX', |
| 28 | 'quantidadeRegistros' => $limit, |
| 29 | 'tipoIntegracao' => 'T', |
| 30 | ]; |
| 31 | |
| 32 | |
| 33 | if ($numEme) { |
| 34 | $params['tipoIntegracao'] = 'E'; |
| 35 | $params['numEme'] = $numEme; |
| 36 | } |
| 37 | |
| 38 | $client = new SeniorSoapClient($wsdlURI, $this->options); |
| 39 | $response = $client->Exportar_6(config('integration.user'), config('integration.user_password'), 0, $params); |
| 40 | |
| 41 | if ((isset($response->erroExecucao) && !is_null($response->erroExecucao)) || $response->tipoRetorno != 1) { |
| 42 | throw new IntegrationSoapSeniorException( |
| 43 | __("Senior's SOAP request returned with an error: :message (:wsdl)", [ |
| 44 | 'message' => $response->erroExecucao, |
| 45 | 'wsdl' => $wsdlURI, |
| 46 | ]), |
| 47 | ); |
| 48 | } |
| 49 | |
| 50 | if (!isset($response->requisicao) || is_null($response->requisicao)) { |
| 51 | return []; |
| 52 | } |
| 53 | |
| 54 | return is_array($response->requisicao) |
| 55 | ? $response->requisicao |
| 56 | : [$response->requisicao]; |
| 57 | |
| 58 | } catch (SoapFault $soapFault) { |
| 59 | throw new IntegrationSoapSeniorException( |
| 60 | __("Failure to consume Senior's soap: :message (:wsdl)", [ |
| 61 | 'message' => $soapFault->getMessage(), |
| 62 | 'wsdl' => $wsdlURI, |
| 63 | ]), |
| 64 | previous: $soapFault |
| 65 | ); |
| 66 | } |
| 67 | } |
| 68 | } |