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 FindRefundsResponse extends DataObject |
15: | { |
16: | |
17: | |
18: | |
19: | public $limit = null; |
20: | |
21: | |
22: | |
23: | |
24: | public $offset = null; |
25: | |
26: | |
27: | |
28: | |
29: | public $refunds = null; |
30: | |
31: | |
32: | |
33: | |
34: | public $totalCount = null; |
35: | |
36: | |
37: | |
38: | |
39: | public function toObject() |
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: | |
64: | |
65: | |
66: | |
67: | public function fromObject($object) |
68: | { |
69: | parent::fromObject($object); |
70: | if (property_exists($object, 'limit')) { |
71: | $this->limit = $object->limit; |
72: | } |
73: | if (property_exists($object, 'offset')) { |
74: | $this->offset = $object->offset; |
75: | } |
76: | if (property_exists($object, 'refunds')) { |
77: | if (!is_array($object->refunds) && !is_object($object->refunds)) { |
78: | throw new UnexpectedValueException('value \'' . print_r($object->refunds, true) . '\' is not an array or object'); |
79: | } |
80: | $this->refunds = []; |
81: | foreach ($object->refunds as $element) { |
82: | $value = new RefundResult(); |
83: | $this->refunds[] = $value->fromObject($element); |
84: | } |
85: | } |
86: | if (property_exists($object, 'totalCount')) { |
87: | $this->totalCount = $object->totalCount; |
88: | } |
89: | return $this; |
90: | } |
91: | } |
92: | |