forked from mallgroup/mpapi-client-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStatusRequest.php
103 lines (81 loc) · 2.59 KB
/
StatusRequest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php declare(strict_types=1);
namespace MpApiClient\Order\DTO;
use DateTimeInterface;
use MpApiClient\Common\Util\InputDataUtil;
use MpApiClient\Order\Entity\StatusEnum;
final class StatusRequest
{
private StatusEnum $status;
private ?bool $confirmed = null;
private ?string $trackingNumber = null;
private ?string $trackingUrl = null;
private ?DateTimeInterface $deliveredAt = null;
private ?DateTimeInterface $firstDeliveryAttempt = null;
public function __construct(StatusEnum $status)
{
$this->status = $status;
}
/**
* @return array<string, mixed>
*/
public function getArrayForApi(): array
{
$out = [
'status' => $this->getStatus()->getValue(),
];
if ($this->confirmed !== null) {
$out['confirmed'] = $this->confirmed;
}
if ($this->trackingUrl !== null) {
$out['tracking_url'] = $this->trackingUrl;
}
if ($this->trackingNumber !== null) {
$out['tracking_number'] = $this->trackingNumber;
}
if ($this->deliveredAt !== null) {
$out['delivered_at'] = $this->deliveredAt->format(InputDataUtil::DATE_TIME_FORMAT);
}
if ($this->firstDeliveryAttempt !== null) {
$out['first_delivery_attempt'] = $this->firstDeliveryAttempt->format(InputDataUtil::DATE_TIME_FORMAT);
}
return $out;
}
public function getStatus(): StatusEnum
{
return $this->status;
}
public function getConfirmed(): ?bool
{
return $this->confirmed;
}
public function setConfirmed(bool $confirmed): void
{
$this->confirmed = $confirmed;
}
public function getTrackingNumber(): ?string
{
return $this->trackingNumber;
}
public function getTrackingUrl(): ?string
{
return $this->trackingUrl;
}
public function getDeliveredAt(): ?DateTimeInterface
{
return $this->deliveredAt;
}
public function getFirstDeliveryAttempt(): ?DateTimeInterface
{
return $this->firstDeliveryAttempt;
}
public function setTracking(string $trackingNumber, string $trackingUrl): void
{
$this->trackingNumber = $trackingNumber;
$this->trackingUrl = $trackingUrl;
}
public function setDelivery(DateTimeInterface $deliveredAt, DateTimeInterface $firstDeliveryAttempt): void
{
$this->deliveredAt = $deliveredAt;
$this->firstDeliveryAttempt = $firstDeliveryAttempt;
}
}