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 SessionResponse extends DataObject |
15: | { |
16: | |
17: | |
18: | |
19: | public $assetUrl = null; |
20: | |
21: | |
22: | |
23: | |
24: | public $clientApiUrl = null; |
25: | |
26: | |
27: | |
28: | |
29: | public $clientSessionId = null; |
30: | |
31: | |
32: | |
33: | |
34: | public $customerId = null; |
35: | |
36: | |
37: | |
38: | |
39: | public $invalidTokens = null; |
40: | |
41: | |
42: | |
43: | |
44: | public $region = null; |
45: | |
46: | |
47: | |
48: | |
49: | public function toObject() |
50: | { |
51: | $object = parent::toObject(); |
52: | if (!is_null($this->assetUrl)) { |
53: | $object->assetUrl = $this->assetUrl; |
54: | } |
55: | if (!is_null($this->clientApiUrl)) { |
56: | $object->clientApiUrl = $this->clientApiUrl; |
57: | } |
58: | if (!is_null($this->clientSessionId)) { |
59: | $object->clientSessionId = $this->clientSessionId; |
60: | } |
61: | if (!is_null($this->customerId)) { |
62: | $object->customerId = $this->customerId; |
63: | } |
64: | if (!is_null($this->invalidTokens)) { |
65: | $object->invalidTokens = []; |
66: | foreach ($this->invalidTokens as $element) { |
67: | if (!is_null($element)) { |
68: | $object->invalidTokens[] = $element; |
69: | } |
70: | } |
71: | } |
72: | if (!is_null($this->region)) { |
73: | $object->region = $this->region; |
74: | } |
75: | return $object; |
76: | } |
77: | |
78: | |
79: | |
80: | |
81: | |
82: | |
83: | public function fromObject($object) |
84: | { |
85: | parent::fromObject($object); |
86: | if (property_exists($object, 'assetUrl')) { |
87: | $this->assetUrl = $object->assetUrl; |
88: | } |
89: | if (property_exists($object, 'clientApiUrl')) { |
90: | $this->clientApiUrl = $object->clientApiUrl; |
91: | } |
92: | if (property_exists($object, 'clientSessionId')) { |
93: | $this->clientSessionId = $object->clientSessionId; |
94: | } |
95: | if (property_exists($object, 'customerId')) { |
96: | $this->customerId = $object->customerId; |
97: | } |
98: | if (property_exists($object, 'invalidTokens')) { |
99: | if (!is_array($object->invalidTokens) && !is_object($object->invalidTokens)) { |
100: | throw new UnexpectedValueException('value \'' . print_r($object->invalidTokens, true) . '\' is not an array or object'); |
101: | } |
102: | $this->invalidTokens = []; |
103: | foreach ($object->invalidTokens as $element) { |
104: | $this->invalidTokens[] = $element; |
105: | } |
106: | } |
107: | if (property_exists($object, 'region')) { |
108: | $this->region = $object->region; |
109: | } |
110: | return $this; |
111: | } |
112: | } |
113: | |