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