1: | <?php |
2: | |
3: | |
4: | |
5: | |
6: | namespace Worldline\Connect\Sdk\V1\Domain; |
7: | |
8: | use UnexpectedValueException; |
9: | use Worldline\Connect\Sdk\Domain\DataObject; |
10: | |
11: | |
12: | |
13: | |
14: | class RefundErrorResponse extends DataObject |
15: | { |
16: | |
17: | |
18: | |
19: | public $errorId = null; |
20: | |
21: | |
22: | |
23: | |
24: | public $errors = null; |
25: | |
26: | |
27: | |
28: | |
29: | public $refundResult = null; |
30: | |
31: | |
32: | |
33: | |
34: | public function toObject() |
35: | { |
36: | $object = parent::toObject(); |
37: | if (!is_null($this->errorId)) { |
38: | $object->errorId = $this->errorId; |
39: | } |
40: | if (!is_null($this->errors)) { |
41: | $object->errors = []; |
42: | foreach ($this->errors as $element) { |
43: | if (!is_null($element)) { |
44: | $object->errors[] = $element->toObject(); |
45: | } |
46: | } |
47: | } |
48: | if (!is_null($this->refundResult)) { |
49: | $object->refundResult = $this->refundResult->toObject(); |
50: | } |
51: | return $object; |
52: | } |
53: | |
54: | |
55: | |
56: | |
57: | |
58: | |
59: | public function fromObject($object) |
60: | { |
61: | parent::fromObject($object); |
62: | if (property_exists($object, 'errorId')) { |
63: | $this->errorId = $object->errorId; |
64: | } |
65: | if (property_exists($object, 'errors')) { |
66: | if (!is_array($object->errors) && !is_object($object->errors)) { |
67: | throw new UnexpectedValueException('value \'' . print_r($object->errors, true) . '\' is not an array or object'); |
68: | } |
69: | $this->errors = []; |
70: | foreach ($object->errors as $element) { |
71: | $value = new APIError(); |
72: | $this->errors[] = $value->fromObject($element); |
73: | } |
74: | } |
75: | if (property_exists($object, 'refundResult')) { |
76: | if (!is_object($object->refundResult)) { |
77: | throw new UnexpectedValueException('value \'' . print_r($object->refundResult, true) . '\' is not an object'); |
78: | } |
79: | $value = new RefundResult(); |
80: | $this->refundResult = $value->fromObject($object->refundResult); |
81: | } |
82: | return $this; |
83: | } |
84: | } |
85: | |