1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Appwilio\RussianPostSDK\Dispatching\Endpoints\Services\Requests; |
6
|
|
|
|
7
|
|
|
use Appwilio\RussianPostSDK\Dispatching\Contracts\Arrayable; |
8
|
|
|
|
9
|
|
|
final class CalculationRequest implements Arrayable |
10
|
|
|
{ |
11
|
|
|
/** @var array */ |
12
|
|
|
private $data; |
13
|
|
|
|
14
|
|
|
public static function create(string $to, int $mass): self |
15
|
|
|
{ |
16
|
|
|
return new self(...\func_get_args()); |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
public function __construct(string $to, int $mass) |
20
|
|
|
{ |
21
|
|
|
$this->data = [ |
22
|
|
|
'index-to' => $to, |
23
|
|
|
'mass' => $mass, |
24
|
|
|
]; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function ofEntriesType(string $entriesType) |
28
|
|
|
{ |
29
|
|
|
$this->data['entries-type'] = $entriesType; |
30
|
|
|
|
31
|
|
|
return $this; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function ofMailCategory(string $mailCategory) |
35
|
|
|
{ |
36
|
|
|
$this->data['mail-category'] = $mailCategory; |
37
|
|
|
|
38
|
|
|
return $this; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function ofMailType(string $mailType) |
42
|
|
|
{ |
43
|
|
|
$this->data['mail-type'] = $mailType; |
44
|
|
|
|
45
|
|
|
return $this; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function dimensions(int $height, int $width, int $length) |
49
|
|
|
{ |
50
|
|
|
$this->data['dimension'] = \compact('height', 'width', 'length'); |
51
|
|
|
|
52
|
|
|
return $this; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function fragile(bool $value = true) |
56
|
|
|
{ |
57
|
|
|
$this->data['fragile'] = $value; |
58
|
|
|
|
59
|
|
|
return $this; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function viaCourier(bool $value = true) |
63
|
|
|
{ |
64
|
|
|
$this->data['courier'] = $value; |
65
|
|
|
|
66
|
|
|
return $this; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function withDeclaredValue(int $value) |
70
|
|
|
{ |
71
|
|
|
$this->data['declared-value'] = $value; |
72
|
|
|
|
73
|
|
|
return $this; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function withCompletenessChecking(bool $value = true) |
77
|
|
|
{ |
78
|
|
|
$this->data['completeness-checking'] = $value; |
79
|
|
|
|
80
|
|
|
return $this; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function withSimpleNotice(bool $value = true) |
84
|
|
|
{ |
85
|
|
|
$this->data['with-simple-notice'] = $value; |
86
|
|
|
|
87
|
|
|
return $this; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function withRegisteredNotice(bool $value = true) |
91
|
|
|
{ |
92
|
|
|
$this->data['with-order-of-notice'] = $value; |
93
|
|
|
|
94
|
|
|
return $this; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function withSmsNotice(bool $value = true) |
98
|
|
|
{ |
99
|
|
|
$this->data['sms-notice-recipient'] = $value; |
100
|
|
|
|
101
|
|
|
return $this; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function toArray(): array |
105
|
|
|
{ |
106
|
|
|
return $this->data; |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|