From e7cb0127ddb2a03131384b51342be6559fba201c Mon Sep 17 00:00:00 2001 From: tamucola Date: Tue, 22 Nov 2016 00:23:43 +0900 Subject: [PATCH 1/3] Update MessageEvent.php add function getMessageType --- src/LINEBot/Event/MessageEvent.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/LINEBot/Event/MessageEvent.php b/src/LINEBot/Event/MessageEvent.php index 940bbd23..080c9cd6 100644 --- a/src/LINEBot/Event/MessageEvent.php +++ b/src/LINEBot/Event/MessageEvent.php @@ -51,4 +51,15 @@ public function getMessageId() { return $this->message['id']; } + + + /** + * Returns the type of the message. + * + * @return string + */ + public function getMessageType() + { + return $this->message['type']; + } } From 3dfce571d66dc5a40af2a7acbe9dc6bcdb4a02ba Mon Sep 17 00:00:00 2001 From: tamucola Date: Tue, 22 Nov 2016 00:26:43 +0900 Subject: [PATCH 2/3] Update MessageEvent.php --- src/LINEBot/Event/MessageEvent.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/LINEBot/Event/MessageEvent.php b/src/LINEBot/Event/MessageEvent.php index 080c9cd6..e5226a68 100644 --- a/src/LINEBot/Event/MessageEvent.php +++ b/src/LINEBot/Event/MessageEvent.php @@ -52,7 +52,6 @@ public function getMessageId() return $this->message['id']; } - /** * Returns the type of the message. * From 284a6a4fa3007a0bd1f3be579b0632f90be35c83 Mon Sep 17 00:00:00 2001 From: tamucola Date: Tue, 22 Nov 2016 00:47:58 +0900 Subject: [PATCH 3/3] Update EventRequestParserTest.php Add test getMessageType --- tests/LINEBot/EventRequestParserTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/LINEBot/EventRequestParserTest.php b/tests/LINEBot/EventRequestParserTest.php index c14f1282..be81ff55 100644 --- a/tests/LINEBot/EventRequestParserTest.php +++ b/tests/LINEBot/EventRequestParserTest.php @@ -206,6 +206,7 @@ public function testParseEventRequest() /** @var TextMessage $event */ $this->assertEquals('replytoken', $event->getReplyToken()); $this->assertEquals('contentid', $event->getMessageId()); + $this->assertEquals('text', $event->getMessageType()); $this->assertEquals('message', $event->getText()); } @@ -218,6 +219,7 @@ public function testParseEventRequest() $this->assertInstanceOf('LINE\LINEBot\Event\MessageEvent\ImageMessage', $event); /** @var ImageMessage $event */ $this->assertEquals('replytoken', $event->getReplyToken()); + $this->assertEquals('image', $event->getMessageType()); } { @@ -229,6 +231,7 @@ public function testParseEventRequest() $this->assertInstanceOf('LINE\LINEBot\Event\MessageEvent\VideoMessage', $event); /** @var VideoMessage $event */ $this->assertEquals('replytoken', $event->getReplyToken()); + $this->assertEquals('video', $event->getMessageType()); } { @@ -237,6 +240,7 @@ public function testParseEventRequest() $this->assertInstanceOf('LINE\LINEBot\Event\MessageEvent\AudioMessage', $event); /** @var AudioMessage $event */ $this->assertEquals('replytoken', $event->getReplyToken()); + $this->assertEquals('audio', $event->getMessageType()); } { @@ -245,6 +249,7 @@ public function testParseEventRequest() $this->assertInstanceOf('LINE\LINEBot\Event\MessageEvent\LocationMessage', $event); /** @var LocationMessage $event */ $this->assertEquals('replytoken', $event->getReplyToken()); + $this->assertEquals('location', $event->getMessageType()); $this->assertEquals('label', $event->getTitle()); $this->assertEquals('tokyo', $event->getAddress()); $this->assertEquals('-34.12', $event->getLatitude()); @@ -257,6 +262,7 @@ public function testParseEventRequest() $this->assertInstanceOf('LINE\LINEBot\Event\MessageEvent\StickerMessage', $event); /** @var StickerMessage $event */ $this->assertEquals('replytoken', $event->getReplyToken()); + $this->assertEquals('sticker', $event->getMessageType()); $this->assertEquals(1, $event->getPackageId()); $this->assertEquals(2, $event->getStickerId()); }