Skip to content

Commit 68ea96e

Browse files
authored
Merge pull request #105 from line/feature/get_default_rich_menu
Implement get_default_rich_menu
2 parents 9690846 + 881c565 commit 68ea96e

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/line/bot/client.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,14 @@ def get_user_rich_menu(user_id)
310310
get(endpoint_path)
311311
end
312312

313+
# Get default rich menu
314+
#
315+
# @return [Net::HTTPResponse]
316+
def get_default_rich_menu
317+
endpoint_path = '/bot/user/all/richmenu'
318+
get(endpoint_path)
319+
end
320+
313321
# Set default rich menu (Link a rich menu to all user)
314322
#
315323
# @param rich_menu_id [String] ID of an uploaded rich menu

spec/line/bot/rich_menu_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@
103103
expect(WebMock).to have_requested(:post, Line::Bot::API::DEFAULT_ENDPOINT + '/bot/user/all/richmenu/7654321')
104104
end
105105

106+
it 'get the default rich menu' do
107+
uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + '/bot/user/all/richmenu'
108+
stub_request(:get, uri_template).to_return(body: '{"richMenuId":"76543210"}', status: 200)
109+
110+
response = client.get_default_rich_menu
111+
expect(WebMock).to have_requested(:get, Line::Bot::API::DEFAULT_ENDPOINT + '/bot/user/all/richmenu')
112+
expect(response.body).to eq '{"richMenuId":"76543210"}'
113+
end
114+
106115
it 'unset a default rich menu' do
107116
uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + '/bot/user/all/richmenu'
108117
stub_request(:delete, uri_template).to_return(body: '{}', status: 200)

0 commit comments

Comments
 (0)