1: <?php
2: /*
3: * This file was automatically generated.
4: */
5: namespace Worldline\Acquiring\Sdk\V1\Domain;
6:
7: use DateTime;
8: use UnexpectedValueException;
9: use Worldline\Acquiring\Sdk\Domain\DataObject;
10:
11: /**
12: * @package Worldline\Acquiring\Sdk\V1\Domain
13: */
14: class ApiPaymentRefundRequest extends DataObject
15: {
16: /**
17: * @var AmountData|null
18: */
19: public ?AmountData $amount = null;
20:
21: /**
22: * @var bool|null
23: */
24: public ?bool $captureImmediately = null;
25:
26: /**
27: * @var DccData|null
28: */
29: public ?DccData $dynamicCurrencyConversion = null;
30:
31: /**
32: * @var string|null
33: */
34: public ?string $operationId = null;
35:
36: /**
37: * @var PaymentReferences|null
38: */
39: public ?PaymentReferences $references = null;
40:
41: /**
42: * @var TerminalData|null
43: */
44: public ?TerminalData $terminalData = null;
45:
46: /**
47: * @var DateTime|null
48: */
49: public ?DateTime $transactionTimestamp = null;
50:
51: /**
52: * @return object
53: */
54: public function toObject(): object
55: {
56: $object = parent::toObject();
57: if (!is_null($this->amount)) {
58: $object->amount = $this->amount->toObject();
59: }
60: if (!is_null($this->captureImmediately)) {
61: $object->captureImmediately = $this->captureImmediately;
62: }
63: if (!is_null($this->dynamicCurrencyConversion)) {
64: $object->dynamicCurrencyConversion = $this->dynamicCurrencyConversion->toObject();
65: }
66: if (!is_null($this->operationId)) {
67: $object->operationId = $this->operationId;
68: }
69: if (!is_null($this->references)) {
70: $object->references = $this->references->toObject();
71: }
72: if (!is_null($this->terminalData)) {
73: $object->terminalData = $this->terminalData->toObject();
74: }
75: if (!is_null($this->transactionTimestamp)) {
76: $object->transactionTimestamp = $this->transactionTimestamp->format('Y-m-d\\TH:i:s.vP');
77: }
78: return $object;
79: }
80:
81: /**
82: * @param object $object
83: *
84: * @return $this
85: * @throws UnexpectedValueException
86: */
87: public function fromObject(object $object): ApiPaymentRefundRequest
88: {
89: parent::fromObject($object);
90: if (property_exists($object, 'amount')) {
91: if (!is_object($object->amount)) {
92: throw new UnexpectedValueException('value \'' . print_r($object->amount, true) . '\' is not an object');
93: }
94: $value = new AmountData();
95: $this->amount = $value->fromObject($object->amount);
96: }
97: if (property_exists($object, 'captureImmediately')) {
98: $this->captureImmediately = $object->captureImmediately;
99: }
100: if (property_exists($object, 'dynamicCurrencyConversion')) {
101: if (!is_object($object->dynamicCurrencyConversion)) {
102: throw new UnexpectedValueException('value \'' . print_r($object->dynamicCurrencyConversion, true) . '\' is not an object');
103: }
104: $value = new DccData();
105: $this->dynamicCurrencyConversion = $value->fromObject($object->dynamicCurrencyConversion);
106: }
107: if (property_exists($object, 'operationId')) {
108: $this->operationId = $object->operationId;
109: }
110: if (property_exists($object, 'references')) {
111: if (!is_object($object->references)) {
112: throw new UnexpectedValueException('value \'' . print_r($object->references, true) . '\' is not an object');
113: }
114: $value = new PaymentReferences();
115: $this->references = $value->fromObject($object->references);
116: }
117: if (property_exists($object, 'terminalData')) {
118: if (!is_object($object->terminalData)) {
119: throw new UnexpectedValueException('value \'' . print_r($object->terminalData, true) . '\' is not an object');
120: }
121: $value = new TerminalData();
122: $this->terminalData = $value->fromObject($object->terminalData);
123: }
124: if (property_exists($object, 'transactionTimestamp')) {
125: $this->transactionTimestamp = new DateTime($object->transactionTimestamp);
126: }
127: return $this;
128: }
129: }
130: