Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/line/line-bot-sdk-php into …
Browse files Browse the repository at this point in the history
…support-laravel
  • Loading branch information
moririnson committed Nov 6, 2019
2 parents 76044ea + c0d9e32 commit cd30868
Show file tree
Hide file tree
Showing 8 changed files with 214 additions and 48 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ matrix:
- php: 7.0
- php: 7.1
- php: 7.2
- php: 7.3
install:
- composer update
script: make check
Expand Down
2 changes: 1 addition & 1 deletion docs/class-LINE.LINEBot.Constant.Meta.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ <h1>Meta</h1>
<td class="value">
<div>
<a href="#VERSION" class="anchor pull-right">#</a>
<code><span class="php-quote">'3.14.0'</span></code>
<code><span class="php-quote">'3.15.0'</span></code>
</div>
</td>
</tr>
Expand Down
40 changes: 38 additions & 2 deletions docs/class-LINE.LINEBot.html
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,42 @@ <h2>see</h2>



</div>
</div>
</td>
</tr>



<tr id="_getUserInteractionStatistics">

<td class="attributes col-md-1">
<code class="keyword">
public


</code>
</td>

<td class="name">
<div>
<a class="anchor pull-right" href="#_getUserInteractionStatistics">#</a>
<code><a href="source-class-LINE.LINEBot.html#641-645">getUserInteractionStatistics</a>( <span> string <span class="property-name">$requestId</span> </span> )</code>

<div class="description">
Get user interaction statistics

Returns statistics about how users interact with broadcast messages sent from your LINE official account.
Interactions are tracked for only 14 days after a message was sent.
The statistics are no longer updated after 15 days.








</div>
</div>
</td>
Expand All @@ -1416,7 +1452,7 @@ <h2>see</h2>
<td class="name">
<div>
<a class="anchor pull-right" href="#_createChannelAccessToken">#</a>
<code><a href="source-class-LINE.LINEBot.html#642-654">createChannelAccessToken</a>( <span> string <span class="property-name">$channelId</span> </span> )</code>
<code><a href="source-class-LINE.LINEBot.html#658-670">createChannelAccessToken</a>( <span> string <span class="property-name">$channelId</span> </span> )</code>

<div class="description">
Create channel access token
Expand Down Expand Up @@ -1453,7 +1489,7 @@ <h2>see</h2>
<td class="name">
<div>
<a class="anchor pull-right" href="#_revokeChannelAccessToken">#</a>
<code><a href="source-class-LINE.LINEBot.html#664-672">revokeChannelAccessToken</a>( <span> string <span class="property-name">$channelAccessToken</span> </span> )</code>
<code><a href="source-class-LINE.LINEBot.html#680-688">revokeChannelAccessToken</a>( <span> string <span class="property-name">$channelAccessToken</span> </span> )</code>

<div class="description">
Revoke channel access token
Expand Down
2 changes: 1 addition & 1 deletion docs/source-class-LINE.LINEBot.Constant.Meta.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
</span><span class="l" id="line-20">
</span><span class="l" id="line-21"><span class="php-keyword1">class</span> Meta
</span><span class="l" id="line-22">{
</span><span class="l" id="line-23"> <span class="php-keyword1">const</span> VERSION = <span class="php-quote">'3.14.0'</span>;
</span><span class="l" id="line-23"> <span class="php-keyword1">const</span> VERSION = <span class="php-quote">'3.15.0'</span>;
</span><span class="l" id="line-24">}
</span><span class="l" id="line-25"></span><br></code></pre>
</div>
Expand Down
102 changes: 59 additions & 43 deletions docs/source-class-LINE.LINEBot.html

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions src/LINEBot.php
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,22 @@ public function getFriendDemographics()
return $this->httpClient->get($url);
}

/**
* Get user interaction statistics
*
* Returns statistics about how users interact with broadcast messages sent from your LINE official account.
* Interactions are tracked for only 14 days after a message was sent.
* The statistics are no longer updated after 15 days.
*
* @param string $requestId Request ID of broadcast message.
* @return Response
*/
public function getUserInteractionStatistics($requestId)
{
$url = $this->endpointBase . '/v2/bot/insight/message/event';
return $this->httpClient->get($url, ['requestId' => $requestId]);
}

