1 | <?php |
||
10 | class Shipping |
||
11 | { |
||
12 | /** |
||
13 | * Requires fields in Shipping. |
||
14 | * |
||
15 | * @var array |
||
16 | */ |
||
17 | public static $requiredFields = [ |
||
18 | 'cep_origem', |
||
19 | 'cep_destino', |
||
20 | 'valor_notafiscal', |
||
21 | ]; |
||
22 | |||
23 | /** |
||
24 | * Token string to Axado. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | public static $token; |
||
29 | |||
30 | /** |
||
31 | * All attributes. |
||
32 | * |
||
33 | * @var array |
||
34 | */ |
||
35 | protected $attributes = []; |
||
36 | |||
37 | /** |
||
38 | * All volumes objects. |
||
39 | * |
||
40 | * @var array |
||
41 | */ |
||
42 | protected $volumes = []; |
||
43 | |||
44 | /** |
||
45 | * FormatterInterface instance. |
||
46 | * |
||
47 | * @var FormatterInterface |
||
48 | */ |
||
49 | protected $formatter; |
||
50 | |||
51 | /** |
||
52 | * Axado\Request instance. |
||
53 | * |
||
54 | * @var Request |
||
55 | */ |
||
56 | protected $request; |
||
57 | |||
58 | /** |
||
59 | * Axado\Response instance. |
||
60 | * |
||
61 | * @var Response |
||
62 | */ |
||
63 | protected $response; |
||
64 | |||
65 | /** |
||
66 | * Constructor. |
||
67 | * |
||
68 | * @param \Axado\Formatter\FormatterInterface $formatter |
||
69 | */ |
||
70 | public function __construct(FormatterInterface $formatter = null) |
||
74 | |||
75 | /** |
||
76 | * Consult this shipping through api. |
||
77 | * |
||
78 | * @throws ShippingException |
||
79 | * |
||
80 | * @return array |
||
81 | */ |
||
82 | public function quotations() |
||
95 | |||
96 | /** |
||
97 | * Returns the first quotation. |
||
98 | * |
||
99 | * @throws QuotationNotFoundException |
||
100 | * |
||
101 | * @return Quotation |
||
102 | */ |
||
103 | public function firstQuotation(): Quotation |
||
116 | |||
117 | /** |
||
118 | * Get the first quotation and return the price. |
||
119 | * |
||
120 | * @return string|null |
||
121 | */ |
||
122 | public function getCosts() |
||
126 | |||
127 | /** |
||
128 | * Get the first quotation and return the price. |
||
129 | * |
||
130 | * @return string|null |
||
131 | */ |
||
132 | public function getDeadline() |
||
136 | |||
137 | /** |
||
138 | * Return the attributes. |
||
139 | * |
||
140 | * @return array |
||
141 | */ |
||
142 | public function getAttributes(): array |
||
146 | |||
147 | /** |
||
148 | * Setter to Postal Code origin. |
||
149 | * |
||
150 | * @param string $cep |
||
151 | */ |
||
152 | public function setPostalCodeOrigin($cep) |
||
156 | |||
157 | /** |
||
158 | * Setter to Postal Code destination. |
||
159 | * |
||
160 | * @param string $cep |
||
161 | */ |
||
162 | public function setPostalCodeDestination($cep) |
||
166 | |||
167 | /** |
||
168 | * Setter to Total price of sale. |
||
169 | * |
||
170 | * @param float $price |
||
171 | */ |
||
172 | public function setTotalPrice($price) |
||
178 | |||
179 | /** |
||
180 | * Setter to Additional price to add to shipping costs. |
||
181 | * |
||
182 | * @param float $price |
||
183 | */ |
||
184 | public function setAdditionalPrice($price) |
||
190 | |||
191 | /** |
||
192 | * Calculate the additional price. |
||
193 | * |
||
194 | * @param string $price |
||
195 | * |
||
196 | * @return float |
||
197 | */ |
||
198 | public function calculateAdditionalPrice($price) |
||
215 | |||
216 | /** |
||
217 | * Getter to Total price of sale. |
||
218 | * |
||
219 | * @return float|null |
||
220 | */ |
||
221 | public function getTotalPrice() |
||
225 | |||
226 | /** |
||
227 | * Getter to of Additional price. |
||
228 | * |
||
229 | * @return float|null |
||
230 | */ |
||
231 | public function getAdditionalPrice() |
||
235 | |||
236 | /** |
||
237 | * Setter to additional days. |
||
238 | * |
||
239 | * @param int $days |
||
240 | */ |
||
241 | public function setAdditionalDays($days) |
||
245 | |||
246 | /** |
||
247 | * Add a volume object to send through Axado api. |
||
248 | * |
||
249 | * @param VolumeInterface $volume |
||
250 | */ |
||
251 | public function addVolume(VolumeInterface $volume) |
||
255 | |||
256 | /** |
||
257 | * Return all volumes at this instance. |
||
258 | * |
||
259 | * @return array |
||
260 | */ |
||
261 | public function allVolumes(): array |
||
265 | |||
266 | /** |
||
267 | * Clean all volumes. |
||
268 | */ |
||
269 | public function clearVolumes() |
||
273 | |||
274 | /** |
||
275 | * Verify is this instance is Valid. |
||
276 | * |
||
277 | * @return bool |
||
278 | */ |
||
279 | protected function isValid(): bool |
||
289 | |||
290 | /** |
||
291 | * Returns a new instance of Request. |
||
292 | * |
||
293 | * @param string $token |
||
294 | * |
||
295 | * @return Request |
||
296 | */ |
||
297 | protected function newRequest(string $token): Request |
||
301 | |||
302 | /** |
||
303 | * Return this object in json format. |
||
304 | * |
||
305 | * @return string |
||
306 | */ |
||
307 | protected function toJson(): string |
||
313 | |||
314 | /** |
||
315 | * Getter of postal code destination. |
||
316 | * |
||
317 | * @return string|null |
||
318 | */ |
||
319 | protected function getPostalCodeDestination() |
||
323 | } |
||
324 |