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 PayoutErrorResponse extends DataObject
15: {
16: /**
17: * @var string|null
18: */
19: public ?string $errorId = null;
20:
21: /**
22: * @var APIError[]|null
23: */
24: public ?array $errors = null;
25:
26: /**
27: * @var PayoutResult|null
28: */
29: public ?PayoutResult $payoutResult = null;
30:
31: /**
32: * @return object
33: */
34: public function toObject(): object
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->payoutResult)) {
49: $object->payoutResult = $this->payoutResult->toObject();
50: }
51: return $object;
52: }
53:
54: /**
55: * @param object $object
56: *
57: * @return $this
58: * @throws UnexpectedValueException
59: */
60: public function fromObject(object $object): PayoutErrorResponse
61: {
62: parent::fromObject($object);
63: if (property_exists($object, 'errorId')) {
64: $this->errorId = $object->errorId;
65: }
66: if (property_exists($object, 'errors')) {
67: if (!is_array($object->errors) && !is_object($object->errors)) {
68: throw new UnexpectedValueException('value \'' . print_r($object->errors, true) . '\' is not an array or object');
69: }
70: $this->errors = [];
71: foreach ($object->errors as $element) {
72: $value = new APIError();
73: $this->errors[] = $value->fromObject($element);
74: }
75: }
76: if (property_exists($object, 'payoutResult')) {
77: if (!is_object($object->payoutResult)) {
78: throw new UnexpectedValueException('value \'' . print_r($object->payoutResult, true) . '\' is not an object');
79: }
80: $value = new PayoutResult();
81: $this->payoutResult = $value->fromObject($object->payoutResult);
82: }
83: return $this;
84: }
85: }
86: