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 PaymentContext extends DataObject
15: {
16: /**
17: * @var AmountOfMoney|null
18: */
19: public ?AmountOfMoney $amountOfMoney = null;
20:
21: /**
22: * @var string|null
23: */
24: public ?string $countryCode = null;
25:
26: /**
27: * @var bool|null
28: */
29: public ?bool $isInstallments = null;
30:
31: /**
32: * @var bool|null
33: */
34: public ?bool $isRecurring = null;
35:
36: /**
37: * @return object
38: */
39: public function toObject(): object
40: {
41: $object = parent::toObject();
42: if (!is_null($this->amountOfMoney)) {
43: $object->amountOfMoney = $this->amountOfMoney->toObject();
44: }
45: if (!is_null($this->countryCode)) {
46: $object->countryCode = $this->countryCode;
47: }
48: if (!is_null($this->isInstallments)) {
49: $object->isInstallments = $this->isInstallments;
50: }
51: if (!is_null($this->isRecurring)) {
52: $object->isRecurring = $this->isRecurring;
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): PaymentContext
64: {
65: parent::fromObject($object);
66: if (property_exists($object, 'amountOfMoney')) {
67: if (!is_object($object->amountOfMoney)) {
68: throw new UnexpectedValueException('value \'' . print_r($object->amountOfMoney, true) . '\' is not an object');
69: }
70: $value = new AmountOfMoney();
71: $this->amountOfMoney = $value->fromObject($object->amountOfMoney);
72: }
73: if (property_exists($object, 'countryCode')) {
74: $this->countryCode = $object->countryCode;
75: }
76: if (property_exists($object, 'isInstallments')) {
77: $this->isInstallments = $object->isInstallments;
78: }
79: if (property_exists($object, 'isRecurring')) {
80: $this->isRecurring = $object->isRecurring;
81: }
82: return $this;
83: }
84: }
85: