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