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