Passed
Pull Request — feature/ECO-948-renaming-and-r... (#7)
by Andrey
04:36 queued 01:50
created

ObtainProfileInformationAdapter::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Apache OSL-2
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\AmazonPay\Business\Api\Adapter;
9
10
use Generated\Shared\Transfer\AmazonpayCallTransfer;
11
use PayWithAmazon\ClientInterface;
12
use SprykerEco\Zed\AmazonPay\Business\Api\Converter\ArrayConverterInterface;
13
14
class ObtainProfileInformationAdapter implements CallAdapterInterface
15
{
16
    /**
17
     * @var \PayWithAmazon\ClientInterface
18
     */
19
    protected $client;
20
21
    /**
22
     * @var \SprykerEco\Zed\AmazonPay\Business\Api\Converter\ArrayConverterInterface
23
     */
24
    protected $converter;
25
26
    /**
27
     * @param \PayWithAmazon\ClientInterface $client
28
     * @param \SprykerEco\Zed\AmazonPay\Business\Api\Converter\ArrayConverterInterface $converter
29
     */
30
    public function __construct(
31
        ClientInterface $client,
32
        ArrayConverterInterface $converter
33
    ) {
34
        $this->client = $client;
35
        $this->converter = $converter;
36
    }
37
38
    /**
39
     * @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonpayCallTransfer
40
     *
41
     * @return \Generated\Shared\Transfer\AmazonpayResponseTransfer
42
     */
43
    public function call(AmazonpayCallTransfer $amazonpayCallTransfer)
44
    {
45
        $result = $this->client->getUserInfo($amazonpayCallTransfer->getAmazonpayPayment()->getAddressConsentToken());
46
47
        $responseTransfer = $this->converter->convert($result);
48
        $responseTransfer->getCustomer()->setIsGuest(true);
49
50
        return $responseTransfer;
51
    }
52
}
53