Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 22
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
SeniorPreOrder
0.00% covered (danger)
0.00%
0 / 22
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 / 22
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;
10use function json_decode;
11
12class SeniorPreOrder extends SeniorImportBase
13{
14    /**
15     * @param SeniorPreOrderDTO $seniorPreOrderDTO
16     * @return array
17     * @throws IntegrationSoapSeniorException
18     */
19    public function execute(SeniorPreOrderDTO $seniorPreOrderDTO): array
20    {
21        $wsdlURI = config('integration.url') . '/sapiens_Synccom_br_soelx_prefaturas?wsdl';
22        try {
23            $params = [
24                'codEmp' => $seniorPreOrderDTO->codemp,
25                'codFil' => $seniorPreOrderDTO->codfil,
26                'numAne' => $seniorPreOrderDTO->numane,
27                'numPfa' => $seniorPreOrderDTO->numpfa,
28            ];
29
30            $client = new SeniorSoapClient($wsdlURI, $this->options);
31            $response = $client->ListarDetalhes(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            $json_decode = json_decode($response->jsonOutput, true);
40            return $json_decode ?? [];
41
42        } catch (SoapFault $soapFault) {
43            throw new IntegrationSoapSeniorException(
44                __("Failure to consume Senior's soap: :message (:wsdl)", [
45                    'message' => $soapFault->getMessage(),
46                    'wsdl' => $wsdlURI,
47                ]),
48                previous: $soapFault
49            );
50        }
51    }
52}