Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
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_ErrorResponse
24
 *
25
 * Properties:
26
 * <ul>
27
 *
28
 * <li>Error: CheckoutByAmazon_Service_Model_Error</li>
29
 * <li>RequestId: string</li>
30
 *
31
 * </ul>
32
 */
33
class CheckoutByAmazon_Service_Model_ErrorResponse extends CheckoutByAmazon_Service_Model
34
{
35
 
36
 
37
    /**
38
     * Construct new CheckoutByAmazon_Service_Model_ErrorResponse
39
     *
40
     * @param mixed $data DOMElement or Associative Array to construct from.
41
     *
42
     * Valid properties:
43
     * <ul>
44
     *
45
     * <li>Error: CheckoutByAmazon_Service_Model_Error</li>
46
     * <li>RequestId: string</li>
47
     *
48
     * </ul>
49
     */
50
    public function __construct($data = null)
51
    {
52
        $this->_fields = array (
53
        'Error' => array('FieldValue' => array(), 'FieldType' => array('CheckoutByAmazon_Service_Model_Error')),
54
        'RequestId' => array('FieldValue' => null, 'FieldType' => 'string'),
55
        );
56
        parent::__construct($data);
57
    }
58
 
59
 
60
    /**
61
     * Construct CheckoutByAmazon_Service_Model_ErrorResponse from XML string
62
     *
63
     * @param string $xml XML string to construct from
64
     * @return CheckoutByAmazon_Service_Model_ErrorResponse
65
     */
66
    public static function fromXML($xml)
67
    {
68
        $dom = new DOMDocument();
69
        $dom->loadXML($xml);
70
        $xpath = new DOMXPath($dom);
71
    	$xpath->registerNamespace('a','http://payments.amazon.com/checkout/v2/2010-08-31/');
72
        $response = $xpath->query('//a:${ActionName}Response');
73
        if ($response->length == 1) {
74
            return new CheckoutByAmazon_Service_Model_ErrorResponse(($response->item(0)));
75
        } else {
76
            throw new Exception ("Unable to construct CheckoutByAmazon_Service_Model_ErrorResponse from provided XML.
77
                                  Make sure that ${ActionName}Response is a root element");
78
        }
79
 
80
    }
81
 
82
    /**
83
     * Gets the value of the Error.
84
     *
85
     * @return array of Error Error
86
     */
87
    public function getError()
88
    {
89
        return $this->_fields['Error']['FieldValue'];
90
    }
91
 
92
    /**
93
     * Sets the value of the Error.
94
     *
95
     * @param mixed Error or an array of Error Error
96
     * @return this instance
97
     */
98
    public function setError($error)
99
    {
100
        if (!$this->_isNumericArray($error)) {
101
            $error =  array ($Error);
102
        }
103
        $this->_fields['Error']['FieldValue'] = $error;
104
        return $this;
105
    }
106
 
107
 
108
    /**
109
     * Checks if Error list is non-empty
110
     *
111
     * @return bool true if Error list is non-empty
112
     */
113
    public function isSetError()
114
    {
115
        return count ($this->_fields['Error']['FieldValue']) > 0;
116
    }
117
 
118
    /**
119
     * Gets the value of the RequestId property.
120
     *
121
     * @return string RequestId
122
     */
123
    public function getRequestId()
124
    {
125
        return $this->_fields['RequestId']['FieldValue'];
126
    }
127
 
128
    /**
129
     * Sets the value of the RequestId property.
130
     *
131
     * @param string RequestId
132
     * @return this instance
133
     */
134
    public function setRequestId($value)
135
    {
136
        $this->_fields['RequestId']['FieldValue'] = $value;
137
        return $this;
138
    }
139
 
140
 
141
    /**
142
     * Checks if RequestId is set
143
     *
144
     * @return bool true if RequestId  is set
145
     */
146
    public function isSetRequestId()
147
    {
148
        return !is_null($this->_fields['RequestId']['FieldValue']);
149
    }
150
 
151
 
152
 
153
    /**
154
     * XML Representation for this object
155
     *
156
     * @return string XML for this object
157
     */
158
    public function toXML()
159
    {
160
        $xml = "";
161
        $xml .= "<ErrorResponse xmlns=\"http://payments.amazon.com/checkout/v2/2010-08-31/\">";
162
        $xml .= $this->_toXMLFragment();
163
        $xml .= "</ErrorResponse>";
164
        return $xml;
165
    }
166
 
167
}
168
?>