From 6ee87aea89ef78e2e98df0e61225950446a822aa Mon Sep 17 00:00:00 2001 From: James Lopez Date: Wed, 5 Jul 2017 16:27:32 +0200 Subject: add user agent details API endpoints to issues and snippets --- lib/api/snippets.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lib/api/snippets.rb') diff --git a/lib/api/snippets.rb b/lib/api/snippets.rb index c630c24c339..db4e0b0b013 100644 --- a/lib/api/snippets.rb +++ b/lib/api/snippets.rb @@ -140,6 +140,23 @@ module API content_type 'text/plain' present snippet.content end + + desc 'Get the user agent details for a snippet' do + success Entities::UserAgentDetail + end + params do + requires :id, type: Integer, desc: 'The ID of a snippet' + end + get ":id/user_agent_detail" do + authenticated_as_admin! + + snippet = Snippet.find_by(id: params[:id]) + + return not_found!('Snippet') unless snippet + return not_found!('UserAgentDetail') unless snippet.user_agent_detail + + present snippet.user_agent_detail, with: Entities::UserAgentDetail + end end end end -- cgit v1.2.1