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[]
18: */
19: public $accountsOnFile = null;
20:
21: /**
22: * @var bool
23: */
24: public $allowsClickToPay = null;
25:
26: /**
27: * @var bool
28: */
29: public $allowsInstallments = null;
30:
31: /**
32: * @var ClickToPayConfiguration
33: */
34: public $clickToPayConfiguration = null;
35:
36: /**
37: * @var bool
38: */
39: public $deviceFingerprintEnabled = null;
40:
41: /**
42: * @var PaymentProductDisplayHints
43: */
44: public $displayHints = null;
45:
46: /**
47: * @var PaymentProductField[]
48: */
49: public $fields = null;
50:
51: /**
52: * @var string
53: */
54: public $id = null;
55:
56: /**
57: * @return object
58: */
59: public function toObject()
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: * @return $this
102: * @throws UnexpectedValueException
103: */
104: public function fromObject($object)
105: {
106: parent::fromObject($object);
107: if (property_exists($object, 'accountsOnFile')) {
108: if (!is_array($object->accountsOnFile) && !is_object($object->accountsOnFile)) {
109: throw new UnexpectedValueException('value \'' . print_r($object->accountsOnFile, true) . '\' is not an array or object');
110: }
111: $this->accountsOnFile = [];
112: foreach ($object->accountsOnFile as $element) {
113: $value = new AccountOnFile();
114: $this->accountsOnFile[] = $value->fromObject($element);
115: }
116: }
117: if (property_exists($object, 'allowsClickToPay')) {
118: $this->allowsClickToPay = $object->allowsClickToPay;
119: }
120: if (property_exists($object, 'allowsInstallments')) {
121: $this->allowsInstallments = $object->allowsInstallments;
122: }
123: if (property_exists($object, 'clickToPayConfiguration')) {
124: if (!is_object($object->clickToPayConfiguration)) {
125: throw new UnexpectedValueException('value \'' . print_r($object->clickToPayConfiguration, true) . '\' is not an object');
126: }
127: $value = new ClickToPayConfiguration();
128: $this->clickToPayConfiguration = $value->fromObject($object->clickToPayConfiguration);
129: }
130: if (property_exists($object, 'deviceFingerprintEnabled')) {
131: $this->deviceFingerprintEnabled = $object->deviceFingerprintEnabled;
132: }
133: if (property_exists($object, 'displayHints')) {
134: if (!is_object($object->displayHints)) {
135: throw new UnexpectedValueException('value \'' . print_r($object->displayHints, true) . '\' is not an object');
136: }
137: $value = new PaymentProductDisplayHints();
138: $this->displayHints = $value->fromObject($object->displayHints);
139: }
140: if (property_exists($object, 'fields')) {
141: if (!is_array($object->fields) && !is_object($object->fields)) {
142: throw new UnexpectedValueException('value \'' . print_r($object->fields, true) . '\' is not an array or object');
143: }
144: $this->fields = [];
145: foreach ($object->fields as $element) {
146: $value = new PaymentProductField();
147: $this->fields[] = $value->fromObject($element);
148: }
149: }
150: if (property_exists($object, 'id')) {
151: $this->id = $object->id;
152: }
153: return $this;
154: }
155: }
156: