1919
2020module 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
0 commit comments