1: <?php
2: /*
3: * This class was auto-generated from the API references found at
4: * https://apireference.connect.worldline-solutions.com/
5: */
6: namespace Worldline\Connect\Sdk\V1\Domain;
7:
8: use UnexpectedValueException;
9: use Worldline\Connect\Sdk\Domain\DataObject;
10:
11: /**
12: * @package Worldline\Connect\Sdk\V1\Domain
13: */
14: class PaymentErrorResponse extends DataObject
15: {
16: /**
17: * @var string
18: */
19: public $errorId = null;
20:
21: /**
22: * @var APIError[]
23: */
24: public $errors = null;
25:
26: /**
27: * @var CreatePaymentResult
28: */
29: public $paymentResult = null;
30:
31: /**
32: * @return object
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->paymentResult)) {
49: $object->paymentResult = $this->paymentResult->toObject();
50: }
51: return $object;
52: }
53:
54: /**
55: * @param object $object
56: * @return $this
57: * @throws UnexpectedValueException
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, 'paymentResult')) {
76: if (!is_object($object->paymentResult)) {
77: throw new UnexpectedValueException('value \'' . print_r($object->paymentResult, true) . '\' is not an object');
78: }
79: $value = new CreatePaymentResult();
80: $this->paymentResult = $value->fromObject($object->paymentResult);
81: }
82: return $this;
83: }
84: }
85: