1: <?php
2: /*
3: * This file was automatically generated.
4: */
5: namespace Worldline\Acquiring\Sdk\V1\Domain;
6:
7: use DateTime;
8: use UnexpectedValueException;
9: use Worldline\Acquiring\Sdk\Domain\DataObject;
10:
11: /**
12: * @package Worldline\Acquiring\Sdk\V1\Domain
13: */
14: class TransactionDataForDcc extends DataObject
15: {
16: /**
17: * @var AmountData|null
18: */
19: public ?AmountData $amount = null;
20:
21: /**
22: * @var DateTime|null
23: */
24: public ?DateTime $transactionTimestamp = null;
25:
26: /**
27: * @var string|null
28: */
29: public ?string $transactionType = null;
30:
31: /**
32: * @return object
33: */
34: public function toObject(): object
35: {
36: $object = parent::toObject();
37: if (!is_null($this->amount)) {
38: $object->amount = $this->amount->toObject();
39: }
40: if (!is_null($this->transactionTimestamp)) {
41: $object->transactionTimestamp = $this->transactionTimestamp->format('Y-m-d\\TH:i:s.vP');
42: }
43: if (!is_null($this->transactionType)) {
44: $object->transactionType = $this->transactionType;
45: }
46: return $object;
47: }
48:
49: /**
50: * @param object $object
51: *
52: * @return $this
53: * @throws UnexpectedValueException
54: */
55: public function fromObject(object $object): TransactionDataForDcc
56: {
57: parent::fromObject($object);
58: if (property_exists($object, 'amount')) {
59: if (!is_object($object->amount)) {
60: throw new UnexpectedValueException('value \'' . print_r($object->amount, true) . '\' is not an object');
61: }
62: $value = new AmountData();
63: $this->amount = $value->fromObject($object->amount);
64: }
65: if (property_exists($object, 'transactionTimestamp')) {
66: $this->transactionTimestamp = new DateTime($object->transactionTimestamp);
67: }
68: if (property_exists($object, 'transactionType')) {
69: $this->transactionType = $object->transactionType;
70: }
71: return $this;
72: }
73: }
74: