Skip to content

Commit a731a26

Browse files
authored
Merge pull request #259 from kenta-takeuchi/validate_rich_menu
create validate_rich_menu method
2 parents 8d3586e + b8697b8 commit a731a26

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Diff for: lib/line/bot/client.rb

+12
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,18 @@ def create_rich_menu(rich_menu)
547547
post(endpoint, endpoint_path, rich_menu.to_json, credentials)
548548
end
549549

550+
# Validate a rich menu object
551+
#
552+
# @param rich_menu [Hash] The rich menu represented as a rich menu object
553+
#
554+
# @return [Net::HTTPResponse]
555+
def validate_rich_menu_object(rich_menu)
556+
channel_token_required
557+
558+
endpoint_path = '/bot/richmenu/validate'
559+
post(endpoint, endpoint_path, rich_menu.to_json, credentials)
560+
end
561+
550562
# Delete a rich menu
551563
#
552564
# @param rich_menu_id [String] ID of an uploaded rich menu

Diff for: spec/line/bot/rich_menu_spec.rb

+8
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@
9595
.with(body: JSON.parse(RICH_MENU_CONTENT).to_json)
9696
end
9797

98+
it 'validates a rich menu object' do
99+
uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + '/bot/richmenu/validate'
100+
stub_request(:post, uri_template).to_return(body: '{}', status: 200)
101+
102+
client.validate_rich_menu_object(JSON.parse(RICH_MENU_CONTENT))
103+
expect(WebMock).to have_requested(:post, Line::Bot::API::DEFAULT_ENDPOINT + '/bot/richmenu/validate')
104+
end
105+
98106
it 'deletes a rich menu' do
99107
uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + '/bot/richmenu/1234567'
100108
stub_request(:delete, uri_template).to_return(body: '{}', status: 200)

0 commit comments

Comments
 (0)