SoapApiAdapter::performRiskCheck()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 21
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 6
Bugs 0 Features 0
Metric Value
cc 2
eloc 15
nc 2
nop 1
dl 0
loc 21
rs 9.7666
c 6
b 0
f 0
1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace SprykerEco\Zed\ArvatoRss\Business\Api\Adapter;
9
10
use Generated\Shared\Transfer\ArvatoRssRiskCheckRequestTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...iskCheckRequestTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Generated\Shared\Transfer\ArvatoRssRiskCheckResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...skCheckResponseTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Generated\Shared\Transfer\ArvatoRssStoreOrderRequestTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...oreOrderRequestTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use Generated\Shared\Transfer\ArvatoRssStoreOrderResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...reOrderResponseTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use SprykerEco\Zed\ArvatoRss\Business\Api\Exception\ArvatoRssRiskCheckApiException;
15
use SprykerEco\Zed\ArvatoRss\Business\Api\Exception\ArvatoRssStoreOrderApiException;
16
17
class SoapApiAdapter implements ApiAdapterInterface
18
{
19
    public const WSDL_PATH = __DIR__ . "/../Etc/risk-solution-services.v2.1.wsdl";
20
21
    /**
22
     * @var \SprykerEco\Zed\ArvatoRss\Business\Api\Adapter\AdapterFactoryInterface
23
     */
24
    protected $adapterFactory;
25
26
    /**
27
     * @param \SprykerEco\Zed\ArvatoRss\Business\Api\Adapter\AdapterFactoryInterface $adapterFactory
28
     */
29
    public function __construct(
30
        AdapterFactoryInterface $adapterFactory
31
    ) {
32
        $this->adapterFactory = $adapterFactory;
33
    }
34
35
    /**
36
     * @param \Generated\Shared\Transfer\ArvatoRssRiskCheckRequestTransfer $requestTransfer
37
     *
38
     * @return \Generated\Shared\Transfer\ArvatoRssRiskCheckResponseTransfer
39
     */
40
    public function performRiskCheck(ArvatoRssRiskCheckRequestTransfer $requestTransfer)
41
    {
42
        $params = $this->adapterFactory
43
            ->createRiskCheckRequestConverter()
44
            ->convert($requestTransfer);
45
        try {
46
            $result = $this->adapterFactory
47
                ->createRiskCheckCall()
48
                ->execute(
49
                    $requestTransfer->getIdentification(),
50
                    $params
51
                );
52
        } catch (ArvatoRssRiskCheckApiException $exception) {
53
            $responseTransfer = new ArvatoRssRiskCheckResponseTransfer();
54
            $responseTransfer->setIsError(true);
55
            $responseTransfer->setErrorMessage($exception->getMessage());
56
57
            return $responseTransfer;
58
        }
59
60
        return $this->adapterFactory->createRiskCheckResponseConverter()->convert($result);
61
    }
62
63
    /**
64
     * @param \Generated\Shared\Transfer\ArvatoRssStoreOrderRequestTransfer $requestTransfer
65
     *
66
     * @return \Generated\Shared\Transfer\ArvatoRssStoreOrderResponseTransfer
67
     */
68
    public function storeOrder(ArvatoRssStoreOrderRequestTransfer $requestTransfer)
69
    {
70
        $params = $this->adapterFactory
71
            ->createStoreOrderRequestConverter()
72
            ->convert($requestTransfer);
73
        try {
74
            $result = $this->adapterFactory
75
                ->createStoreOrderCall()
76
                ->execute(
77
                    $requestTransfer->getIdentification(),
78
                    $params
79
                );
80
        } catch (ArvatoRssStoreOrderApiException $exception) {
81
            $responseTransfer = new ArvatoRssStoreOrderResponseTransfer();
82
            $responseTransfer->setIsError(true);
83
            $responseTransfer->setErrorMessage($exception->getMessage());
84
85
            return $responseTransfer;
86
        }
87
88
        return $this->adapterFactory->createStoreOrderResponseConverter()->convert($result);
89
    }
90
}
91