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
18: */
19: public $card = null;
20:
21: /**
22: * @var TokenEWallet
23: */
24: public $eWallet = null;
25:
26: /**
27: * @var string
28: */
29: public $id = null;
30:
31: /**
32: * @var TokenNonSepaDirectDebit
33: */
34: public $nonSepaDirectDebit = null;
35:
36: /**
37: * @var string
38: */
39: public $originalPaymentId = null;
40:
41: /**
42: * @var int
43: */
44: public $paymentProductId = null;
45:
46: /**
47: * @var TokenSepaDirectDebit
48: */
49: public $sepaDirectDebit = null;
50:
51: /**
52: * @return object
53: */
54: public function toObject()
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: * @return $this
84: * @throws UnexpectedValueException
85: */
86: public function fromObject($object)
87: {
88: parent::fromObject($object);
89: if (property_exists($object, 'card')) {
90: if (!is_object($object->card)) {
91: throw new UnexpectedValueException('value \'' . print_r($object->card, true) . '\' is not an object');
92: }
93: $value = new TokenCard();
94: $this->card = $value->fromObject($object->card);
95: }
96: if (property_exists($object, 'eWallet')) {
97: if (!is_object($object->eWallet)) {
98: throw new UnexpectedValueException('value \'' . print_r($object->eWallet, true) . '\' is not an object');
99: }
100: $value = new TokenEWallet();
101: $this->eWallet = $value->fromObject($object->eWallet);
102: }
103: if (property_exists($object, 'id')) {
104: $this->id = $object->id;
105: }
106: if (property_exists($object, 'nonSepaDirectDebit')) {
107: if (!is_object($object->nonSepaDirectDebit)) {
108: throw new UnexpectedValueException('value \'' . print_r($object->nonSepaDirectDebit, true) . '\' is not an object');
109: }
110: $value = new TokenNonSepaDirectDebit();
111: $this->nonSepaDirectDebit = $value->fromObject($object->nonSepaDirectDebit);
112: }
113: if (property_exists($object, 'originalPaymentId')) {
114: $this->originalPaymentId = $object->originalPaymentId;
115: }
116: if (property_exists($object, 'paymentProductId')) {
117: $this->paymentProductId = $object->paymentProductId;
118: }
119: if (property_exists($object, 'sepaDirectDebit')) {
120: if (!is_object($object->sepaDirectDebit)) {
121: throw new UnexpectedValueException('value \'' . print_r($object->sepaDirectDebit, true) . '\' is not an object');
122: }
123: $value = new TokenSepaDirectDebit();
124: $this->sepaDirectDebit = $value->fromObject($object->sepaDirectDebit);
125: }
126: return $this;
127: }
128: }
129: