|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Waredesk\Models\Product; |
|
4
|
|
|
|
|
5
|
|
|
use DateTime; |
|
6
|
|
|
use JsonSerializable; |
|
7
|
|
|
use Waredesk\Collections\Products\Variants\Codes; |
|
8
|
|
|
use Waredesk\Collections\Products\Variants\Options; |
|
9
|
|
|
use Waredesk\Collections\Products\Variants\Prices; |
|
10
|
|
|
use Waredesk\Image; |
|
11
|
|
|
|
|
12
|
|
|
class Variant implements JsonSerializable |
|
13
|
|
|
{ |
|
14
|
|
|
private $id; |
|
15
|
|
|
private $images; |
|
16
|
|
|
private $options; |
|
17
|
|
|
private $codes; |
|
18
|
|
|
private $prices; |
|
19
|
|
|
private $description; |
|
20
|
|
|
private $notes; |
|
21
|
|
|
private $weight_unit; |
|
22
|
|
|
private $length_unit; |
|
23
|
|
|
private $weight; |
|
24
|
|
|
private $width; |
|
25
|
|
|
private $height; |
|
26
|
|
|
private $depth; |
|
27
|
|
|
private $creation_datetime; |
|
28
|
|
|
private $modification_datetime; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var Image |
|
32
|
|
|
*/ |
|
33
|
|
|
private $pendingImage; |
|
34
|
|
|
|
|
35
|
2 |
|
public function __construct() |
|
36
|
|
|
{ |
|
37
|
2 |
|
$this->options = new Options(); |
|
38
|
2 |
|
$this->codes = new Codes(); |
|
39
|
2 |
|
$this->prices = new Prices(); |
|
40
|
2 |
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function getId(): ?int |
|
43
|
|
|
{ |
|
44
|
|
|
return $this->id; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
2 |
|
public function setId(int $id = null) |
|
48
|
|
|
{ |
|
49
|
2 |
|
$this->id = $id; |
|
50
|
2 |
|
} |
|
51
|
|
|
|
|
52
|
1 |
|
public function getImages(): ?array |
|
53
|
|
|
{ |
|
54
|
1 |
|
return $this->images; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
2 |
|
public function setImages(array $images = null) |
|
58
|
|
|
{ |
|
59
|
2 |
|
$this->pendingImage = null; |
|
60
|
2 |
|
$this->images = $images; |
|
61
|
2 |
|
} |
|
62
|
|
|
|
|
63
|
1 |
|
public function setImage(Image $image = null) |
|
64
|
|
|
{ |
|
65
|
1 |
|
$this->pendingImage = $image; |
|
66
|
1 |
|
} |
|
67
|
|
|
|
|
68
|
2 |
|
public function getOptions(): ?Options |
|
69
|
|
|
{ |
|
70
|
2 |
|
return $this->options; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
2 |
|
public function setOptions(Options $options) |
|
74
|
|
|
{ |
|
75
|
2 |
|
$this->options = $options; |
|
76
|
2 |
|
} |
|
77
|
|
|
|
|
78
|
2 |
|
public function getCodes(): ?Codes |
|
79
|
|
|
{ |
|
80
|
2 |
|
return $this->codes; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
2 |
|
public function setCodes(Codes $codes) |
|
84
|
|
|
{ |
|
85
|
2 |
|
$this->codes = $codes; |
|
86
|
2 |
|
} |
|
87
|
|
|
|
|
88
|
2 |
|
public function getPrices(): ?Prices |
|
89
|
|
|
{ |
|
90
|
2 |
|
return $this->prices; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
2 |
|
public function setPrices(Prices $prices) |
|
94
|
|
|
{ |
|
95
|
2 |
|
$this->prices = $prices; |
|
96
|
2 |
|
} |
|
97
|
|
|
|
|
98
|
2 |
|
public function getDescription(): ?string |
|
99
|
|
|
{ |
|
100
|
2 |
|
return $this->description; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
2 |
|
public function setDescription(string $description = null) |
|
104
|
|
|
{ |
|
105
|
2 |
|
$this->description = $description; |
|
106
|
2 |
|
} |
|
107
|
|
|
|
|
108
|
2 |
|
public function getNotes(): ?string |
|
109
|
|
|
{ |
|
110
|
2 |
|
return $this->notes; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
2 |
|
public function setNotes(string $notes = null) |
|
114
|
|
|
{ |
|
115
|
2 |
|
$this->notes = $notes; |
|
116
|
2 |
|
} |
|
117
|
|
|
|
|
118
|
2 |
|
public function getWeightUnit(): ?string |
|
119
|
|
|
{ |
|
120
|
2 |
|
return $this->weight_unit; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
2 |
|
public function setWeightUnit(string $weight_unit = null) |
|
124
|
|
|
{ |
|
125
|
2 |
|
$this->weight_unit = $weight_unit; |
|
126
|
2 |
|
} |
|
127
|
|
|
|
|
128
|
2 |
|
public function getLengthUnit(): ?string |
|
129
|
|
|
{ |
|
130
|
2 |
|
return $this->length_unit; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
2 |
|
public function setLengthUnit(string $length_unit = null) |
|
134
|
|
|
{ |
|
135
|
2 |
|
$this->length_unit = $length_unit; |
|
136
|
2 |
|
} |
|
137
|
|
|
|
|
138
|
2 |
|
public function getWeight(): ?float |
|
139
|
|
|
{ |
|
140
|
2 |
|
return $this->weight; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
2 |
|
public function setWeight(float $weight = null) |
|
144
|
|
|
{ |
|
145
|
2 |
|
$this->weight = $weight; |
|
146
|
2 |
|
} |
|
147
|
|
|
|
|
148
|
2 |
|
public function getWidth(): ?float |
|
149
|
|
|
{ |
|
150
|
2 |
|
return $this->width; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
2 |
|
public function setWidth(float $width = null) |
|
154
|
|
|
{ |
|
155
|
2 |
|
$this->width = $width; |
|
156
|
2 |
|
} |
|
157
|
|
|
|
|
158
|
2 |
|
public function getHeight(): ?float |
|
159
|
|
|
{ |
|
160
|
2 |
|
return $this->height; |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
2 |
|
public function setHeight(float $height = null) |
|
164
|
|
|
{ |
|
165
|
2 |
|
$this->height = $height; |
|
166
|
2 |
|
} |
|
167
|
|
|
|
|
168
|
2 |
|
public function getDepth(): ?float |
|
169
|
|
|
{ |
|
170
|
2 |
|
return $this->depth; |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
2 |
|
public function setDepth(float $depth = null) |
|
174
|
|
|
{ |
|
175
|
2 |
|
$this->depth = $depth; |
|
176
|
2 |
|
} |
|
177
|
|
|
|
|
178
|
|
|
public function getCreationDatetime(): ?DateTime |
|
179
|
|
|
{ |
|
180
|
|
|
return $this->creation_datetime; |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
2 |
|
public function setCreationDatetime(DateTime $creation_datetime = null) |
|
184
|
|
|
{ |
|
185
|
2 |
|
$this->creation_datetime = $creation_datetime; |
|
186
|
2 |
|
} |
|
187
|
|
|
|
|
188
|
|
|
public function getModificationDatetime(): ?DateTime |
|
189
|
|
|
{ |
|
190
|
|
|
return $this->modification_datetime; |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
2 |
|
public function setModificationDatetime(DateTime $modification_datetime = null) |
|
194
|
|
|
{ |
|
195
|
2 |
|
$this->modification_datetime = $modification_datetime; |
|
196
|
2 |
|
} |
|
197
|
|
|
|
|
198
|
2 |
|
public function jsonSerialize() |
|
199
|
|
|
{ |
|
200
|
|
|
$returnValue = [ |
|
201
|
2 |
|
'description' => $this->getDescription(), |
|
202
|
2 |
|
'notes' => $this->getNotes(), |
|
203
|
2 |
|
'options' => $this->getOptions()->jsonSerialize(), |
|
204
|
2 |
|
'codes' => $this->getCodes()->jsonSerialize(), |
|
205
|
2 |
|
'prices' => $this->getPrices()->jsonSerialize(), |
|
206
|
2 |
|
'weight_unit' => $this->getWeightUnit(), |
|
207
|
2 |
|
'length_unit' => $this->getLengthUnit(), |
|
208
|
2 |
|
'weight' => $this->getWeight(), |
|
209
|
2 |
|
'width' => $this->getWidth(), |
|
210
|
2 |
|
'height' => $this->getHeight(), |
|
211
|
2 |
|
'depth' => $this->getDepth(), |
|
212
|
|
|
]; |
|
213
|
2 |
|
if ($this->pendingImage) { |
|
214
|
1 |
|
$returnValue['image'] = $this->pendingImage->toBase64(); |
|
215
|
|
|
} |
|
216
|
2 |
|
return $returnValue; |
|
217
|
|
|
} |
|
218
|
|
|
} |
|
219
|
|
|
|