Skip to content

Commit eb162f2

Browse files
committed
Support custom headers for X-Line-Retry-Key
1 parent 507470b commit eb162f2

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/line/bot/client.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ def revoke_channel_token(access_token)
107107
# @param user_id [String] User Id
108108
# @param messages [Hash or Array] Message Objects
109109
# @return [Net::HTTPResponse]
110-
def push_message(user_id, messages)
110+
def push_message(user_id, messages, headers={})
111111
channel_token_required
112112

113113
messages = [messages] if messages.is_a?(Hash)
114114

115115
endpoint_path = '/bot/message/push'
116116
payload = { to: user_id, messages: messages }.to_json
117-
post(endpoint, endpoint_path, payload, credentials)
117+
post(endpoint, endpoint_path, payload, headers.merge(credentials))
118118
end
119119

120120
# Reply messages to a user using replyToken.
@@ -152,29 +152,29 @@ def reply_message(token, messages)
152152
# @param to [Array or String] Array of userIds
153153
# @param messages [Hash or Array] Message Objects
154154
# @return [Net::HTTPResponse]
155-
def multicast(to, messages)
155+
def multicast(to, messages, headers={})
156156
channel_token_required
157157

158158
to = [to] if to.is_a?(String)
159159
messages = [messages] if messages.is_a?(Hash)
160160

161161
endpoint_path = '/bot/message/multicast'
162162
payload = { to: to, messages: messages }.to_json
163-
post(endpoint, endpoint_path, payload, credentials)
163+
post(endpoint, endpoint_path, payload, headers.merge(credentials))
164164
end
165165

166166
# Send messages to all friends.
167167
#
168168
# @param messages [Hash or Array] Message Objects
169169
# @return [Net::HTTPResponse]
170-
def broadcast(messages)
170+
def broadcast(messages, headers={})
171171
channel_token_required
172172

173173
messages = [messages] if messages.is_a?(Hash)
174174

175175
endpoint_path = '/bot/message/broadcast'
176176
payload = { messages: messages }.to_json
177-
post(endpoint, endpoint_path, payload, credentials)
177+
post(endpoint, endpoint_path, payload, headers.merge(credentials))
178178
end
179179

180180
# Narrowcast messages to users
@@ -188,7 +188,7 @@ def broadcast(messages)
188188
# @param limit [Hash]
189189
#
190190
# @return [Net::HTTPResponse]
191-
def narrowcast(messages, recipient: nil, filter: nil, limit: nil)
191+
def narrowcast(messages, recipient: nil, filter: nil, limit: nil, headers: {})
192192
channel_token_required
193193

194194
messages = [messages] if messages.is_a?(Hash)
@@ -200,7 +200,7 @@ def narrowcast(messages, recipient: nil, filter: nil, limit: nil)
200200
filter: filter,
201201
limit: limit
202202
}.to_json
203-
post(endpoint, endpoint_path, payload, credentials)
203+
post(endpoint, endpoint_path, payload, headers.merge(credentials))
204204
end
205205

206206
def leave_group(group_id)

0 commit comments

Comments
 (0)