diff --git a/src/CiscoSparkDriver.php b/src/CiscoSparkDriver.php index fcc70c3..2bdf724 100644 --- a/src/CiscoSparkDriver.php +++ b/src/CiscoSparkDriver.php @@ -2,17 +2,17 @@ namespace BotMan\Drivers\CiscoSpark; +use BotMan\BotMan\Users\User; +use Illuminate\Support\Collection; use BotMan\BotMan\Drivers\HttpDriver; -use BotMan\BotMan\Messages\Attachments\Location; use BotMan\BotMan\Messages\Incoming\Answer; -use BotMan\BotMan\Messages\Incoming\IncomingMessage; -use BotMan\BotMan\Messages\Outgoing\OutgoingMessage; use BotMan\BotMan\Messages\Outgoing\Question; -use BotMan\BotMan\Users\User; -use Illuminate\Support\Collection; -use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use BotMan\BotMan\Messages\Attachments\Location; +use Symfony\Component\HttpFoundation\ParameterBag; +use BotMan\BotMan\Messages\Incoming\IncomingMessage; +use BotMan\BotMan\Messages\Outgoing\OutgoingMessage; class CiscoSparkDriver extends HttpDriver { @@ -41,7 +41,7 @@ protected function getHeaders() return [ 'Accept:application/json', 'Content-Type:application/json', - 'Authorization:Bearer '.$this->config->get('token') + 'Authorization:Bearer '.$this->config->get('token'), ]; } @@ -52,7 +52,7 @@ protected function getHeaders() */ public function matchesRequest() { - return ! is_null($this->payload->get('actorId')) && $this->payload->get('resource') === 'messages' && $this->payload->get('event') === 'created'; + return ! is_null($this->payload->get('actorId')) && $this->payload->get('resource') === 'messages' && $this->payload->get('event') === 'created'; } /** @@ -174,7 +174,7 @@ public function sendRequest($endpoint, array $parameters, IncomingMessage $match } /** - * Returns the chatbot ID + * Returns the chatbot ID. * @return string */ private function getBotId() diff --git a/stubs/cisco-spark.php b/stubs/cisco-spark.php index 450edbf..6bca918 100644 --- a/stubs/cisco-spark.php +++ b/stubs/cisco-spark.php @@ -21,4 +21,4 @@ | */ 'secret' => env('CISCO_SPARK_SECRET'), -]; \ No newline at end of file +]; diff --git a/tests/CiscoSparkDriverTest.php b/tests/CiscoSparkDriverTest.php index 5fad591..0172a96 100644 --- a/tests/CiscoSparkDriverTest.php +++ b/tests/CiscoSparkDriverTest.php @@ -2,12 +2,12 @@ namespace Tests; -use BotMan\BotMan\Http\Curl; -use BotMan\Drivers\CiscoSpark\CiscoSparkDriver; use Mockery as m; +use BotMan\BotMan\Http\Curl; use PHPUnit_Framework_TestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use BotMan\Drivers\CiscoSpark\CiscoSparkDriver; class CiscoSparkDriverTest extends PHPUnit_Framework_TestCase { @@ -20,8 +20,8 @@ private function getDriver($responseData, $htmlInterface = null) return new CiscoSparkDriver($request, [ 'cisco-spark' => [ - 'token' => 'my-token' - ] + 'token' => 'my-token', + ], ], $htmlInterface); } @@ -44,8 +44,8 @@ private function getValidTestData() 'roomId' => 'Y2lzY29zcGFyazovL3VzL1JPT00vY2RlMWRkNDAtMmYwZC0xMWU1LWJhOWMtN2I2NTU2ZDIyMDdi', 'personId' => 'Y2lzY29zcGFyazovL3VzL1BFT1BMRS9lM2EyNjA4OC1hNmRiLTQxZjgtOTliMC1hNTEyMzkyYzAwOTg', 'personEmail' => 'person@example.com', - 'created' => '2015-12-04T17:33:56.767Z' - ] + 'created' => '2015-12-04T17:33:56.767Z', + ], ]; } @@ -77,7 +77,7 @@ public function it_matches_the_request() public function it_returns_the_message_object() { $botResponseData = [ - 'id' => 'bot-id' + 'id' => 'bot-id', ]; $botResponse = new Response(json_encode($botResponseData)); @@ -87,14 +87,14 @@ public function it_returns_the_message_object() ->with('https://api.ciscospark.com/v1/people/me', [], [ 'Accept:application/json', 'Content-Type:application/json', - 'Authorization:Bearer my-token' + 'Authorization:Bearer my-token', ]) ->andReturn($botResponse); $msgResponseData = [ 'text' => 'Hi Julia', 'roomId' => 'room-1234567890', - 'personId' => 'person-0987654321' + 'personId' => 'person-0987654321', ]; $msgResponse = new Response(json_encode($msgResponseData)); @@ -103,7 +103,7 @@ public function it_returns_the_message_object() ->with('https://api.ciscospark.com/v1/messages/Y2lzY29zcGFyazovL3VzL01FU1NBR0UvMzIzZWUyZjAtOWFhZC0xMWU1LTg1YmYtMWRhZjhkNDJlZjlj', [], [ 'Accept:application/json', 'Content-Type:application/json', - 'Authorization:Bearer my-token' + 'Authorization:Bearer my-token', ]) ->andReturn($msgResponse); @@ -115,7 +115,7 @@ public function it_returns_the_message_object() public function it_returns_the_message_text() { $botResponseData = [ - 'id' => 'bot-id' + 'id' => 'bot-id', ]; $botResponse = new Response(json_encode($botResponseData)); @@ -125,14 +125,14 @@ public function it_returns_the_message_text() ->with('https://api.ciscospark.com/v1/people/me', [], [ 'Accept:application/json', 'Content-Type:application/json', - 'Authorization:Bearer my-token' + 'Authorization:Bearer my-token', ]) ->andReturn($botResponse); $msgResponseData = [ 'text' => 'Hi Julia', 'roomId' => 'room-1234567890', - 'personId' => 'person-0987654321' + 'personId' => 'person-0987654321', ]; $msgResponse = new Response(json_encode($msgResponseData)); @@ -141,7 +141,7 @@ public function it_returns_the_message_text() ->with('https://api.ciscospark.com/v1/messages/Y2lzY29zcGFyazovL3VzL01FU1NBR0UvMzIzZWUyZjAtOWFhZC0xMWU1LTg1YmYtMWRhZjhkNDJlZjlj', [], [ 'Accept:application/json', 'Content-Type:application/json', - 'Authorization:Bearer my-token' + 'Authorization:Bearer my-token', ]) ->andReturn($msgResponse); @@ -153,7 +153,7 @@ public function it_returns_the_message_text() public function it_detects_bots() { $botResponseData = [ - 'id' => 'bot-id' + 'id' => 'bot-id', ]; $botResponse = new Response(json_encode($botResponseData)); @@ -163,14 +163,14 @@ public function it_detects_bots() ->with('https://api.ciscospark.com/v1/people/me', [], [ 'Accept:application/json', 'Content-Type:application/json', - 'Authorization:Bearer my-token' + 'Authorization:Bearer my-token', ]) ->andReturn($botResponse); $msgResponseData = [ 'text' => 'Hi Julia', 'roomId' => 'room-1234567890', - 'personId' => 'bot-id' + 'personId' => 'bot-id', ]; $msgResponse = new Response(json_encode($msgResponseData)); @@ -179,7 +179,7 @@ public function it_detects_bots() ->with('https://api.ciscospark.com/v1/messages/Y2lzY29zcGFyazovL3VzL01FU1NBR0UvMzIzZWUyZjAtOWFhZC0xMWU1LTg1YmYtMWRhZjhkNDJlZjlj', [], [ 'Accept:application/json', 'Content-Type:application/json', - 'Authorization:Bearer my-token' + 'Authorization:Bearer my-token', ]) ->andReturn($msgResponse); @@ -191,7 +191,7 @@ public function it_detects_bots() public function it_returns_the_user_id() { $botResponseData = [ - 'id' => 'bot-id' + 'id' => 'bot-id', ]; $botResponse = new Response(json_encode($botResponseData)); @@ -201,14 +201,14 @@ public function it_returns_the_user_id() ->with('https://api.ciscospark.com/v1/people/me', [], [ 'Accept:application/json', 'Content-Type:application/json', - 'Authorization:Bearer my-token' + 'Authorization:Bearer my-token', ]) ->andReturn($botResponse); $msgResponseData = [ 'text' => 'Hi Julia', 'roomId' => 'room-1234567890', - 'personId' => 'person-0987654321' + 'personId' => 'person-0987654321', ]; $msgResponse = new Response(json_encode($msgResponseData)); @@ -217,7 +217,7 @@ public function it_returns_the_user_id() ->with('https://api.ciscospark.com/v1/messages/Y2lzY29zcGFyazovL3VzL01FU1NBR0UvMzIzZWUyZjAtOWFhZC0xMWU1LTg1YmYtMWRhZjhkNDJlZjlj', [], [ 'Accept:application/json', 'Content-Type:application/json', - 'Authorization:Bearer my-token' + 'Authorization:Bearer my-token', ]) ->andReturn($msgResponse); @@ -229,7 +229,7 @@ public function it_returns_the_user_id() public function it_returns_the_channel_id() { $botResponseData = [ - 'id' => 'bot-id' + 'id' => 'bot-id', ]; $botResponse = new Response(json_encode($botResponseData)); @@ -239,14 +239,14 @@ public function it_returns_the_channel_id() ->with('https://api.ciscospark.com/v1/people/me', [], [ 'Accept:application/json', 'Content-Type:application/json', - 'Authorization:Bearer my-token' + 'Authorization:Bearer my-token', ]) ->andReturn($botResponse); $msgResponseData = [ 'text' => 'Hi Julia', 'roomId' => 'room-1234567890', - 'personId' => 'person-0987654321' + 'personId' => 'person-0987654321', ]; $msgResponse = new Response(json_encode($msgResponseData)); @@ -255,7 +255,7 @@ public function it_returns_the_channel_id() ->with('https://api.ciscospark.com/v1/messages/Y2lzY29zcGFyazovL3VzL01FU1NBR0UvMzIzZWUyZjAtOWFhZC0xMWU1LTg1YmYtMWRhZjhkNDJlZjlj', [], [ 'Accept:application/json', 'Content-Type:application/json', - 'Authorization:Bearer my-token' + 'Authorization:Bearer my-token', ]) ->andReturn($msgResponse); @@ -272,16 +272,16 @@ public function it_is_configured() $driver = new CiscoSparkDriver($request, [ 'cisco-spark' => [ - 'token' => 'token' - ] + 'token' => 'token', + ], ], $htmlInterface); $this->assertTrue($driver->isConfigured()); $driver = new CiscoSparkDriver($request, [ 'cisco-spark' => [ - 'token' => null - ] + 'token' => null, + ], ], $htmlInterface); $this->assertFalse($driver->isConfigured());