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
SeniorUnitMeasurementImport
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\Shared\Integrations\Senior\Exceptions\IntegrationSoapSeniorException;
6use SoapFault;
7use function __;
8use function is_null;
9
10class SeniorUnitMeasurementImport extends SeniorImportBase
11{
12    /**
13     * @return array
14     * @throws IntegrationSoapSeniorException
15     */
16    public function execute(int $offset = 0, int $limit = 1000): array
17    {
18        $wsdlURI = config('integration.url') . '/sapiens_Synccom_br_Soelx_Produtos?wsdl';
19
20        try {
21            $params = [
22                'offSet' => $offset,
23                'limit' => $limit
24            ];
25
26            $client = new SeniorSoapClient($wsdlURI, $this->options);
27            $response = $client->ListarUnidadeMedidas(config('integration.user'), config('integration.user_password'), 0, $params);
28
29            $this->verifyErroFromSenior($response, $wsdlURI);
30
31            if (is_null($response->jsonOutput)) {
32                return [];
33            }
34
35            return $this->convertBase64InArray($response->jsonOutput);
36        } catch (SoapFault $soapFault) {
37            throw new IntegrationSoapSeniorException(
38                __("Failure to consume Senior's soap: :message (:wsdl)", [
39                    'message' => $soapFault->getMessage(),
40                    'wsdl' => $wsdlURI,
41                ]),
42                previous: $soapFault
43            );
44        }
45    }
46}