1: | <?php |
2: | |
3: | |
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: | |
13: | |
14: | class ApiPaymentSummaryForResponse extends DataObject |
15: | { |
16: | |
17: | |
18: | |
19: | public $paymentId = null; |
20: | |
21: | |
22: | |
23: | |
24: | public $references = null; |
25: | |
26: | |
27: | |
28: | |
29: | public $retryAfter = null; |
30: | |
31: | |
32: | |
33: | |
34: | public $status = null; |
35: | |
36: | |
37: | |
38: | |
39: | public $statusTimestamp = null; |
40: | |
41: | |
42: | |
43: | |
44: | public function toObject() |
45: | { |
46: | $object = parent::toObject(); |
47: | if (!is_null($this->paymentId)) { |
48: | $object->paymentId = $this->paymentId; |
49: | } |
50: | if (!is_null($this->references)) { |
51: | $object->references = $this->references->toObject(); |
52: | } |
53: | if (!is_null($this->retryAfter)) { |
54: | $object->retryAfter = $this->retryAfter; |
55: | } |
56: | if (!is_null($this->status)) { |
57: | $object->status = $this->status; |
58: | } |
59: | if (!is_null($this->statusTimestamp)) { |
60: | $object->statusTimestamp = $this->statusTimestamp->format('Y-m-d\\TH:i:s.vP'); |
61: | } |
62: | return $object; |
63: | } |
64: | |
65: | |
66: | |
67: | |
68: | |
69: | |
70: | public function fromObject($object) |
71: | { |
72: | parent::fromObject($object); |
73: | if (property_exists($object, 'paymentId')) { |
74: | $this->paymentId = $object->paymentId; |
75: | } |
76: | if (property_exists($object, 'references')) { |
77: | if (!is_object($object->references)) { |
78: | throw new UnexpectedValueException('value \'' . print_r($object->references, true) . '\' is not an object'); |
79: | } |
80: | $value = new ApiReferencesForResponses(); |
81: | $this->references = $value->fromObject($object->references); |
82: | } |
83: | if (property_exists($object, 'retryAfter')) { |
84: | $this->retryAfter = $object->retryAfter; |
85: | } |
86: | if (property_exists($object, 'status')) { |
87: | $this->status = $object->status; |
88: | } |
89: | if (property_exists($object, 'statusTimestamp')) { |
90: | $this->statusTimestamp = new DateTime($object->statusTimestamp); |
91: | } |
92: | return $this; |
93: | } |
94: | } |
95: | |