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 GiftCardPurchase extends DataObject
15: {
16: /**
17: * @var AmountOfMoney|null
18: */
19: public ?AmountOfMoney $amountOfMoney = null;
20:
21: /**
22: * @var int|null
23: */
24: public ?int $numberOfGiftCards = null;
25:
26: /**
27: * @return object
28: */
29: public function toObject(): object
30: {
31: $object = parent::toObject();
32: if (!is_null($this->amountOfMoney)) {
33: $object->amountOfMoney = $this->amountOfMoney->toObject();
34: }
35: if (!is_null($this->numberOfGiftCards)) {
36: $object->numberOfGiftCards = $this->numberOfGiftCards;
37: }
38: return $object;
39: }
40:
41: /**
42: * @param object $object
43: *
44: * @return $this
45: * @throws UnexpectedValueException
46: */
47: public function fromObject(object $object): GiftCardPurchase
48: {
49: parent::fromObject($object);
50: if (property_exists($object, 'amountOfMoney')) {
51: if (!is_object($object->amountOfMoney)) {
52: throw new UnexpectedValueException('value \'' . print_r($object->amountOfMoney, true) . '\' is not an object');
53: }
54: $value = new AmountOfMoney();
55: $this->amountOfMoney = $value->fromObject($object->amountOfMoney);
56: }
57: if (property_exists($object, 'numberOfGiftCards')) {
58: $this->numberOfGiftCards = $object->numberOfGiftCards;
59: }
60: return $this;
61: }
62: }
63: