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 ApiRefundRequest extends DataObject
15: {
16: /**
17: * @var AmountData|null
18: */
19: public ?AmountData $amount = null;
20:
21: /**
22: * @var CardPaymentDataForRefund|null
23: */
24: public ?CardPaymentDataForRefund $cardPaymentData = null;
25:
26: /**
27: * @var DccData|null
28: */
29: public ?DccData $dynamicCurrencyConversion = null;
30:
31: /**
32: * @var MerchantData|null
33: */
34: public ?MerchantData $merchant = null;
35:
36: /**
37: * @var string|null
38: */
39: public ?string $operationId = null;
40:
41: /**
42: * @var PaymentReferences|null
43: */
44: public ?PaymentReferences $references = null;
45:
46: /**
47: * @var TerminalData|null
48: */
49: public ?TerminalData $terminalData = null;
50:
51: /**
52: * @var DateTime|null
53: */
54: public ?DateTime $transactionTimestamp = null;
55:
56: /**
57: * @return object
58: */
59: public function toObject(): object
60: {
61: $object = parent::toObject();
62: if (!is_null($this->amount)) {
63: $object->amount = $this->amount->toObject();
64: }
65: if (!is_null($this->cardPaymentData)) {
66: $object->cardPaymentData = $this->cardPaymentData->toObject();
67: }
68: if (!is_null($this->dynamicCurrencyConversion)) {
69: $object->dynamicCurrencyConversion = $this->dynamicCurrencyConversion->toObject();
70: }
71: if (!is_null($this->merchant)) {
72: $object->merchant = $this->merchant->toObject();
73: }
74: if (!is_null($this->operationId)) {
75: $object->operationId = $this->operationId;
76: }
77: if (!is_null($this->references)) {
78: $object->references = $this->references->toObject();
79: }
80: if (!is_null($this->terminalData)) {
81: $object->terminalData = $this->terminalData->toObject();
82: }
83: if (!is_null($this->transactionTimestamp)) {
84: $object->transactionTimestamp = $this->transactionTimestamp->format('Y-m-d\\TH:i:s.vP');
85: }
86: return $object;
87: }
88:
89: /**
90: * @param object $object
91: *
92: * @return $this
93: * @throws UnexpectedValueException
94: */
95: public function fromObject(object $object): ApiRefundRequest
96: {
97: parent::fromObject($object);
98: if (property_exists($object, 'amount')) {
99: if (!is_object($object->amount)) {
100: throw new UnexpectedValueException('value \'' . print_r($object->amount, true) . '\' is not an object');
101: }
102: $value = new AmountData();
103: $this->amount = $value->fromObject($object->amount);
104: }
105: if (property_exists($object, 'cardPaymentData')) {
106: if (!is_object($object->cardPaymentData)) {
107: throw new UnexpectedValueException('value \'' . print_r($object->cardPaymentData, true) . '\' is not an object');
108: }
109: $value = new CardPaymentDataForRefund();
110: $this->cardPaymentData = $value->fromObject($object->cardPaymentData);
111: }
112: if (property_exists($object, 'dynamicCurrencyConversion')) {
113: if (!is_object($object->dynamicCurrencyConversion)) {
114: throw new UnexpectedValueException('value \'' . print_r($object->dynamicCurrencyConversion, true) . '\' is not an object');
115: }
116: $value = new DccData();
117: $this->dynamicCurrencyConversion = $value->fromObject($object->dynamicCurrencyConversion);
118: }
119: if (property_exists($object, 'merchant')) {
120: if (!is_object($object->merchant)) {
121: throw new UnexpectedValueException('value \'' . print_r($object->merchant, true) . '\' is not an object');
122: }
123: $value = new MerchantData();
124: $this->merchant = $value->fromObject($object->merchant);
125: }
126: if (property_exists($object, 'operationId')) {
127: $this->operationId = $object->operationId;
128: }
129: if (property_exists($object, 'references')) {
130: if (!is_object($object->references)) {
131: throw new UnexpectedValueException('value \'' . print_r($object->references, true) . '\' is not an object');
132: }
133: $value = new PaymentReferences();
134: $this->references = $value->fromObject($object->references);
135: }
136: if (property_exists($object, 'terminalData')) {
137: if (!is_object($object->terminalData)) {
138: throw new UnexpectedValueException('value \'' . print_r($object->terminalData, true) . '\' is not an object');
139: }
140: $value = new TerminalData();
141: $this->terminalData = $value->fromObject($object->terminalData);
142: }
143: if (property_exists($object, 'transactionTimestamp')) {
144: $this->transactionTimestamp = new DateTime($object->transactionTimestamp);
145: }
146: return $this;
147: }
148: }
149: