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 UpdateTokenRequest extends DataObject
15: {
16: /**
17: * @var TokenCard|null
18: */
19: public ?TokenCard $card = null;
20:
21: /**
22: * @var TokenEWallet|null
23: */
24: public ?TokenEWallet $eWallet = null;
25:
26: /**
27: * @var TokenNonSepaDirectDebit|null
28: */
29: public ?TokenNonSepaDirectDebit $nonSepaDirectDebit = null;
30:
31: /**
32: * @var int|null
33: */
34: public ?int $paymentProductId = null;
35:
36: /**
37: * @var TokenSepaDirectDebitWithoutCreditor|null
38: */
39: public ?TokenSepaDirectDebitWithoutCreditor $sepaDirectDebit = null;
40:
41: /**
42: * @return object
43: */
44: public function toObject(): object
45: {
46: $object = parent::toObject();
47: if (!is_null($this->card)) {
48: $object->card = $this->card->toObject();
49: }
50: if (!is_null($this->eWallet)) {
51: $object->eWallet = $this->eWallet->toObject();
52: }
53: if (!is_null($this->nonSepaDirectDebit)) {
54: $object->nonSepaDirectDebit = $this->nonSepaDirectDebit->toObject();
55: }
56: if (!is_null($this->paymentProductId)) {
57: $object->paymentProductId = $this->paymentProductId;
58: }
59: if (!is_null($this->sepaDirectDebit)) {
60: $object->sepaDirectDebit = $this->sepaDirectDebit->toObject();
61: }
62: return $object;
63: }
64:
65: /**
66: * @param object $object
67: *
68: * @return $this
69: * @throws UnexpectedValueException
70: */
71: public function fromObject(object $object): UpdateTokenRequest
72: {
73: parent::fromObject($object);
74: if (property_exists($object, 'card')) {
75: if (!is_object($object->card)) {
76: throw new UnexpectedValueException('value \'' . print_r($object->card, true) . '\' is not an object');
77: }
78: $value = new TokenCard();
79: $this->card = $value->fromObject($object->card);
80: }
81: if (property_exists($object, 'eWallet')) {
82: if (!is_object($object->eWallet)) {
83: throw new UnexpectedValueException('value \'' . print_r($object->eWallet, true) . '\' is not an object');
84: }
85: $value = new TokenEWallet();
86: $this->eWallet = $value->fromObject($object->eWallet);
87: }
88: if (property_exists($object, 'nonSepaDirectDebit')) {
89: if (!is_object($object->nonSepaDirectDebit)) {
90: throw new UnexpectedValueException('value \'' . print_r($object->nonSepaDirectDebit, true) . '\' is not an object');
91: }
92: $value = new TokenNonSepaDirectDebit();
93: $this->nonSepaDirectDebit = $value->fromObject($object->nonSepaDirectDebit);
94: }
95: if (property_exists($object, 'paymentProductId')) {
96: $this->paymentProductId = $object->paymentProductId;
97: }
98: if (property_exists($object, 'sepaDirectDebit')) {
99: if (!is_object($object->sepaDirectDebit)) {
100: throw new UnexpectedValueException('value \'' . print_r($object->sepaDirectDebit, true) . '\' is not an object');
101: }
102: $value = new TokenSepaDirectDebitWithoutCreditor();
103: $this->sepaDirectDebit = $value->fromObject($object->sepaDirectDebit);
104: }
105: return $this;
106: }
107: }
108: