Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 23 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| SeniorRequestDeliveryExport | |
0.00% |
0 / 23 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
| execute | |
0.00% |
0 / 23 |
|
0.00% |
0 / 1 |
20 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Domain\Shared\Integrations\Senior; |
| 4 | |
| 5 | use SoapFault; |
| 6 | use function __; |
| 7 | |
| 8 | use Illuminate\Support\Facades\Auth; |
| 9 | |
| 10 | use Domain\Shared\Integrations\Senior\Exceptions\IntegrationSoapSeniorException; |
| 11 | |
| 12 | class SeniorRequestDeliveryExport extends SeniorImportBase |
| 13 | { |
| 14 | /** |
| 15 | * @param array $deliveries |
| 16 | * @return array |
| 17 | * @throws IntegrationSoapSeniorException |
| 18 | */ |
| 19 | public function execute(array $deliveries): array |
| 20 | { |
| 21 | $wsdlURI = config('integration.url') . '/sapiens_Synccom_br_soelx_MovimentoEstoque?wsdl'; |
| 22 | ['user' => $user, 'password' => $password] = (new SeniorCredentialResolver()) |
| 23 | ->resolveForAuthenticatedUser(Auth::user(), true); |
| 24 | |
| 25 | try { |
| 26 | $client = new SeniorSoapClient($wsdlURI, $this->options); |
| 27 | $response = $client->atenderRequisicoes( |
| 28 | $user, |
| 29 | $password, |
| 30 | 0, |
| 31 | $deliveries |
| 32 | ); |
| 33 | |
| 34 | if (isset($response->requisicoesResult)) { |
| 35 | return is_array($response->requisicoesResult) |
| 36 | ? $response->requisicoesResult |
| 37 | : [$response->requisicoesResult]; |
| 38 | } |
| 39 | |
| 40 | return []; |
| 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 | } |