Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 23
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
SeniorPurchaseOrderImport
0.00% covered (danger)
0.00%
0 / 23
0.00% covered (danger)
0.00%
0 / 1
30
0.00% covered (danger)
0.00%
0 / 1
 execute
0.00% covered (danger)
0.00%
0 / 23
0.00% covered (danger)
0.00%
0 / 1
30
1<?php
2
3namespace Domain\Shared\Integrations\Senior;
4
5use Domain\Shared\Integrations\Senior\Exceptions\IntegrationSoapSeniorException;
6use Domain\PurchaseOrder\DTOs\SeniorPurchaseOrderImportDTO;
7use SoapFault;
8use function __;
9
10class SeniorPurchaseOrderImport 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(SeniorPurchaseOrderImportDTO $requestParams, int $offset = 0, int $limit = 1000): array
20    {
21        $wsdlURI = config('integration.url') . '/sapiens_Synccom_br_SoelX_ConferenciaNotasFiscaisEntrada?wsdl';
22        try {
23            $client = new SeniorSoapClient($wsdlURI, $this->options);
24
25            $params = [
26                "limit" => $limit,
27                "offSet" => $offset,
28            ];
29
30            if($requestParams){
31                $params = $params + $requestParams->toArray();
32            }
33
34            $response = $client->listarOrdensCompraViaNota(config('integration.user'), config('integration.user_password'), 0, $params);
35
36            $this->verifyErroFromSenior($response, $wsdlURI);
37
38            if(isset($response->ordensCompra)){
39                if(!is_array($response->ordensCompra))
40                {
41                    return [$response->ordensCompra] ?? [];
42                } else {
43                    return $response->ordensCompra ?? [];
44                }
45            } else {
46                return [];
47            }
48
49        } catch (SoapFault $soapFault) {
50            throw new IntegrationSoapSeniorException(
51                __("Failure to consume Senior's soap: :message (:wsdl)", [
52                    'message' => $soapFault->getMessage(),
53                    'wsdl' => $wsdlURI,
54                ]),
55                previous: $soapFault
56            );
57        }
58    }
59}