Skip to content

Commit bd5c355

Browse files
authored
Use yard to generate documentation (#153)
* Use yard to generate documentation * Fix typo * Update README.md * Fix comments
1 parent cd8f4ea commit bd5c355

File tree

15 files changed

+97
-25
lines changed

15 files changed

+97
-25
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ gemspec
55
group :development, :test do
66
# ref: http://docs.rubocop.org/en/latest/installation/
77
gem 'rubocop', '~> 0.56.0', require: false
8+
gem 'yard', '~> 0.9.20'
89
end

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ See the official API documentation for more information
1313
- English: https://developers.line.biz/en/docs/messaging-api/overview/
1414
- Japanese: https://developers.line.biz/ja/docs/messaging-api/overview/
1515

16+
Also, generated documentation by YARD is available.
17+
18+
- https://rubydoc.info/gems/line-bot-api
19+
1620
## Installation
1721

1822
Add this line to your application's Gemfile:

lib/line/bot/client.rb

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919

2020
module Line
2121
module Bot
22+
# API Client of LINE Bot SDK Ruby
23+
#
24+
# @client ||= Line::Bot::Client.new do |config|
25+
# config.channel_id = ENV["LINE_CHANNEL_ID"]
26+
# config.channel_secret = ENV["LINE_CHANNEL_SECRET"]
27+
# config.channel_token = ENV["LINE_CHANNEL_TOKEN"]
28+
# end
2229
class Client
2330
# @return [String]
2431
attr_accessor :channel_token, :channel_id, :channel_secret, :endpoint, :blob_endpoint
@@ -29,10 +36,9 @@ class Client
2936
# @return [Hash]
3037
attr_accessor :http_options
3138

32-
# Initialize a new Bot Client.
39+
# Initialize a new client.
3340
#
3441
# @param options [Hash]
35-
#
3642
# @return [Line::Bot::Client]
3743
def initialize(options = {})
3844
options.each do |key, value|
@@ -96,11 +102,10 @@ def revoke_channel_token(access_token)
96102
post(endpoint, endpoint_path, payload, headers)
97103
end
98104

99-
# Push messages to line server and to user.
100-
#
101-
# @param user_id [String] User's identifiers
102-
# @param messages [Hash or Array]
105+
# Push messages to a user using user_id.
103106
#
107+
# @param user_id [String] User Id
108+
# @param messages [Hash or Array] Message Objects
104109
# @return [Net::HTTPResponse]
105110
def push_message(user_id, messages)
106111
channel_token_required
@@ -112,11 +117,25 @@ def push_message(user_id, messages)
112117
post(endpoint, endpoint_path, payload, credentials)
113118
end
114119

115-
# Reply messages to line server and to users.
120+
# Reply messages to a user using replyToken.
121+
#
122+
# @example Send a balloon to a user.
123+
# message = {
124+
# type: 'text',
125+
# text: 'Hello, World!'
126+
# }
127+
# client.reply_message(event['replyToken'], message)
116128
#
117-
# @param token [String]
118-
# @param messages [Hash or Array]
129+
# @example Send multiple balloons to a user.
119130
#
131+
# messages = [
132+
# {type: 'text', text: 'Message1'},
133+
# {type: 'text', text: 'Message2'}
134+
# ]
135+
# client.reply_message(event['replyToken'], messages)
136+
#
137+
# @param token [String] Reply Token
138+
# @param messages [Hash or Array] Message Objects
120139
# @return [Net::HTTPResponse]
121140
def reply_message(token, messages)
122141
channel_token_required
@@ -128,11 +147,10 @@ def reply_message(token, messages)
128147
post(endpoint, endpoint_path, payload, credentials)
129148
end
130149

131-
# Multicast messages to line server and to users.
132-
#
133-
# @param to [Array or String]
134-
# @param messages [Hash or Array]
150+
# Send messages to multiple users using userIds.
135151
#
152+
# @param to [Array or String] Array of userIds
153+
# @param messages [Hash or Array] Message Objects
136154
# @return [Net::HTTPResponse]
137155
def multicast(to, messages)
138156
channel_token_required
@@ -145,10 +163,9 @@ def multicast(to, messages)
145163
post(endpoint, endpoint_path, payload, credentials)
146164
end
147165

148-
# Broadcast messages to users
149-
#
150-
# @param messages [Hash or Array]
166+
# Send messages to all friends.
151167
#
168+
# @param messages [Hash or Array] Message Objects
152169
# @return [Net::HTTPResponse]
153170
def broadcast(messages)
154171
channel_token_required
@@ -177,7 +194,6 @@ def leave_room(room_id)
177194
# Get message content.
178195
#
179196
# @param identifier [String] Message's identifier
180-
#
181197
# @return [Net::HTTPResponse]
182198
def get_message_content(identifier)
183199
channel_token_required
@@ -188,8 +204,7 @@ def get_message_content(identifier)
188204

189205
# Get an user's profile.
190206
#
191-
# @param user_id [String] User's identifier
192-
#
207+
# @param user_id [String] User Id user_id
193208
# @return [Net::HTTPResponse]
194209
def get_profile(user_id)
195210
channel_token_required
@@ -201,7 +216,7 @@ def get_profile(user_id)
201216
# Get an user's profile of a group.
202217
#
203218
# @param group_id [String] Group's identifier
204-
# @param user_id [String] User's identifier
219+
# @param user_id [String] User Id user_id
205220
#
206221
# @return [Net::HTTPResponse]
207222
def get_group_member_profile(group_id, user_id)
@@ -214,7 +229,7 @@ def get_group_member_profile(group_id, user_id)
214229
# Get an user's profile of a room.
215230
#
216231
# @param room_id [String] Room's identifier
217-
# @param user_id [String] User's identifier
232+
# @param user_id [String] User Id user_id
218233
#
219234
# @return [Net::HTTPResponse]
220235
def get_room_member_profile(room_id, user_id)
@@ -241,7 +256,7 @@ def get_group_member_ids(group_id, continuation_token = nil)
241256

242257
# Get user IDs of a room
243258
#
244-
# @param group_id [String] Room's identifier
259+
# @param room_id [String] Room's identifier
245260
# @param continuation_token [String] Identifier to return next page
246261
# (next property to be included in the response)
247262
#
@@ -394,6 +409,9 @@ def unset_default_rich_menu
394409

395410
# Link a rich menu to a user
396411
#
412+
# If you want to link a rich menu to multiple users,
413+
# please consider to use bulk_link_rich_menus.
414+
#
397415
# @param user_id [String] ID of the user
398416
# @param rich_menu_id [String] ID of an uploaded rich menu
399417
#
@@ -531,7 +549,7 @@ def get_number_of_followers(date)
531549
get(endpoint, endpoint_path, credentials)
532550
end
533551

534-
# Retrieves the demographic attributes for a bot's friends.
552+
# Get the demographic attributes for a bot's friends.
535553
#
536554
# @return [Net::HTTPResponse]
537555
def get_friend_demographics
@@ -596,7 +614,9 @@ def parse_events_from(request_body)
596614
end
597615
end
598616

599-
# Validate signature
617+
# Validate signature of a webhook event.
618+
#
619+
# https://developers.line.biz/en/reference/messaging-api/#signature-validation
600620
#
601621
# @param content [String] Request's body
602622
# @param channel_signature [String] Request'header 'X-LINE-Signature' # HTTP_X_LINE_SIGNATURE

lib/line/bot/event/account_link.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,16 @@
1515
module Line
1616
module Bot
1717
module Event
18+
# Event object for when a user has linked his/her LINE account with a provider's service account.
19+
#
20+
# https://developers.line.biz/en/reference/messaging-api/#account-link-event
1821
class AccountLink < Base
22+
# @return [String]
1923
def result
2024
@src['link']['result']
2125
end
2226

27+
# @return [String]
2328
def nonce
2429
@src['link']['nonce']
2530
end

lib/line/bot/event/beacon.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,21 @@
1515
module Line
1616
module Bot
1717
module Event
18+
# Event object for when a user enters the range of a LINE Beacon.
19+
#
20+
# https://developers.line.biz/en/reference/messaging-api/#beacon-event
1821
class Beacon < Base
22+
# @return [String]
1923
def type
2024
@src['beacon']['type']
2125
end
2226

27+
# @return [String]
2328
def hwid
2429
@src['beacon']['hwid']
2530
end
2631

32+
# @return [String]
2733
def deviceMessage
2834
[@src['beacon']['dm']].pack('H*')
2935
end

lib/line/bot/event/follow.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
module Line
1616
module Bot
1717
module Event
18+
# Event object for when your LINE official account is added as a friend (or unblocked).
19+
# You can reply to follow events.
20+
#
21+
# https://developers.line.biz/en/reference/messaging-api/#follow-event
1822
class Follow < Base
1923
end
2024
end

lib/line/bot/event/join.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
module Line
1616
module Bot
1717
module Event
18+
# Event object for when your LINE official account joins a group or room.
19+
#
20+
# https://developers.line.biz/en/reference/messaging-api/#join-event
1821
class Join < Base
1922
end
2023
end

lib/line/bot/event/leave.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
module Line
1616
module Bot
1717
module Event
18+
# Event object for when a user removes your LINE official account from a group or when your LINE official account leaves a group or room.
19+
#
20+
# No replyToken is generated for this event.
21+
#
22+
# https://developers.line.biz/en/reference/messaging-api/#leave-event
1823
class Leave < Base
1924
end
2025
end

lib/line/bot/event/member_joined.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
module Line
1616
module Bot
1717
module Event
18+
# Event object for when a user joins a group or room that the LINE official account is in.
19+
#
20+
# https://developers.line.biz/en/reference/messaging-api/#member-joined-event
1821
class MemberJoined < Base
1922
end
2023
end

lib/line/bot/event/member_left.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
module Line
1616
module Bot
1717
module Event
18+
# Event object for when a user leaves a group or room that the LINE official account is in.
19+
#
20+
# No replyToken is generated for this event.
21+
#
22+
# https://developers.line.biz/en/reference/messaging-api/#member-left-event
1823
class MemberLeft < Base
1924
end
2025
end

0 commit comments

Comments
 (0)