/**
* Create channel access token
*
Expand Down
2 changes: 1 addition & 1 deletion src/LINEBot/Constant/Meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@

class Meta
{
const VERSION = '3.14.0';
const VERSION = '3.15.0';
}
97 changes: 97 additions & 0 deletions tests/LINEBot/InsightTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,4 +316,101 @@ public function testGetFriendDemographics()
$data = $res->getJSONDecodedBody();
$this->assertEquals($responseJson, $data);
}

public function testGetUserInteractionStatistics()
{
$requestId = 'test request id';

// Test: status is ready
$mock = function ($testRunner, $httpMethod, $url, $data) use ($requestId) {
/** @var \PHPUnit\Framework\TestCase $testRunner */
$testRunner->assertEquals('GET', $httpMethod);
$testRunner->assertEquals('https://api.line.me/v2/bot/insight/message/event', $url);
$testRunner->assertEquals([
'requestId' => $requestId
], $data);

return [
'overview' => [
'requestId' => $requestId,
'timestamp' => 1568214000,
'delivered' => 32,
'uniqueImpression' => 4,
'uniqueClick' => null,
'uniqueMediaPlayed' => 2,
'uniqueMediaPlayed100Percent' => -1
],
'messages' => [
[
'seq' => 1,
'impression' => 18,
'mediaPlayed' => 11,
'mediaPlayed25Percent' => -1,
'mediaPlayed50Percent' => -1,
'mediaPlayed75Percent' => -1,
'mediaPlayed100Percent' => -1,
'uniqueMediaPlayed' => 2,
'uniqueMediaPlayed25Percent' => -1,
'uniqueMediaPlayed50Percent' => -1,
'uniqueMediaPlayed75Percent' => -1,
'uniqueMediaPlayed100Percent' => -1
],
],
'clicks' => [
[
'seq' => 1,
'url' => 'https://www.yahoo.co.jp/',
'click' => -1,
'uniqueClick' => -1,
'uniqueClickOfRequest' => -1
],
[
'seq' => 1,
'url' => 'https://www.google.com/?hl=ja',
'click' => -1,
'uniqueClick' => -1,
'uniqueClickOfRequest' => -1
],
]
];
};
$bot = new LINEBot(new DummyHttpClient($this, $mock), ['channelSecret' => 'CHANNEL-SECRET']);
$res = $bot->getUserInteractionStatistics($requestId);

$this->assertEquals(200, $res->getHTTPStatus());
$this->assertTrue($res->isSucceeded());

$data = $res->getJSONDecodedBody();
$this->assertEquals($requestId, $data['overview']['requestId']);
$this->assertEquals(1568214000, $data['overview']['timestamp']);
$this->assertEquals(32, $data['overview']['delivered']);
$this->assertEquals(4, $data['overview']['uniqueImpression']);
$this->assertEquals(null, $data['overview']['uniqueClick']);
$this->assertEquals(2, $data['overview']['uniqueMediaPlayed']);
$this->assertEquals(-1, $data['overview']['uniqueMediaPlayed100Percent']);
$this->assertEquals(1, count($data['messages']));
$this->assertEquals(1, $data['messages'][0]['seq']);
$this->assertEquals(18, $data['messages'][0]['impression']);
$this->assertEquals(11, $data['messages'][0]['mediaPlayed']);
$this->assertEquals(-1, $data['messages'][0]['mediaPlayed25Percent']);
$this->assertEquals(-1, $data['messages'][0]['mediaPlayed50Percent']);
$this->assertEquals(-1, $data['messages'][0]['mediaPlayed75Percent']);
$this->assertEquals(-1, $data['messages'][0]['mediaPlayed100Percent']);
$this->assertEquals(2, $data['messages'][0]['uniqueMediaPlayed']);
$this->assertEquals(-1, $data['messages'][0]['uniqueMediaPlayed25Percent']);
$this->assertEquals(-1, $data['messages'][0]['uniqueMediaPlayed50Percent']);
$this->assertEquals(-1, $data['messages'][0]['uniqueMediaPlayed75Percent']);
$this->assertEquals(-1, $data['messages'][0]['uniqueMediaPlayed100Percent']);
$this->assertEquals(2, count($data['clicks']));
$this->assertEquals(1, $data['clicks'][0]['seq']);
$this->assertEquals('https://www.yahoo.co.jp/', $data['clicks'][0]['url']);
$this->assertEquals(-1, $data['clicks'][0]['click']);
$this->assertEquals(-1, $data['clicks'][0]['uniqueClick']);
$this->assertEquals(-1, $data['clicks'][0]['uniqueClickOfRequest']);
$this->assertEquals(1, $data['clicks'][1]['seq']);
$this->assertEquals('https://www.google.com/?hl=ja', $data['clicks'][1]['url']);
$this->assertEquals(-1, $data['clicks'][1]['click']);
$this->assertEquals(-1, $data['clicks'][1]['uniqueClick']);
$this->assertEquals(-1, $data['clicks'][1]['uniqueClickOfRequest']);
}
}

0 comments on commit cd30868

Please sign in to comment.