Skip to content

Commit 48041dd

Browse files
authored
Merge pull request #113 from line/feature/bulk_rich_menu_control
Add bulk link/unlink richmenu api
2 parents 9b8139f + add95f2 commit 48041dd

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

lib/line/bot/client.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,25 @@ def unlink_user_rich_menu(user_id)
363363
delete(endpoint_path)
364364
end
365365

366+
# To link a rich menu to multiple users at a time
367+
#
368+
# @param user_ids [Array] ID of the user
369+
# @param rich_menu_id [String] ID of the uploaded rich menu
370+
#
371+
# @return [Net::HTTPResponse]
372+
def bulk_link_rich_menus(user_ids, rich_menu_id)
373+
post("/bot/richmenu/bulk/link", {richMenuId: rich_menu_id, userIds: user_ids}.to_json)
374+
end
375+
376+
# To unlink a rich menu from multiple users at a time
377+
#
378+
# @param user_ids [Array] ID of the user
379+
#
380+
# @return [Net::HTTPResponse]
381+
def bulk_unlink_rich_menus(user_ids)
382+
post("/bot/richmenu/bulk/unlink", {userIds: user_ids}.to_json)
383+
end
384+
366385
# Download an image associated with a rich menu
367386
#
368387
# @param rich_menu_id [String] ID of an uploaded rich menu

spec/line/bot/rich_menu_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,22 @@
136136
expect(WebMock).to have_requested(:delete, Line::Bot::API::DEFAULT_ENDPOINT + '/bot/user/1234567/richmenu')
137137
end
138138

139+
it 'link a rich menu to multiple users at a atime' do
140+
uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + '/bot/richmenu/bulk/link'
141+
stub_request(:post, uri_template).to_return(body: '{}', status: 200)
142+
143+
client.bulk_link_rich_menus(['1', '2'], '7654321')
144+
expect(WebMock).to have_requested(:post, Line::Bot::API::DEFAULT_ENDPOINT + '/bot/richmenu/bulk/link')
145+
end
146+
147+
it 'unlink a rich menu from multiple users at a time' do
148+
uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + '/bot/richmenu/bulk/unlink'
149+
stub_request(:post, uri_template).to_return(body: '{}', status: 200)
150+
151+
client.bulk_unlink_rich_menus(['1', '2'])
152+
expect(WebMock).to have_requested(:post, Line::Bot::API::DEFAULT_ENDPOINT + '/bot/richmenu/bulk/unlink')
153+
end
154+
139155
it 'gets an image associated with a rich menu' do
140156
uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + '/bot/richmenu/1234567/content'
141157
stub_request(:get, uri_template).to_return(body: File.open(RICH_MENU_IMAGE_FILE_PATH).read, status: 200)

0 commit comments

Comments
 (0)