Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 21
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
SeniorOriginsImport
0.00% covered (danger)
0.00%
0 / 21
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 / 21
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\Product\DTOs\SeniorOriginsProductsDTO;
7use SoapFault;
8use function __;
9use function is_null;
10
11class SeniorOriginsImport extends SeniorImportBase
12{
13    /**
14     * @param SeniorOriginsProductsDTO $seniorOriginsProductsDTO
15     * @return array
16     * @throws IntegrationSoapSeniorException
17     */
18    public function execute(SeniorOriginsProductsDTO $seniorOriginsProductsDTO, int $offset = 0, int $limit = 1000): array
19    {
20        $wsdlURI = config('integration.url') . '/sapiens_Synccom_br_Soelx_Produtos?wsdl';
21
22        try {
23            $params = [
24                'codEmp' => $seniorOriginsProductsDTO->codemp,
25                'codOri' => $seniorOriginsProductsDTO->codori,
26                'offSet' => $offset,
27                'limit'  => $limit
28            ];
29
30            $client = new SeniorSoapClient($wsdlURI, $this->options);
31            $response = $client->ListarOrigens(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            return $this->convertBase64InArray($response->jsonOutput);
40
41        } catch (SoapFault $soapFault) {
42            throw new IntegrationSoapSeniorException(
43                __("Failure to consume Senior's soap: :message (:wsdl)", [
44                    'message' => $soapFault->getMessage(),
45                    'wsdl' => $wsdlURI,
46                ]),
47                previous: $soapFault
48            );
49        }
50    }
51}