|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright (c) 2013-2014 eBay Enterprise, Inc. |
|
4
|
|
|
* |
|
5
|
|
|
* NOTICE OF LICENSE |
|
6
|
|
|
* |
|
7
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
|
8
|
|
|
* that is bundled with this package in the file LICENSE.md. |
|
9
|
|
|
* It is also available through the world-wide-web at this URL: |
|
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
|
11
|
|
|
* |
|
12
|
|
|
* @copyright Copyright (c) 2013-2014 eBay Enterprise, Inc. (http://www.ebayenterprise.com/) |
|
13
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
namespace eBayEnterprise\RetailOrderManagement\Payload\OrderEvents; |
|
17
|
|
|
|
|
18
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\IPayload; |
|
19
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\IPayloadMap; |
|
20
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\ISchemaValidator; |
|
21
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\IValidatorIterator; |
|
22
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\PayloadFactory; |
|
23
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\Payment\TAmount; |
|
24
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\TTopLevelPayload; |
|
25
|
|
|
use Psr\Log\LoggerInterface; |
|
26
|
|
|
use Psr\Log\NullLogger; |
|
27
|
|
|
|
|
28
|
|
|
class OrderCreditIssued implements IOrderCreditIssued |
|
29
|
|
|
{ |
|
30
|
|
|
use TTopLevelPayload, TOrderEvent, TCurrency, TLoyaltyProgramCustomer, TOrderItemContainer, TReturnSummary, TAmount; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @param IValidatorIterator |
|
34
|
|
|
* @param ISchemaValidator |
|
35
|
|
|
* @param IPayloadMap |
|
36
|
|
|
* @param LoggerInterface |
|
37
|
|
|
* @param IPayload |
|
38
|
|
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
39
|
|
|
*/ |
|
40
|
|
|
public function __construct( |
|
41
|
|
|
IValidatorIterator $validators, |
|
42
|
|
|
ISchemaValidator $schemaValidator, |
|
43
|
|
|
IPayloadMap $payloadMap, |
|
44
|
|
|
LoggerInterface $logger, |
|
45
|
|
|
IPayload $parentPayload = null |
|
46
|
|
|
) { |
|
47
|
|
|
$this->logger = $logger; |
|
|
|
|
|
|
48
|
|
|
$this->validators = $validators; |
|
49
|
|
|
$this->schemaValidator = $schemaValidator; |
|
50
|
|
|
$this->payloadMap = $payloadMap; |
|
51
|
|
|
$this->parentPayload = $parentPayload; |
|
52
|
|
|
$this->payloadFactory = new PayloadFactory(); |
|
53
|
|
|
|
|
54
|
|
|
$this->loyaltyPrograms = |
|
55
|
|
|
$this->buildPayloadForInterface(static::LOYALTY_PROGRAM_ITERABLE_INTERFACE); |
|
56
|
|
|
$this->orderItems = |
|
57
|
|
|
$this->buildPayloadForInterface(static::ORDER_ITEM_ITERABLE_INTERFACE); |
|
58
|
|
|
|
|
59
|
|
|
$this->extractionPaths = [ |
|
60
|
|
|
'storeId' => 'string(@storeId)', |
|
61
|
|
|
'currencyCode' => 'string(@currency)', |
|
62
|
|
|
'currencySymbol' => 'string(@currencySymbol)', |
|
63
|
|
|
'customerFirstName' => 'string(x:Customer/x:Name/x:FirstName)', |
|
64
|
|
|
'customerLastName' => 'string(x:Customer/x:Name/x:LastName)', |
|
65
|
|
|
'customerEmailAddress' => 'string(x:Customer/x:Name/x:EmailAddress)', |
|
66
|
|
|
'orderId' => 'string(@customerOrderId)', |
|
67
|
|
|
'returnOrCredit' => 'string(x:CreditIssuedSummary/@returnOrCreditIssued)', |
|
68
|
|
|
'referenceNumber' => 'string(x:CreditIssuedSummary/@creditRefNumber)', |
|
69
|
|
|
'totalCredit' => 'string(x:CreditIssuedSummary/@totalCredit)' |
|
70
|
|
|
]; |
|
71
|
|
|
|
|
72
|
|
|
$this->optionalExtractionPaths = [ |
|
73
|
|
|
'customerId' => 'x:Customer/@customerId', |
|
74
|
|
|
'customerMiddleName' => 'x:Customer/x:Name/x:MiddleName', |
|
75
|
|
|
'customerHonorificName' => 'x:Customer/x:Name/x:Honorific', |
|
76
|
|
|
'customerEmailAddress' => 'x:Customer/x:EmailAddress' |
|
77
|
|
|
]; |
|
78
|
|
|
|
|
79
|
|
|
$this->subpayloadExtractionPaths = [ |
|
80
|
|
|
'loyaltyPrograms' => 'x:Customer/x:LoyaltyPrograms', |
|
81
|
|
|
'orderItems' => 'x:AdjustedOrderItems' |
|
82
|
|
|
]; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
View Code Duplication |
protected function getRootAttributes() |
|
|
|
|
|
|
86
|
|
|
{ |
|
87
|
|
|
return [ |
|
88
|
|
|
'xmlns' => $this->getXmlNamespace(), |
|
89
|
|
|
'customerOrderId' => $this->getCustomerOrderId(), |
|
90
|
|
|
'storeId' => $this->getStoreId(), |
|
91
|
|
|
'currency' => $this->getCurrencyCode(), |
|
92
|
|
|
'currencySymbol' => $this->getCurrencySymbol() |
|
93
|
|
|
]; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
public function getEventType() |
|
97
|
|
|
{ |
|
98
|
|
|
return static::ROOT_NODE; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
protected function getSchemaFile() |
|
102
|
|
|
{ |
|
103
|
|
|
return $this->getSchemaDir() . self::XSD; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
protected function getXmlNamespace() |
|
107
|
|
|
{ |
|
108
|
|
|
return self::XML_NS; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
protected function getRootNodeName() |
|
112
|
|
|
{ |
|
113
|
|
|
return self::ROOT_NODE; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
protected function serializeContents() |
|
117
|
|
|
{ |
|
118
|
|
|
return $this->serializeCustomer() |
|
119
|
|
|
. $this->getOrderItems()->serialize() |
|
120
|
|
|
. $this->serializeOrderSummary(); |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
protected function serializeOrderSummary() |
|
124
|
|
|
{ |
|
125
|
|
|
$format = '<CreditIssuedSummary returnOrCreditIssued="%s" creditRefNumber="%s" totalCredit="%s"></CreditIssuedSummary>'; |
|
126
|
|
|
return sprintf( |
|
127
|
|
|
$format, |
|
128
|
|
|
$this->getReturnOrCredit(), |
|
129
|
|
|
$this->getReferenceNumber(), |
|
130
|
|
|
$this->formatAmount($this->getTotalCredit()) |
|
131
|
|
|
); |
|
132
|
|
|
} |
|
133
|
|
|
} |
|
134
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..