| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | namespace Worldline\Acquiring\Sdk\V1\Domain; |
| 6: | |
| 7: | use UnexpectedValueException; |
| 8: | use Worldline\Acquiring\Sdk\Domain\DataObject; |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | class SearchDisputesResponse extends DataObject |
| 14: | { |
| 15: | |
| 16: | |
| 17: | |
| 18: | public ?array $disputes = null; |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | public ?PaginationResponse $pagination = null; |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: | public ?string $requestId = null; |
| 29: | |
| 30: | |
| 31: | |
| 32: | |
| 33: | public function toObject(): object |
| 34: | { |
| 35: | $object = parent::toObject(); |
| 36: | if (!is_null($this->disputes)) { |
| 37: | $object->disputes = []; |
| 38: | foreach ($this->disputes as $element) { |
| 39: | if (!is_null($element)) { |
| 40: | $object->disputes[] = $element->toObject(); |
| 41: | } |
| 42: | } |
| 43: | } |
| 44: | if (!is_null($this->pagination)) { |
| 45: | $object->pagination = $this->pagination->toObject(); |
| 46: | } |
| 47: | if (!is_null($this->requestId)) { |
| 48: | $object->requestId = $this->requestId; |
| 49: | } |
| 50: | return $object; |
| 51: | } |
| 52: | |
| 53: | |
| 54: | |
| 55: | |
| 56: | |
| 57: | |
| 58: | |
| 59: | public function fromObject(object $object): SearchDisputesResponse |
| 60: | { |
| 61: | parent::fromObject($object); |
| 62: | if (property_exists($object, 'disputes')) { |
| 63: | if (!is_array($object->disputes) && !is_object($object->disputes)) { |
| 64: | throw new UnexpectedValueException('value \'' . print_r($object->disputes, true) . '\' is not an array or object'); |
| 65: | } |
| 66: | $this->disputes = []; |
| 67: | foreach ($object->disputes as $element) { |
| 68: | $value = new DisputeCase(); |
| 69: | $this->disputes[] = $value->fromObject($element); |
| 70: | } |
| 71: | } |
| 72: | if (property_exists($object, 'pagination')) { |
| 73: | if (!is_object($object->pagination)) { |
| 74: | throw new UnexpectedValueException('value \'' . print_r($object->pagination, true) . '\' is not an object'); |
| 75: | } |
| 76: | $value = new PaginationResponse(); |
| 77: | $this->pagination = $value->fromObject($object->pagination); |
| 78: | } |
| 79: | if (property_exists($object, 'requestId')) { |
| 80: | $this->requestId = $object->requestId; |
| 81: | } |
| 82: | return $this; |
| 83: | } |
| 84: | } |
| 85: | |