1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Inspirum\Balikobot\Model\Values; |
4
|
|
|
|
5
|
|
|
class PackageTransportCost |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* Package batch ID (EID) |
9
|
|
|
* |
10
|
|
|
* @var string |
11
|
|
|
*/ |
12
|
|
|
private $batchId; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Shipper |
16
|
|
|
* |
17
|
|
|
* @var string |
18
|
|
|
*/ |
19
|
|
|
private $shipper; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Total cost |
23
|
|
|
* |
24
|
|
|
* @var float |
25
|
|
|
*/ |
26
|
|
|
private $totalCost; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Currency code |
30
|
|
|
* |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
private $currencyCode; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Cost breakdown |
37
|
|
|
* |
38
|
|
|
* @var array<\Inspirum\Balikobot\Model\Values\PackageTransportCostPart> |
39
|
|
|
*/ |
40
|
|
|
private $costsBreakdown; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* PackageTransportCost constructor. |
44
|
|
|
* |
45
|
|
|
* @param string $batchId |
46
|
|
|
* @param string $shipper |
47
|
|
|
* @param float $totalCost |
48
|
|
|
* @param string $currencyCode |
49
|
|
|
* @param array<\Inspirum\Balikobot\Model\Values\PackageTransportCostPart> $costsBreakdown |
50
|
|
|
*/ |
51
|
11 |
|
public function __construct( |
52
|
|
|
string $batchId, |
53
|
|
|
string $shipper, |
54
|
|
|
float $totalCost, |
55
|
|
|
string $currencyCode, |
56
|
|
|
array $costsBreakdown = [] |
57
|
|
|
) { |
58
|
11 |
|
$this->batchId = $batchId; |
59
|
11 |
|
$this->shipper = $shipper; |
60
|
11 |
|
$this->totalCost = $totalCost; |
61
|
11 |
|
$this->currencyCode = $currencyCode; |
62
|
11 |
|
$this->costsBreakdown = $costsBreakdown; |
63
|
11 |
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return string |
67
|
|
|
*/ |
68
|
6 |
|
public function getBatchId(): string |
69
|
|
|
{ |
70
|
6 |
|
return $this->batchId; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return string |
75
|
|
|
*/ |
76
|
11 |
|
public function getShipper(): string |
77
|
|
|
{ |
78
|
11 |
|
return $this->shipper; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return float |
83
|
|
|
*/ |
84
|
5 |
|
public function getTotalCost(): float |
85
|
|
|
{ |
86
|
5 |
|
return $this->totalCost; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return string |
91
|
|
|
*/ |
92
|
5 |
|
public function getCurrencyCode(): string |
93
|
|
|
{ |
94
|
5 |
|
return $this->currencyCode; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @return array<\Inspirum\Balikobot\Model\Values\PackageTransportCostPart>|\Inspirum\Balikobot\Model\Values\PackageTransportCostPart[] |
99
|
|
|
*/ |
100
|
2 |
|
public function getCostsBreakdown(): array |
101
|
|
|
{ |
102
|
2 |
|
return $this->costsBreakdown; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @param string $shipper |
107
|
|
|
* @param array<string,mixed> $data |
108
|
|
|
* |
109
|
|
|
* @return \Inspirum\Balikobot\Model\Values\PackageTransportCost |
110
|
|
|
*/ |
111
|
4 |
|
public static function newInstanceFromData(string $shipper, array $data): self |
112
|
|
|
{ |
113
|
4 |
|
return new self( |
114
|
4 |
|
$data['eid'], |
115
|
|
|
$shipper, |
116
|
4 |
|
$data['costs_total'], |
117
|
4 |
|
$data['currency'], |
118
|
|
|
array_map(function (array $part) use ($data) { |
119
|
3 |
|
return new PackageTransportCostPart($part['name'], $part['cost'], $data['currency']); |
120
|
4 |
|
}, $data['costs_breakdown'] ?? []) |
121
|
|
|
); |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|