Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 21
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
SeniorFamilyImport
0.00% covered (danger)
0.00%
0 / 21
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 1
 execute
0.00% covered (danger)
0.00%
0 / 21
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3namespace Domain\Shared\Integrations\Senior;
4
5use Domain\Shared\Integrations\Senior\Exceptions\IntegrationSoapSeniorException;
6use Domain\Product\DTOs\SeniorFamilyProductsDTO;
7use SoapFault;
8use function __;
9use function is_null;
10
11class SeniorFamilyImport extends SeniorImportBase
12{
13    /**
14     * @param SeniorFamilyProductsDTO $seniorFamilyProductsDTO
15     * @return array
16     * @throws IntegrationSoapSeniorException
17     */
18    public function execute(SeniorFamilyProductsDTO $seniorFamilyProductsDTO, int $offset = 0, int $limit = 1000): array
19    {
20        $wsdlURI = config('integration.url') . '/sapiens_Synccom_br_Soelx_Produtos?wsdl';
21
22        try {
23            $params = [
24                'codEmp' => $seniorFamilyProductsDTO->codemp,
25                'codFam' => $seniorFamilyProductsDTO->codfam,
26                'offSet' => $offset,
27                'limit'  => $limit
28            ];
29
30            $client = new SeniorSoapClient($wsdlURI, $this->options);
31            $response = $client->ListarFamilias(config('integration.user'), config('integration.user_password'), 0, $params);
32
33            $this->verifyErroFromSenior($response, $wsdlURI);
34
35            if (is_null($response->jsonOutput)) {
36                return [];
37            }
38
39            return $this->convertBase64InArray($response->jsonOutput);
40        } catch (SoapFault $soapFault) {
41            throw new IntegrationSoapSeniorException(
42                __("Failure to consume Senior's soap: :message (:wsdl)", [
43                    'message' => $soapFault->getMessage(),
44                    'wsdl' => $wsdlURI,
45                ]),
46                previous: $soapFault
47            );
48        }
49    }
50}