Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 24 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| SeniorResourceCenterImport | |
0.00% |
0 / 24 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
| execute | |
0.00% |
0 / 24 |
|
0.00% |
0 / 1 |
20 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Domain\Shared\Integrations\Senior; |
| 4 | |
| 5 | use Domain\CostCenter\DTOs\SeniorResourceCenterImportDTO; |
| 6 | use SoapFault; |
| 7 | use function __; |
| 8 | |
| 9 | use Domain\Shared\Integrations\Senior\Exceptions\IntegrationSoapSeniorException; |
| 10 | |
| 11 | class SeniorResourceCenterImport extends SeniorImportBase |
| 12 | { |
| 13 | /** |
| 14 | * @param SeniorResourceCenterImportDTO $seniorCostCenterImportDTO |
| 15 | * @param string $lastDate |
| 16 | * @param int $offset |
| 17 | * @param int $limit |
| 18 | * @return array |
| 19 | * @throws IntegrationSoapSeniorException |
| 20 | */ |
| 21 | public function execute(SeniorResourceCenterImportDTO $seniorCostCenterImportDTO, string $lastDate, int $offset = 0, int $limit = 1000): array |
| 22 | { |
| 23 | $wsdlURI = config('integration.url') . '/sapiens_Synccom_br_Soelx_Manufatura?wsdl'; |
| 24 | try { |
| 25 | $client = new SeniorSoapClient($wsdlURI, $this->options); |
| 26 | |
| 27 | $params = [ |
| 28 | "codCre" => $seniorCostCenterImportDTO->codCre, |
| 29 | "codEmp" => $seniorCostCenterImportDTO->codEmp, |
| 30 | "datReg" => $lastDate, |
| 31 | "limit" => $limit, |
| 32 | "offset" => $offset |
| 33 | ]; |
| 34 | |
| 35 | $response = $client->ListarCentrosRecurso(config('integration.user'), config('integration.user_password'), 0, $params); |
| 36 | |
| 37 | $this->verifyErroFromSenior($response, $wsdlURI); |
| 38 | |
| 39 | if(isset($response->centrosRecurso)){ |
| 40 | return is_array($response->centrosRecurso) |
| 41 | ? $response->centrosRecurso |
| 42 | : [$response->centrosRecurso]; |
| 43 | } else { |
| 44 | return []; |
| 45 | } |
| 46 | |
| 47 | } catch (SoapFault $soapFault) { |
| 48 | throw new IntegrationSoapSeniorException( |
| 49 | __("Failure to consume Senior's soap: :message (:wsdl)", [ |
| 50 | 'message' => $soapFault->getMessage(), |
| 51 | 'wsdl' => $wsdlURI, |
| 52 | ]), |
| 53 | previous: $soapFault |
| 54 | ); |
| 55 | } |
| 56 | } |
| 57 | } |