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