2
2
3
3
namespace BotMan \Drivers \Hangouts ;
4
4
5
- use BotMan \BotMan \Users \User ;
6
- use Illuminate \Support \Collection ;
5
+ use BotMan \BotMan \Drivers \Events \GenericEvent ;
7
6
use BotMan \BotMan \Drivers \HttpDriver ;
7
+ use BotMan \BotMan \Messages \Attachments \Image ;
8
8
use BotMan \BotMan \Messages \Incoming \Answer ;
9
+ use BotMan \BotMan \Messages \Incoming \IncomingMessage ;
10
+ use BotMan \BotMan \Messages \Outgoing \OutgoingMessage ;
9
11
use BotMan \BotMan \Messages \Outgoing \Question ;
12
+ use BotMan \BotMan \Users \User ;
13
+ use Illuminate \Support \Collection ;
14
+ use Symfony \Component \HttpFoundation \JsonResponse ;
15
+ use Symfony \Component \HttpFoundation \ParameterBag ;
10
16
use Symfony \Component \HttpFoundation \Request ;
11
- use BotMan \BotMan \Messages \Attachments \Image ;
12
17
use Symfony \Component \HttpFoundation \Response ;
13
- use BotMan \BotMan \Drivers \Events \GenericEvent ;
14
- use Symfony \Component \HttpFoundation \ParameterBag ;
15
- use Symfony \Component \HttpFoundation \JsonResponse ;
16
- use BotMan \BotMan \Messages \Incoming \IncomingMessage ;
17
- use BotMan \BotMan \Messages \Outgoing \OutgoingMessage ;
18
18
19
19
class HangoutsDriver extends HttpDriver
20
20
{
@@ -24,6 +24,7 @@ class HangoutsDriver extends HttpDriver
24
24
25
25
/**
26
26
* @param Request $request
27
+ *
27
28
* @return void
28
29
*/
29
30
public function buildPayload (Request $ request )
@@ -96,12 +97,14 @@ protected function loadMessages()
96
97
*/
97
98
public function isConfigured ()
98
99
{
99
- return ! empty ($ this ->config ->get ('token ' ));
100
+ return !empty ($ this ->config ->get ('token ' ));
100
101
}
101
102
102
103
/**
103
104
* Retrieve User information.
105
+ *
104
106
* @param \BotMan\BotMan\Messages\Incoming\IncomingMessage $matchingMessage
107
+ *
105
108
* @return User
106
109
*/
107
110
public function getUser (IncomingMessage $ matchingMessage )
@@ -115,6 +118,7 @@ public function getUser(IncomingMessage $matchingMessage)
115
118
116
119
/**
117
120
* @param \BotMan\BotMan\Messages\Incoming\IncomingMessage $message
121
+ *
118
122
* @return Answer
119
123
*/
120
124
public function getConversationAnswer (IncomingMessage $ message )
@@ -124,35 +128,36 @@ public function getConversationAnswer(IncomingMessage $message)
124
128
125
129
/**
126
130
* @param OutgoingMessage|\BotMan\BotMan\Messages\Outgoing\Question $message
127
- * @param \BotMan\BotMan\Messages\Incoming\IncomingMessage $matchingMessage
128
- * @param array $additionalParameters
131
+ * @param \BotMan\BotMan\Messages\Incoming\IncomingMessage $matchingMessage
132
+ * @param array $additionalParameters
133
+ *
129
134
* @return array
130
135
*/
131
136
public function buildServicePayload ($ message , $ matchingMessage , $ additionalParameters = [])
132
137
{
133
138
$ payload = [
134
- 'text ' => '' ,
139
+ 'text ' => '' ,
135
140
'cards ' => [
136
141
[
137
142
'sections ' => [
138
143
[
139
- 'widgets ' => []
140
- ]
141
- ]
142
- ]
143
- ]
144
+ 'widgets ' => [],
145
+ ],
146
+ ],
147
+ ],
148
+ ],
144
149
];
145
150
if ($ message instanceof OutgoingMessage) {
146
151
$ text = $ message ->getText ();
147
152
148
153
$ payload ['text ' ] = $ text ;
149
154
150
155
$ attachment = $ message ->getAttachment ();
151
- if (! is_null ($ attachment ) && $ attachment instanceof Image) {
156
+ if (!is_null ($ attachment ) && $ attachment instanceof Image) {
152
157
$ payload ['cards ' ][0 ]['sections ' ][0 ]['widgets ' ][] = [
153
158
'image ' => [
154
- 'imageUrl ' => $ attachment ->getUrl ()
155
- ]
159
+ 'imageUrl ' => $ attachment ->getUrl (),
160
+ ],
156
161
];
157
162
}
158
163
} elseif ($ message instanceof Question) {
@@ -164,6 +169,7 @@ public function buildServicePayload($message, $matchingMessage, $additionalParam
164
169
165
170
/**
166
171
* @param mixed $payload
172
+ *
167
173
* @return Response
168
174
*/
169
175
public function sendPayload ($ payload )
@@ -174,9 +180,10 @@ public function sendPayload($payload)
174
180
/**
175
181
* Low-level method to perform driver specific API requests.
176
182
*
177
- * @param string $endpoint
178
- * @param array $parameters
183
+ * @param string $endpoint
184
+ * @param array $parameters
179
185
* @param \BotMan\BotMan\Messages\Incoming\IncomingMessage $matchingMessage
186
+ *
180
187
* @return void
181
188
*/
182
189
public function sendRequest ($ endpoint , array $ parameters , IncomingMessage $ matchingMessage )
0 commit comments