Skip to content

Commit 47e0eca

Browse files
authored
Merge pull request #196 from line/feature/video_viewing_complete_event
Add videoPlayComplete event and spec
2 parents a8fbf6a + 053a0da commit 47e0eca

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed

examples/kitchensink/app.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ def reply_content(event, messages)
7777
when Line::Bot::Event::Things
7878
reply_text(event, "[THINGS]\n#{JSON.generate(event['things'])}")
7979

80+
when Line::Bot::Event::VideoPlayComplete
81+
reply_text(event, "[VIDEOPLAYCOMPLETE]\n#{JSON.generate(event['videoPlayComplete'])}")
82+
8083
else
8184
reply_text(event, "Unknown event type: #{event}")
8285
end

lib/line/bot/event.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@
2525
require 'line/bot/event/member_joined'
2626
require 'line/bot/event/member_left'
2727
require 'line/bot/event/things'
28+
require 'line/bot/event/video_play_complete'
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2016 LINE
2+
#
3+
# LINE Corporation licenses this file to you under the Apache License,
4+
# version 2.0 (the "License"); you may not use this file except in compliance
5+
# with the License. You may obtain a copy of the License at:
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
# License for the specific language governing permissions and limitations
13+
# under the License.
14+
15+
module Line
16+
module Bot
17+
module Event
18+
# Event for when a user finishes viewing a video at least once with the specified trackingId sent by the LINE Official Account.
19+
#
20+
# https://developers.line.biz/en/reference/messaging-api/#video-viewing-complete
21+
class VideoPlayComplete < Base
22+
end
23+
end
24+
end
25+
end

spec/line/bot/client_parse_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,18 @@
285285
"unsend": {
286286
"messageId": "325708"
287287
}
288+
},
289+
{
290+
"type": "videoPlayComplete",
291+
"replyToken": "nHuyWi...",
292+
"source": {
293+
"type": "user",
294+
"userId": "U4af4980629..."
295+
},
296+
"timestamp": 12345678901234,
297+
"videoPlayComplete": {
298+
"trackingId": "track_id"
299+
}
288300
}
289301
]
290302
}
@@ -417,6 +429,7 @@ def generate_client
417429
expect(events[18].device_id).to eq('deviceid4')
418430

419431
expect(events[19]).to be_a(Line::Bot::Event::Unsend)
432+
expect(events[20]).to be_a(Line::Bot::Event::VideoPlayComplete)
420433
end
421434

422435
it 'parses unknown event' do

0 commit comments

Comments
 (0)