1: | <?php |
2: | |
3: | |
4: | |
5: | |
6: | namespace Worldline\Connect\Sdk\V1\Domain; |
7: | |
8: | use UnexpectedValueException; |
9: | use Worldline\Connect\Sdk\Domain\DataObject; |
10: | |
11: | |
12: | |
13: | |
14: | class PaymentProductGroup extends DataObject |
15: | { |
16: | |
17: | |
18: | |
19: | public $accountsOnFile = null; |
20: | |
21: | |
22: | |
23: | |
24: | public $allowsInstallments = null; |
25: | |
26: | |
27: | |
28: | |
29: | public $deviceFingerprintEnabled = null; |
30: | |
31: | |
32: | |
33: | |
34: | public $displayHints = null; |
35: | |
36: | |
37: | |
38: | |
39: | public $fields = null; |
40: | |
41: | |
42: | |
43: | |
44: | public $id = null; |
45: | |
46: | |
47: | |
48: | |
49: | public function toObject() |
50: | { |
51: | $object = parent::toObject(); |
52: | if (!is_null($this->accountsOnFile)) { |
53: | $object->accountsOnFile = []; |
54: | foreach ($this->accountsOnFile as $element) { |
55: | if (!is_null($element)) { |
56: | $object->accountsOnFile[] = $element->toObject(); |
57: | } |
58: | } |
59: | } |
60: | if (!is_null($this->allowsInstallments)) { |
61: | $object->allowsInstallments = $this->allowsInstallments; |
62: | } |
63: | if (!is_null($this->deviceFingerprintEnabled)) { |
64: | $object->deviceFingerprintEnabled = $this->deviceFingerprintEnabled; |
65: | } |
66: | if (!is_null($this->displayHints)) { |
67: | $object->displayHints = $this->displayHints->toObject(); |
68: | } |
69: | if (!is_null($this->fields)) { |
70: | $object->fields = []; |
71: | foreach ($this->fields as $element) { |
72: | if (!is_null($element)) { |
73: | $object->fields[] = $element->toObject(); |
74: | } |
75: | } |
76: | } |
77: | if (!is_null($this->id)) { |
78: | $object->id = $this->id; |
79: | } |
80: | return $object; |
81: | } |
82: | |
83: | |
84: | |
85: | |
86: | |
87: | |
88: | public function fromObject($object) |
89: | { |
90: | parent::fromObject($object); |
91: | if (property_exists($object, 'accountsOnFile')) { |
92: | if (!is_array($object->accountsOnFile) && !is_object($object->accountsOnFile)) { |
93: | throw new UnexpectedValueException('value \'' . print_r($object->accountsOnFile, true) . '\' is not an array or object'); |
94: | } |
95: | $this->accountsOnFile = []; |
96: | foreach ($object->accountsOnFile as $element) { |
97: | $value = new AccountOnFile(); |
98: | $this->accountsOnFile[] = $value->fromObject($element); |
99: | } |
100: | } |
101: | if (property_exists($object, 'allowsInstallments')) { |
102: | $this->allowsInstallments = $object->allowsInstallments; |
103: | } |
104: | if (property_exists($object, 'deviceFingerprintEnabled')) { |
105: | $this->deviceFingerprintEnabled = $object->deviceFingerprintEnabled; |
106: | } |
107: | if (property_exists($object, 'displayHints')) { |
108: | if (!is_object($object->displayHints)) { |
109: | throw new UnexpectedValueException('value \'' . print_r($object->displayHints, true) . '\' is not an object'); |
110: | } |
111: | $value = new PaymentProductDisplayHints(); |
112: | $this->displayHints = $value->fromObject($object->displayHints); |
113: | } |
114: | if (property_exists($object, 'fields')) { |
115: | if (!is_array($object->fields) && !is_object($object->fields)) { |
116: | throw new UnexpectedValueException('value \'' . print_r($object->fields, true) . '\' is not an array or object'); |
117: | } |
118: | $this->fields = []; |
119: | foreach ($object->fields as $element) { |
120: | $value = new PaymentProductField(); |
121: | $this->fields[] = $value->fromObject($element); |
122: | } |
123: | } |
124: | if (property_exists($object, 'id')) { |
125: | $this->id = $object->id; |
126: | } |
127: | return $this; |
128: | } |
129: | } |
130: | |