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 GetDccRateRequest extends DataObject
15: {
16: /**
17: * @var CardDataForDcc|null
18: */
19: public ?CardDataForDcc $cardPaymentData = null;
20:
21: /**
22: * @var string|null
23: */
24: public ?string $operationId = null;
25:
26: /**
27: * @var DateTime|null
28: */
29: public ?DateTime $originalPaymentDate = null;
30:
31: /**
32: * @var PointOfSaleDataForDcc|null
33: */
34: public ?PointOfSaleDataForDcc $pointOfSaleData = null;
35:
36: /**
37: * @var string|null
38: */
39: public ?string $rateReferenceId = null;
40:
41: /**
42: * @var string|null
43: */
44: public ?string $targetCurrency = null;
45:
46: /**
47: * @var TransactionDataForDcc|null
48: */
49: public ?TransactionDataForDcc $transaction = null;
50:
51: /**
52: * @return object
53: */
54: public function toObject(): object
55: {
56: $object = parent::toObject();
57: if (!is_null($this->cardPaymentData)) {
58: $object->cardPaymentData = $this->cardPaymentData->toObject();
59: }
60: if (!is_null($this->operationId)) {
61: $object->operationId = $this->operationId;
62: }
63: if (!is_null($this->originalPaymentDate)) {
64: $object->originalPaymentDate = $this->originalPaymentDate->format('Y-m-d');
65: }
66: if (!is_null($this->pointOfSaleData)) {
67: $object->pointOfSaleData = $this->pointOfSaleData->toObject();
68: }
69: if (!is_null($this->rateReferenceId)) {
70: $object->rateReferenceId = $this->rateReferenceId;
71: }
72: if (!is_null($this->targetCurrency)) {
73: $object->targetCurrency = $this->targetCurrency;
74: }
75: if (!is_null($this->transaction)) {
76: $object->transaction = $this->transaction->toObject();
77: }
78: return $object;
79: }
80:
81: /**
82: * @param object $object
83: *
84: * @return $this
85: * @throws UnexpectedValueException
86: */
87: public function fromObject(object $object): GetDccRateRequest
88: {
89: parent::fromObject($object);
90: if (property_exists($object, 'cardPaymentData')) {
91: if (!is_object($object->cardPaymentData)) {
92: throw new UnexpectedValueException('value \'' . print_r($object->cardPaymentData, true) . '\' is not an object');
93: }
94: $value = new CardDataForDcc();
95: $this->cardPaymentData = $value->fromObject($object->cardPaymentData);
96: }
97: if (property_exists($object, 'operationId')) {
98: $this->operationId = $object->operationId;
99: }
100: if (property_exists($object, 'originalPaymentDate')) {
101: $this->originalPaymentDate = new DateTime($object->originalPaymentDate);
102: }
103: if (property_exists($object, 'pointOfSaleData')) {
104: if (!is_object($object->pointOfSaleData)) {
105: throw new UnexpectedValueException('value \'' . print_r($object->pointOfSaleData, true) . '\' is not an object');
106: }
107: $value = new PointOfSaleDataForDcc();
108: $this->pointOfSaleData = $value->fromObject($object->pointOfSaleData);
109: }
110: if (property_exists($object, 'rateReferenceId')) {
111: $this->rateReferenceId = $object->rateReferenceId;
112: }
113: if (property_exists($object, 'targetCurrency')) {
114: $this->targetCurrency = $object->targetCurrency;
115: }
116: if (property_exists($object, 'transaction')) {
117: if (!is_object($object->transaction)) {
118: throw new UnexpectedValueException('value \'' . print_r($object->transaction, true) . '\' is not an object');
119: }
120: $value = new TransactionDataForDcc();
121: $this->transaction = $value->fromObject($object->transaction);
122: }
123: return $this;
124: }
125: }
126: