Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 15
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
SeniorPreOrderItensImport
0.00% covered (danger)
0.00%
0 / 15
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 / 15
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\StockIO\DTOs\SeniorPreOrderDTO;
7use SoapFault;
8use function __;
9use function is_null;
10
11class SeniorPreOrderItensImport extends SeniorImportBase
12{
13    /**
14     * @param SeniorPreOrderDTO $seniorPreOrderDTO
15     * @return array
16     * @throws IntegrationSoapSeniorException
17     */
18    public function execute($params): array
19    {
20        $wsdlURI = config('integration.url') . '/sapiens_Synccom_br_soelx_prefaturas?wsdl';
21
22        try {
23            $client = new SeniorSoapClient($wsdlURI, $this->options);
24            $response = $client->ListarItens(config('integration.user'), config('integration.user_password'), 0, $params);
25
26            $this->verifyErroFromSenior($response, $wsdlURI);
27
28            if (is_null($response->jsonOutput)) {
29                return [];
30            }
31
32            return $this->convertBase64InArray($response->jsonOutput);
33
34        } catch (SoapFault $soapFault) {
35            throw new IntegrationSoapSeniorException(
36                __("Failure to consume Senior's soap: :message (:wsdl)", [
37                    'message' => $soapFault->getMessage(),
38                    'wsdl' => $wsdlURI,
39                ]),
40                previous: $soapFault
41            );
42        }
43    }
44}