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 FindRefundsResponse extends DataObject
15: {
16: /**
17: * @var int|null
18: */
19: public ?int $limit = null;
20:
21: /**
22: * @var int|null
23: */
24: public ?int $offset = null;
25:
26: /**
27: * @var RefundResult[]|null
28: */
29: public ?array $refunds = null;
30:
31: /**
32: * @var int|null
33: */
34: public ?int $totalCount = null;
35:
36: /**
37: * @return object
38: */
39: public function toObject(): object
40: {
41: $object = parent::toObject();
42: if (!is_null($this->limit)) {
43: $object->limit = $this->limit;
44: }
45: if (!is_null($this->offset)) {
46: $object->offset = $this->offset;
47: }
48: if (!is_null($this->refunds)) {
49: $object->refunds = [];
50: foreach ($this->refunds as $element) {
51: if (!is_null($element)) {
52: $object->refunds[] = $element->toObject();
53: }
54: }
55: }
56: if (!is_null($this->totalCount)) {
57: $object->totalCount = $this->totalCount;
58: }
59: return $object;
60: }
61:
62: /**
63: * @param object $object
64: *
65: * @return $this
66: * @throws UnexpectedValueException
67: */
68: public function fromObject(object $object): FindRefundsResponse
69: {
70: parent::fromObject($object);
71: if (property_exists($object, 'limit')) {
72: $this->limit = $object->limit;
73: }
74: if (property_exists($object, 'offset')) {
75: $this->offset = $object->offset;
76: }
77: if (property_exists($object, 'refunds')) {
78: if (!is_array($object->refunds) && !is_object($object->refunds)) {
79: throw new UnexpectedValueException('value \'' . print_r($object->refunds, true) . '\' is not an array or object');
80: }
81: $this->refunds = [];
82: foreach ($object->refunds as $element) {
83: $value = new RefundResult();
84: $this->refunds[] = $value->fromObject($element);
85: }
86: }
87: if (property_exists($object, 'totalCount')) {
88: $this->totalCount = $object->totalCount;
89: }
90: return $this;
91: }
92: }
93: