-
Notifications
You must be signed in to change notification settings - Fork 123
Expand file tree
/
Copy pathKeyboard.php
More file actions
172 lines (153 loc) · 3.65 KB
/
Keyboard.php
File metadata and controls
172 lines (153 loc) · 3.65 KB
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
<?php
namespace Viber\Api;
/**
* Message keyboard
*
* The keyboard can be attached to any message type or sent on it’s on.
* Once received, the keyboard will appear to the user instead of the device’s
* native keyboard. The client will always display the last keyboard
* that was sent to it.
*
* @see https://developers.viber.com/tools/keyboards/index.html
*
* @author Novikov Bogdan <hcbogdan@gmail.com>
*/
class Keyboard extends Entity
{
/**
* Array containing all keyboard buttons by order
*
* @var array
*/
protected $Buttons;
/**
* Background color of the keyboard (HEX)
*
* @var string
*/
protected $BgColor;
/**
* When true - the keyboard will always be displayed with the same height
* as the native keyboard.When false - short keyboards will be displayed
* with the minimal possible height. Maximal height will be native
* keyboard height
*
* @var boolean
*/
protected $DefaultHeight;
/**
* optional (api level 4). Customize the keyboard input field.
* regular-display regular size input field.
* minimized - display input field minimized by default.
* hidden - hide the input field
*
* @var string
*/
protected $InputFieldState;
/**
* {@inheritDoc}
*/
public function toArray()
{
return [
'Type' => 'keyboard',
'Buttons' => $this->getButtonsApiArray(),
'BgColor' => $this->getBgColor(),
'InputFieldState' => $this->getInputFieldState(),
'DefaultHeight' => $this->getDefaultHeight(),
];
}
/**
* Build buttons api array
*
* @return array
*/
protected function getButtonsApiArray()
{
$buttons = [];
foreach ($this->getButtons() as $i) {
$buttons[] = $i->toApiArray();
}
return $buttons;
}
/**
* Get the value of Array containing all keyboard buttons by order
*
* @return array
*/
public function getButtons()
{
return $this->Buttons;
}
/**
* Set the value of Array containing all keyboard buttons by order
*
* @param array Buttons
*
* @return self
*/
public function setButtons(array $Buttons)
{
$this->Buttons = $Buttons;
return $this;
}
/**
* Get the value of Background color of the keyboard (HEX)
*
* @return string
*/
public function getBgColor()
{
return $this->BgColor;
}
/**
* Set the value of Background color of the keyboard (HEX)
*
* @param string BgColor
*
* @return self
*/
public function setBgColor($BgColor)
{
$this->BgColor = $BgColor;
return $this;
}
/**
* Get the value of When true - the keyboard will always be displayed with the same height
*
* @return boolean
*/
public function getDefaultHeight()
{
return $this->DefaultHeight;
}
/**
* Set the value of When true - the keyboard will always be displayed with the same height
*
* @param boolean DefaultHeight
*
* @return self
*/
public function setDefaultHeight($DefaultHeight)
{
$this->DefaultHeight = $DefaultHeight;
return $this;
}
/**
* @return string
*/
public function getInputFieldState()
{
return $this->InputFieldState;
}
/**
* @param boolean DefaultHeight
*
* @return self
*/
public function setInputFieldState($fieldState)
{
$this->InputFieldState = $fieldState;
return $this;
}
}