Skip to content

Commit ab200f8

Browse files
authored
create set_rich_menu_alias and unset_rich_menu_alias method (#233)
1 parent 92a6221 commit ab200f8

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

lib/line/bot/client.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,31 @@ def unset_default_rich_menu
492492
delete(endpoint, endpoint_path, credentials)
493493
end
494494

495+
# Set rich menu alias
496+
#
497+
# @param rich_menu_id [String] ID of an uploaded rich menu
498+
# @param rich_menu_alias_id [String] string of alias words rich menu
499+
#
500+
# @return [Net::HTTPResponse]
501+
def set_rich_menus_alias(rich_menu_id, rich_menu_alias_id)
502+
channel_token_required
503+
504+
endpoint_path = '/bot/richmenu/alias'
505+
post(endpoint, endpoint_path, { richMenuId: rich_menu_id, richMenuAliasId: rich_menu_alias_id }.to_json, credentials)
506+
end
507+
508+
# Unset rich menu alias
509+
#
510+
# @param rich_menu_alias_id [String] string of alias words rich menu
511+
#
512+
# @return [Net::HTTPResponse]
513+
def unset_rich_menus_alias(rich_menu_alias_id)
514+
channel_token_required
515+
516+
endpoint_path = "/bot/richmenu/alias/#{rich_menu_alias_id}"
517+
delete(endpoint, endpoint_path, credentials)
518+
end
519+
495520
# Link a rich menu to a user
496521
#
497522
# If you want to link a rich menu to multiple users,

spec/line/bot/rich_menu_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,22 @@
120120
expect(WebMock).to have_requested(:delete, Line::Bot::API::DEFAULT_ENDPOINT + '/bot/user/all/richmenu')
121121
end
122122

123+
it 'creates a rich menu alias' do
124+
uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + '/bot/richmenu/alias'
125+
stub_request(:post, uri_template).to_return(body: '{}', status: 200)
126+
127+
client.set_rich_menus_alias('1234567', 'alias-1234567')
128+
expect(WebMock).to have_requested(:post, Line::Bot::API::DEFAULT_ENDPOINT + '/bot/richmenu/alias')
129+
end
130+
131+
fit 'deletes a rich menu alias' do
132+
uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + '/bot/richmenu/alias/alias-1234567'
133+
stub_request(:delete, uri_template).to_return(body: '{}', status: 200)
134+
135+
client.unset_rich_menus_alias('alias-1234567')
136+
expect(WebMock).to have_requested(:delete, Line::Bot::API::DEFAULT_ENDPOINT + '/bot/richmenu/alias/alias-1234567')
137+
end
138+
123139
it 'links a rich menu to a user' do
124140
uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + '/bot/user/1234567/richmenu/7654321'
125141
stub_request(:post, uri_template).to_return(body: '{}', status: 200)

0 commit comments

Comments
 (0)