forked from mallgroup/mpapi-client-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBasicOrder.php
186 lines (161 loc) · 4.68 KB
/
BasicOrder.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?php declare(strict_types=1);
namespace MpApiClient\Order\Entity;
use DateTimeInterface;
use Exception;
use JsonSerializable;
use MpApiClient\Common\Util\InputDataUtil;
use MpApiClient\Common\Util\JsonSerializeEntityTrait;
final class BasicOrder implements JsonSerializable
{
use JsonSerializeEntityTrait;
private int $id;
private ?string $externalId;
private int $purchaseId;
private int $customerId;
private string $customer;
private float $cod;
private string $paymentType;
private ?DateTimeInterface $shipDate;
private ?string $trackingNumber;
private ?string $trackingUrl;
private ?DateTimeInterface $deliveredAt;
private StatusEnum $status;
private bool $confirmed;
private bool $test;
private bool $mdp;
private bool $mdpSpectrum;
private bool $mdpClassic;
private function __construct(
int $id,
?string $externalId,
int $purchaseId,
int $customerId,
string $customer,
float $cod,
string $paymentType,
?DateTimeInterface $shipDate,
?string $trackingNumber,
?string $trackingUrl,
?DateTimeInterface $deliveredAt,
StatusEnum $status,
bool $confirmed,
bool $test,
bool $mdp,
bool $mdpClassic,
bool $mdpSpectrum
) {
$this->id = $id;
$this->externalId = $externalId;
$this->purchaseId = $purchaseId;
$this->customerId = $customerId;
$this->customer = $customer;
$this->cod = $cod;
$this->paymentType = $paymentType;
$this->shipDate = $shipDate;
$this->trackingNumber = $trackingNumber;
$this->trackingUrl = $trackingUrl;
$this->deliveredAt = $deliveredAt;
$this->status = $status;
$this->confirmed = $confirmed;
$this->test = $test;
$this->mdp = $mdp;
$this->mdpClassic = $mdpClassic;
$this->mdpSpectrum = $mdpSpectrum;
}
/**
* @param array<string, mixed> $data
*
* @throws Exception
* @internal
*/
public static function createFromApi(array $data): self
{
return new self(
(int) $data['id'],
$data['external_id'] ?? null,
(int) $data['purchase_id'],
(int) $data['customer_id'],
(string) $data['customer'],
(float) $data['cod'],
(string) $data['payment_type'],
InputDataUtil::getNullableDate($data, 'ship_date'),
InputDataUtil::getNullableString($data, 'tracking_number'),
InputDataUtil::getNullableString($data, 'tracking_url'),
InputDataUtil::getNullableDate($data, 'delivered_at'),
new StatusEnum((string) $data[StatusEnum::KEY_NAME]),
(bool) $data['confirmed'],
(bool) $data['test'],
(bool) $data['mdp'],
(bool) $data['mdp_classic'],
(bool) $data['mdp_spectrum'],
);
}
public function getId(): int
{
return $this->id;
}
public function getExternalId(): ?string
{
return $this->externalId;
}
public function getPurchaseId(): int
{
return $this->purchaseId;
}
public function getCustomerId(): int
{
return $this->customerId;
}
public function getCustomer(): string
{
return $this->customer;
}
public function getCod(): float
{
return $this->cod;
}
public function getPaymentType(): string
{
return $this->paymentType;
}
public function getShipDate(): ?DateTimeInterface
{
return $this->shipDate;
}
public function getTrackingNumber(): ?string
{
return $this->trackingNumber;
}
public function getTrackingUrl(): ?string
{
return $this->trackingUrl;
}
public function getDeliveredAt(): ?DateTimeInterface
{
return $this->deliveredAt;
}
public function getStatus(): StatusEnum
{
return $this->status;
}
public function isConfirmed(): bool
{
return $this->confirmed;
}
public function isTest(): bool
{
return $this->test;
}
public function isMdp(): bool
{
return $this->mdp;
}
public function isMdpSpectrum(): bool
{
return $this->mdpSpectrum;
}
public function isMdpClassic(): bool
{
return $this->mdpClassic;
}
}