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