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