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 ErrorResponse 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: * @return object
28: */
29: public function toObject()
30: {
31: $object = parent::toObject();
32: if (!is_null($this->errorId)) {
33: $object->errorId = $this->errorId;
34: }
35: if (!is_null($this->errors)) {
36: $object->errors = [];
37: foreach ($this->errors as $element) {
38: if (!is_null($element)) {
39: $object->errors[] = $element->toObject();
40: }
41: }
42: }
43: return $object;
44: }
45:
46: /**
47: * @param object $object
48: * @return $this
49: * @throws UnexpectedValueException
50: */
51: public function fromObject($object)
52: {
53: parent::fromObject($object);
54: if (property_exists($object, 'errorId')) {
55: $this->errorId = $object->errorId;
56: }
57: if (property_exists($object, 'errors')) {
58: if (!is_array($object->errors) && !is_object($object->errors)) {
59: throw new UnexpectedValueException('value \'' . print_r($object->errors, true) . '\' is not an array or object');
60: }
61: $this->errors = [];
62: foreach ($object->errors as $element) {
63: $value = new APIError();
64: $this->errors[] = $value->fromObject($element);
65: }
66: }
67: return $this;
68: }
69: }
70: