|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
namespace floor12\MindBox; |
|
5
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
abstract class MindBoxRequest |
|
8
|
|
|
{ |
|
9
|
|
|
/** @var string */ |
|
10
|
|
|
protected $operationName; |
|
11
|
|
|
/** @var array */ |
|
12
|
|
|
protected $body = []; |
|
13
|
|
|
/** @var string|null */ |
|
14
|
|
|
protected $deviceUUID; |
|
15
|
|
|
/** @var int */ |
|
16
|
|
|
protected $mode = MindBoxClient::MODE_SYNCHRONOUS; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @param string|null $operationName |
|
20
|
|
|
* @param array|null $body |
|
21
|
|
|
* @param int|null $mode |
|
22
|
|
|
* @param string|null $deviceUUID |
|
23
|
|
|
*/ |
|
24
|
7 |
|
public function __construct( |
|
25
|
|
|
string $operationName = null, |
|
26
|
|
|
array $body = null, |
|
27
|
|
|
int $mode = null, |
|
28
|
|
|
string $deviceUUID = null) |
|
29
|
|
|
{ |
|
30
|
7 |
|
$this->operationName = $operationName; |
|
31
|
7 |
|
$this->body = $body; |
|
32
|
7 |
|
$this->mode = $mode; |
|
33
|
7 |
|
$this->deviceUUID = $deviceUUID; |
|
34
|
7 |
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @return string |
|
38
|
|
|
*/ |
|
39
|
2 |
|
public function getOperationName() |
|
40
|
|
|
{ |
|
41
|
2 |
|
return $this->operationName; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @return string|null |
|
46
|
|
|
*/ |
|
47
|
2 |
|
public function getDeviceUUID(): ?string |
|
48
|
|
|
{ |
|
49
|
2 |
|
return $this->deviceUUID; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @return array |
|
54
|
|
|
*/ |
|
55
|
2 |
|
public function getBody(): array |
|
56
|
|
|
{ |
|
57
|
2 |
|
return $this->body; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @return string |
|
62
|
|
|
*/ |
|
63
|
2 |
|
public function getBodyAsJson(): string |
|
64
|
|
|
{ |
|
65
|
2 |
|
return json_encode($this->body); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @return int |
|
70
|
|
|
*/ |
|
71
|
1 |
|
public function getMode(): int |
|
72
|
|
|
{ |
|
73
|
1 |
|
return $this->mode; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @return bool |
|
78
|
|
|
*/ |
|
79
|
2 |
|
public function isAsync(): bool |
|
80
|
|
|
{ |
|
81
|
2 |
|
return $this->mode === MindBoxClient::MODE_ASYNCHRONOUS; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @param string|null $deviceUUID |
|
86
|
|
|
*/ |
|
87
|
1 |
|
public function setDeviceUUID(?string $deviceUUID): void |
|
88
|
|
|
{ |
|
89
|
1 |
|
$this->deviceUUID = $deviceUUID; |
|
90
|
1 |
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @param int $mode |
|
94
|
|
|
*/ |
|
95
|
3 |
|
public function setMode(int $mode): void |
|
96
|
|
|
{ |
|
97
|
3 |
|
$this->mode = $mode; |
|
98
|
3 |
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @param mixed $operationName |
|
102
|
|
|
*/ |
|
103
|
1 |
|
public function setOperationName($operationName): void |
|
104
|
|
|
{ |
|
105
|
1 |
|
$this->operationName = $operationName; |
|
106
|
1 |
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* @param array $body |
|
110
|
|
|
*/ |
|
111
|
2 |
|
public function setBody(array $body): void |
|
112
|
|
|
{ |
|
113
|
2 |
|
$this->body = $body; |
|
114
|
2 |
|
} |
|
115
|
|
|
|
|
116
|
|
|
|
|
117
|
|
|
} |
|
118
|
|
|
|