Skip to content

Commit 638afcf

Browse files
authored
Merge pull request #74 from line/feature/beacon_dm
Support beacon device message (beacon.dm)
2 parents fbe4818 + 5a247f0 commit 638afcf

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/LINEBot/Event/BeaconDetectionEvent.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,20 @@ public function getHwid()
4848
/**
4949
* Returns type of beacon event.
5050
*
51-
* @return String
51+
* @return string
5252
*/
5353
public function getBeaconEventType()
5454
{
5555
return $this->event['beacon']['type'];
5656
}
57+
58+
/**
59+
* Returns device message of the beacon.
60+
*
61+
* @return string a binary string containing data
62+
*/
63+
public function getDeviceMessage()
64+
{
65+
return pack('H*', $this->event['beacon']['dm']);
66+
}
5767
}

tests/LINEBot/EventRequestParserTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ class EventRequestParserTest extends \PHPUnit_Framework_TestCase
179179
"replyToken":"replytoken",
180180
"beacon":{
181181
"hwid":"bid",
182-
"type":"enter"
182+
"type":"enter",
183+
"dm":"1234567890abcdef"
183184
}
184185
}
185186
]
@@ -190,7 +191,7 @@ public function testParseEventRequest()
190191
{
191192
$bot = new LINEBot(new DummyHttpClient($this, function () {
192193
}), ['channelSecret' => 'testsecret']);
193-
$events = $bot->parseEventRequest($this::$json, 'Nq7AExtg27CQRfM3ngKtQxtVeIM/757ZTyDOrxQtWNg=');
194+
$events = $bot->parseEventRequest($this::$json, '93uPt20VdWTN4NI8JDjrRCvRfY6Mf1/9J4J1yNk11sE=');
194195

195196
$this->assertEquals(count($events), 12);
196197

@@ -316,6 +317,7 @@ public function testParseEventRequest()
316317
$this->assertEquals('replytoken', $event->getReplyToken());
317318
$this->assertEquals('bid', $event->getHwid());
318319
$this->assertEquals('enter', $event->getBeaconEventType());
320+
$this->assertEquals("\x12\x34\x56\x78\x90\xab\xcd\xef", $event->getDeviceMessage());
319321
}
320322
}
321323
}

0 commit comments

Comments
 (0)