| 1 |
lars |
1 |
<?php
|
|
|
2 |
/*******************************************************************************
|
|
|
3 |
* Copyright 2011 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
5 |
*
|
|
|
6 |
* You may not use this file except in compliance with the License.
|
|
|
7 |
* You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
|
|
|
8 |
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
|
9 |
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
|
10 |
* specific language governing permissions and limitations under the License.
|
|
|
11 |
* *****************************************************************************
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
/**
|
|
|
16 |
* @see CheckoutByAmazon_Service_Model
|
|
|
17 |
*/
|
|
|
18 |
require_once ('CheckoutByAmazon/Service/Model.php');
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
/**
|
|
|
23 |
* CheckoutByAmazon_Service_Model_ItemList
|
|
|
24 |
*
|
|
|
25 |
* Properties:
|
|
|
26 |
* <ul>
|
|
|
27 |
*
|
|
|
28 |
* <li>PurchaseItem: CheckoutByAmazon_Service_Model_PurchaseItem</li>
|
|
|
29 |
*
|
|
|
30 |
* </ul>
|
|
|
31 |
*/
|
|
|
32 |
class CheckoutByAmazon_Service_Model_ItemList extends CheckoutByAmazon_Service_Model
|
|
|
33 |
{
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
/**
|
|
|
37 |
* Construct new CheckoutByAmazon_Service_Model_ItemList
|
|
|
38 |
*
|
|
|
39 |
* @param mixed $data DOMElement or Associative Array to construct from.
|
|
|
40 |
*
|
|
|
41 |
* Valid properties:
|
|
|
42 |
* <ul>
|
|
|
43 |
*
|
|
|
44 |
* <li>PurchaseItem: CheckoutByAmazon_Service_Model_PurchaseItem</li>
|
|
|
45 |
*
|
|
|
46 |
* </ul>
|
|
|
47 |
*/
|
|
|
48 |
public function __construct($data = null)
|
|
|
49 |
{
|
|
|
50 |
$this->_fields = array (
|
|
|
51 |
'PurchaseItem' => array('FieldValue' => array(), 'FieldType' => array('CheckoutByAmazon_Service_Model_PurchaseItem')),
|
|
|
52 |
);
|
|
|
53 |
parent::__construct($data);
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
/**
|
|
|
57 |
* Gets the value of the PurchaseItem.
|
|
|
58 |
*
|
|
|
59 |
* @return array of PurchaseItem PurchaseItem
|
|
|
60 |
*/
|
|
|
61 |
public function getPurchaseItem()
|
|
|
62 |
{
|
|
|
63 |
return $this->_fields['PurchaseItem']['FieldValue'];
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
/**
|
|
|
67 |
* Sets the value of the PurchaseItem.
|
|
|
68 |
*
|
|
|
69 |
* @param mixed PurchaseItem or an array of PurchaseItem PurchaseItem
|
|
|
70 |
* @return this instance
|
|
|
71 |
*/
|
|
|
72 |
public function setPurchaseItem($purchaseItem)
|
|
|
73 |
{
|
|
|
74 |
if (!$this->_isNumericArray($purchaseItem)) {
|
|
|
75 |
$purchaseItem = array ($purchaseItem);
|
|
|
76 |
}
|
|
|
77 |
$this->_fields['PurchaseItem']['FieldValue'] = $purchaseItem;
|
|
|
78 |
return $this;
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
/**
|
|
|
82 |
* Checks if PurchaseItem list is non-empty
|
|
|
83 |
*
|
|
|
84 |
* @return bool true if PurchaseItem list is non-empty
|
|
|
85 |
*/
|
|
|
86 |
public function isSetPurchaseItem()
|
|
|
87 |
{
|
|
|
88 |
return count ($this->_fields['PurchaseItem']['FieldValue']) > 0;
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
//Akhil
|
|
|
92 |
/**
|
|
|
93 |
* Sets the value of the PurchaseItem with merchantItemId.
|
|
|
94 |
*
|
|
|
95 |
* @param mixed PurchaseItem or an array of PurchaseItem PurchaseItem
|
|
|
96 |
* @return this instance
|
|
|
97 |
*/
|
|
|
98 |
public function setPurchaseItemWithMerchantItemId($purchaseItem,$merchantItemID)
|
|
|
99 |
{
|
|
|
100 |
$this->_fields['PurchaseItem']['FieldValue'][$merchantItemID] = $purchaseItem;
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
/**
|
|
|
104 |
* Gets the value of the PurchaseItem when merchantItemId is given.
|
|
|
105 |
*
|
|
|
106 |
* @return array of PurchaseItem PurchaseItem
|
|
|
107 |
*/
|
|
|
108 |
public function getpurchaseItemWithMerchantItemId($merchantItemID)
|
|
|
109 |
{
|
|
|
110 |
return $this->_fields['PurchaseItem']['FieldValue'][$merchantItemID];
|
|
|
111 |
}
|
|
|
112 |
//Akhil
|
|
|
113 |
/**
|
|
|
114 |
* Checks if PurchaseItem list is non-empty for merchantItemId
|
|
|
115 |
*
|
|
|
116 |
* @return bool true if PurchaseItem list is non-empty
|
|
|
117 |
*/
|
|
|
118 |
public function isSetPurchaseItemWithMerchantItemId($merchantItemID)
|
|
|
119 |
{
|
|
|
120 |
return count ($this->_fields['PurchaseItem']['FieldValue'][$merchantItemID]) > 0;
|
|
|
121 |
}
|
|
|
122 |
|
|
|
123 |
/**
|
|
|
124 |
* Add the item with merchantItemId as index
|
|
|
125 |
*
|
|
|
126 |
* @param mixed PurchaseItem or an array of PurchaseItem PurchaseItem
|
|
|
127 |
* @return this instance
|
|
|
128 |
*/
|
|
|
129 |
public function addItem($purchaseItem)
|
|
|
130 |
{
|
|
|
131 |
$merchantItemID = $purchaseItem->_fields['MerchantItemId']['FieldValue'];
|
|
|
132 |
$this->_fields['PurchaseItem']['FieldValue'][$merchantItemID] = $purchaseItem;
|
|
|
133 |
}
|
|
|
134 |
|
|
|
135 |
}
|
|
|
136 |
?>
|