1: <?php
2: /*
3: * This class was auto-generated from the API references found at
4: * https://apireference.connect.worldline-solutions.com/
5: */
6: namespace Worldline\Connect\Sdk\V1\Domain;
7:
8: use UnexpectedValueException;
9: use Worldline\Connect\Sdk\Domain\DataObject;
10:
11: /**
12: * @package Worldline\Connect\Sdk\V1\Domain
13: */
14: class MerchantAction extends DataObject
15: {
16: /**
17: * @var string|null
18: */
19: public ?string $actionType = null;
20:
21: /**
22: * @var PaymentProductField[]|null
23: */
24: public ?array $formFields = null;
25:
26: /**
27: * @var MobileThreeDSecureChallengeParameters|null
28: */
29: public ?MobileThreeDSecureChallengeParameters $mobileThreeDSecureChallengeParameters = null;
30:
31: /**
32: * @var RedirectData|null
33: */
34: public ?RedirectData $redirectData = null;
35:
36: /**
37: * @var string|null
38: */
39: public ?string $renderingData = null;
40:
41: /**
42: * @var KeyValuePair[]|null
43: */
44: public ?array $showData = null;
45:
46: /**
47: * @var ThirdPartyData|null
48: */
49: public ?ThirdPartyData $thirdPartyData = null;
50:
51: /**
52: * @return object
53: */
54: public function toObject(): object
55: {
56: $object = parent::toObject();
57: if (!is_null($this->actionType)) {
58: $object->actionType = $this->actionType;
59: }
60: if (!is_null($this->formFields)) {
61: $object->formFields = [];
62: foreach ($this->formFields as $element) {
63: if (!is_null($element)) {
64: $object->formFields[] = $element->toObject();
65: }
66: }
67: }
68: if (!is_null($this->mobileThreeDSecureChallengeParameters)) {
69: $object->mobileThreeDSecureChallengeParameters = $this->mobileThreeDSecureChallengeParameters->toObject();
70: }
71: if (!is_null($this->redirectData)) {
72: $object->redirectData = $this->redirectData->toObject();
73: }
74: if (!is_null($this->renderingData)) {
75: $object->renderingData = $this->renderingData;
76: }
77: if (!is_null($this->showData)) {
78: $object->showData = [];
79: foreach ($this->showData as $element) {
80: if (!is_null($element)) {
81: $object->showData[] = $element->toObject();
82: }
83: }
84: }
85: if (!is_null($this->thirdPartyData)) {
86: $object->thirdPartyData = $this->thirdPartyData->toObject();
87: }
88: return $object;
89: }
90:
91: /**
92: * @param object $object
93: *
94: * @return $this
95: * @throws UnexpectedValueException
96: */
97: public function fromObject(object $object): MerchantAction
98: {
99: parent::fromObject($object);
100: if (property_exists($object, 'actionType')) {
101: $this->actionType = $object->actionType;
102: }
103: if (property_exists($object, 'formFields')) {
104: if (!is_array($object->formFields) && !is_object($object->formFields)) {
105: throw new UnexpectedValueException('value \'' . print_r($object->formFields, true) . '\' is not an array or object');
106: }
107: $this->formFields = [];
108: foreach ($object->formFields as $element) {
109: $value = new PaymentProductField();
110: $this->formFields[] = $value->fromObject($element);
111: }
112: }
113: if (property_exists($object, 'mobileThreeDSecureChallengeParameters')) {
114: if (!is_object($object->mobileThreeDSecureChallengeParameters)) {
115: throw new UnexpectedValueException('value \'' . print_r($object->mobileThreeDSecureChallengeParameters, true) . '\' is not an object');
116: }
117: $value = new MobileThreeDSecureChallengeParameters();
118: $this->mobileThreeDSecureChallengeParameters = $value->fromObject($object->mobileThreeDSecureChallengeParameters);
119: }
120: if (property_exists($object, 'redirectData')) {
121: if (!is_object($object->redirectData)) {
122: throw new UnexpectedValueException('value \'' . print_r($object->redirectData, true) . '\' is not an object');
123: }
124: $value = new RedirectData();
125: $this->redirectData = $value->fromObject($object->redirectData);
126: }
127: if (property_exists($object, 'renderingData')) {
128: $this->renderingData = $object->renderingData;
129: }
130: if (property_exists($object, 'showData')) {
131: if (!is_array($object->showData) && !is_object($object->showData)) {
132: throw new UnexpectedValueException('value \'' . print_r($object->showData, true) . '\' is not an array or object');
133: }
134: $this->showData = [];
135: foreach ($object->showData as $element) {
136: $value = new KeyValuePair();
137: $this->showData[] = $value->fromObject($element);
138: }
139: }
140: if (property_exists($object, 'thirdPartyData')) {
141: if (!is_object($object->thirdPartyData)) {
142: throw new UnexpectedValueException('value \'' . print_r($object->thirdPartyData, true) . '\' is not an object');
143: }
144: $value = new ThirdPartyData();
145: $this->thirdPartyData = $value->fromObject($object->thirdPartyData);
146: }
147: return $this;
148: }
149: }
150: