Passed
Pull Request — master (#45)
by
unknown
03:36
created

InitPayPalExpressConverter   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 39
c 1
b 0
f 0
dl 0
loc 50
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createResponseTransfer() 0 42 1
1
<?php
2
3
/**
4
 * MIT License
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Yves\Computop\Converter;
9
10
use Generated\Shared\Transfer\ComputopApiResponseHeaderTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...iResponseHeaderTransfer 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\ComputopPayPalExpressInitResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...essInitResponseTransfer 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 Spryker\Shared\Kernel\Transfer\TransferInterface;
13
use SprykerEco\Shared\Computop\Config\ComputopApiConfig;
14
15
class InitPayPalExpressConverter extends AbstractInitConverter
16
{
17
    /**
18
     * @param array $responseParamsArray
19
     * @param \Generated\Shared\Transfer\ComputopApiResponseHeaderTransfer $header
20
     *
21
     * @return \Spryker\Shared\Kernel\Transfer\TransferInterface
22
     */
23
    protected function createResponseTransfer(array $responseParamsArray, ComputopApiResponseHeaderTransfer $header): TransferInterface
24
    {
25
        $responseTransfer = new ComputopPayPalExpressInitResponseTransfer();
26
        $responseTransfer->fromArray($responseParamsArray, true);
27
        $responseTransfer->setHeader($header);
28
        $responseTransfer->setEmail($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::EMAIL));
29
        $responseTransfer->setFirstName($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::FIRST_NAME));
30
        $responseTransfer->setLastName($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::LAST_NAME));
31
        //optional fields
32
        $responseTransfer->setTransactionId($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::TRANSACTION_ID));
33
        $responseTransfer->setRefNr($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::REF_NR));
34
        $responseTransfer->setInfoText($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::INFO_TEXT));
35
        $responseTransfer->setBillingAgreementId($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::BILLING_AGREEMENT_ID));
36
        $responseTransfer->setPhone($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::PHONE));
37
        $responseTransfer->setAddressCountryCode($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::ADDRESS_COUNTRY_CODE));
38
        $responseTransfer->setAddressStreet($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::ADDRESS_STREET));
39
        $responseTransfer->setAddressStreet2($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::ADDRESS_STREET2));
40
        $responseTransfer->setAddressCity($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::ADDRESS_CITY));
41
        $responseTransfer->setAddressState($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::ADDRESS_STATE));
42
        $responseTransfer->setAddressZip($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::ADDRESS_ZIP));
43
        $responseTransfer->setBillingAddressCity($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::BILLING_ADDRESS_CITY));
44
        $responseTransfer->setBillingAddressCountryCode($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::BILLING_ADDRESS_COUNTRY_CODE));
45
        $responseTransfer->setBillingAddressState($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::BILLING_ADDRESS_STATE));
46
        $responseTransfer->setBillingAddressStreet($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::BILLING_ADDRESS_STREET));
47
        $responseTransfer->setBillingAddressStreet2($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::BILLING_ADDRESS_STREET2));
48
        $responseTransfer->setBillingAddressZip($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::BILLING_ADDRESS_ZIP));
49
        $responseTransfer->setBillingName($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::BILLING_NAME));
50
        $responseTransfer->setPayerId($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::PAYER_ID));
51
        $responseTransfer->setIsFinancing($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::IS_FINANCING));
52
        $responseTransfer->setFinancingFeeAmount($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::FINANCING_FEE_AMOUNT));
53
        $responseTransfer->setFinancingMonthlyPayment($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::FINANCING_MONTHLY_PAYMENT));
54
        $responseTransfer->setFinancingTerm($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::FINANCING_TERM));
55
        $responseTransfer->setFinancingTotalCost($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::FINANCING_TOTAL_COST));
56
        $responseTransfer->setGrossAmount($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::GROSS_AMOUNT));
57
        $responseTransfer->setFeeAmount($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::FEE_AMOUNT));
58
        $responseTransfer->setSettleAmount($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::SETTLE_AMOUNT));
59
        $responseTransfer->setTaxAmount($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::TAX_AMOUNT));
60
        $responseTransfer->setExchangeRate($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::EXCHANGE_RATE));
61
        $responseTransfer->setMcFee($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::MC_FEE));
62
        $responseTransfer->setMcGross($this->computopApiService->getResponseValue($responseParamsArray, ComputopApiConfig::MC_GROSS));
63
64
        return $responseTransfer;
65
    }
66
}
67