-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathOrderLine.php
228 lines (200 loc) · 4.52 KB
/
OrderLine.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<?php
declare(strict_types=1);
namespace MyParcelNL\Sdk\src\Model\Fulfilment;
use MyParcelNL\Sdk\src\Model\BaseModel;
use MyParcelNL\Sdk\src\Support\Helpers;
class OrderLine extends BaseModel
{
/**
* Arbitrary key/value instructions
*
* @var array
*/
private $instructions;
/**
* Full price in cents, regardless of quantity, excluding VAT.
*
* @var int|null
*/
private $price;
/**
* Full price in cents, regardless of quantity, including VAT.
*
* @var int|null
*/
private $price_after_vat;
/**
* The product in this OrderLine.
*
* @var \MyParcelNL\Sdk\src\Model\Fulfilment\Product
*/
private $product;
/**
* Amount of Products in this OrderLine.
*
* @var int|null
*/
private $quantity;
/**
* Unique identifier from our API. Set after saving the order this OrderLine belongs to.
*
* @var string|null
*/
private $uuid;
/**
* VAT in cents.
*
* @var int|null
*/
private $vat;
/**
* @param array $data
*/
public function __construct(array $data = [])
{
$this->uuid = $data['uuid'] ?? null;
$this->price = Helpers::intOrNull($data['price'] ?? null);
$this->vat = Helpers::intOrNull($data['vat'] ?? null);
$this->price_after_vat = Helpers::intOrNull($data['price_after_vat'] ?? null);
$this->quantity = Helpers::intOrNull($data['quantity'] ?? null);
$this->instructions = $data['instructions'] ?? null;
$this->product = new Product($data['product'] ?? []);
}
public function __toString() {
return (string) self::class;
}
/**
* @return array
*/
public function getInstructions(): ?array
{
return $this->instructions;
}
/**
* @return int|null
*/
public function getPrice(): ?int
{
return $this->price;
}
/**
* @return int|null
*/
public function getPriceAfterVat(): ?int
{
return $this->price_after_vat;
}
/**
* @return \MyParcelNL\Sdk\src\Model\Fulfilment\Product
*/
public function getProduct(): Product
{
return $this->product;
}
/**
* @return int|null
*/
public function getQuantity(): ?int
{
return $this->quantity;
}
/**
* @return string|null
*/
public function getUuid(): ?string
{
return $this->uuid;
}
/**
* @return int|null
*/
public function getVat(): ?int
{
return $this->vat;
}
/**
* @param array $instructions
*
* @return self
*/
public function setInstructions(array $instructions): self
{
$this->instructions = $instructions;
return $this;
}
/**
* @param int|null $price
*
* @return self
*/
public function setPrice(?int $price): self
{
$this->price = $price;
return $this;
}
/**
* @param int|null $price_after_vat
*
* @return self
*/
public function setPriceAfterVat(?int $price_after_vat): self
{
$this->price_after_vat = $price_after_vat;
return $this;
}
/**
* @param \MyParcelNL\Sdk\src\Model\Fulfilment\Product $product
*
* @return self
*/
public function setProduct(Product $product): self
{
$this->product = $product;
return $this;
}
/**
* @param int|null $quantity
*
* @return self
*/
public function setQuantity(?int $quantity): self
{
$this->quantity = $quantity;
return $this;
}
/**
* @param string $uuid
*
* @return self
*/
public function setUuid(string $uuid): self
{
$this->uuid = $uuid;
return $this;
}
/**
* @param int|null $vat
*
* @return self
*/
public function setVat(?int $vat): self
{
$this->vat = $vat;
return $this;
}
/**
* @return array
*/
public function toArray(): array
{
return [
'uuid' => $this->getUuid(),
'product' => $this->getProduct()->toArray(),
'quantity' => $this->getQuantity(),
'price' => $this->getPrice(),
'vat' => $this->getVat(),
'price_after_vat' => $this->getPriceAfterVat(),
'instructions' => $this->getInstructions(),
];
}
}