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 SessionRequest extends DataObject
15: {
16: /**
17: * @var PaymentProductFiltersClientSession|null
18: */
19: public ?PaymentProductFiltersClientSession $paymentProductFilters = null;
20:
21: /**
22: * @var string[]|null
23: */
24: public ?array $tokens = null;
25:
26: /**
27: * @return object
28: */
29: public function toObject(): object
30: {
31: $object = parent::toObject();
32: if (!is_null($this->paymentProductFilters)) {
33: $object->paymentProductFilters = $this->paymentProductFilters->toObject();
34: }
35: if (!is_null($this->tokens)) {
36: $object->tokens = [];
37: foreach ($this->tokens as $element) {
38: if (!is_null($element)) {
39: $object->tokens[] = $element;
40: }
41: }
42: }
43: return $object;
44: }
45:
46: /**
47: * @param object $object
48: *
49: * @return $this
50: * @throws UnexpectedValueException
51: */
52: public function fromObject(object $object): SessionRequest
53: {
54: parent::fromObject($object);
55: if (property_exists($object, 'paymentProductFilters')) {
56: if (!is_object($object->paymentProductFilters)) {
57: throw new UnexpectedValueException('value \'' . print_r($object->paymentProductFilters, true) . '\' is not an object');
58: }
59: $value = new PaymentProductFiltersClientSession();
60: $this->paymentProductFilters = $value->fromObject($object->paymentProductFilters);
61: }
62: if (property_exists($object, 'tokens')) {
63: if (!is_array($object->tokens) && !is_object($object->tokens)) {
64: throw new UnexpectedValueException('value \'' . print_r($object->tokens, true) . '\' is not an array or object');
65: }
66: $this->tokens = [];
67: foreach ($object->tokens as $element) {
68: $this->tokens[] = $element;
69: }
70: }
71: return $this;
72: }
73: }
74: