Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 25
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
SeniorPackaging
0.00% covered (danger)
0.00%
0 / 25
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 / 25
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 SeniorPackaging 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(int $offset = 0, int $limit = 1000): array
20    {
21        $wsdlURI = config('integration.url') . '/sapiens_synccom.br.soelx.embalagem?wsdl';
22        try {
23            $client = new SeniorSoapClient($wsdlURI, $this->options);
24            $queryArray = [
25                "ReturnType" => 0,
26                "columns" => [],
27                "table" => [],
28                "join" => [],
29                "where" => [],
30                "order" => [],
31                "limit" => $limit,
32                "offSet" => $offset,
33            ];
34            $response = $client->listar(config('integration.user'), config('integration.user_password'), 0, $queryArray);
35
36            $this->verifyErroFromSenior($response, $wsdlURI);
37
38            if (is_null($response->jsonOutput)) {
39                return [];
40            }
41
42            return $this->convertBase64InArray($response->jsonOutput);
43
44        } catch (SoapFault $soapFault) {
45            throw new IntegrationSoapSeniorException(
46                __("Failure to consume Senior's soap: :message (:wsdl)", [
47                    'message' => $soapFault->getMessage(),
48                    'wsdl' => $wsdlURI,
49                ]),
50                previous: $soapFault
51            );
52        }
53    }
54}