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