Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
SeniorConversionImport
0.00% covered (danger)
0.00%
0 / 19
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 / 19
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3namespace Domain\Shared\Integrations\Senior;
4
5use Domain\Conversion\DTOs\SeniorConversionImportDTO;
6use Domain\Shared\Integrations\Senior\Exceptions\IntegrationSoapSeniorException;
7use SoapFault;
8use function __;
9
10class SeniorConversionImport extends SeniorImportBase
11{
12    /**
13     * @param string $query
14     * @param int $offset
15     * @param int $limit
16     * @return array
17     * @throws IntegrationSoapSeniorException
18     */
19    public function execute(SeniorConversionImportDTO $seniorConversionImportDTO, int $offset = 0, int $limit = 1000): array
20    {
21        $wsdlURI = config('integration.url') . '/sapiens_Synccom_br_Soelx_Produtos?wsdl';
22        try {
23            $client = new SeniorSoapClient($wsdlURI, $this->options);
24
25            $params = [
26                "limit"  => $limit,
27                "offSet" => $offset,
28            ];
29
30            if(!is_null($seniorConversionImportDTO->unimed)){
31                $params = $params + ['uniMed' => $seniorConversionImportDTO->unimed];
32            }
33
34            $response = $client->listarUnidadeMedidaConversao(config('integration.user'), config('integration.user_password'), 0, $params);
35
36            $this->verifyErroFromSenior($response, $wsdlURI);
37
38            return $this->convertBase64InArray($response->jsonOutput);
39
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}