zammad/app/controllers/rss_controller.rb

31 lines
593 B
Ruby
Raw Normal View History

2014-02-03 19:24:49 +00:00
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
2012-04-29 21:28:45 +00:00
class RssController < ApplicationController
before_action :authentication_check
2012-04-29 21:28:45 +00:00
=begin
Resource:
GET /api/v1/rss_fetch
Response:
{
...
}
Test:
curl http://localhost/api/v1/rss_fetch.json -v -u #{login}:#{password} -H "Content-Type: application/json" -X GET
=end
2012-04-29 21:28:45 +00:00
def fetch
2013-08-22 20:21:52 +00:00
items = Rss.fetch(params[:url], params[:limit])
if items.nil?
render json: { message: "failed to fetch #{params[:url]}", status: :unprocessable_entity }
2012-11-26 23:22:52 +00:00
return
2012-04-29 21:28:45 +00:00
end
render json: { items: items }
2012-04-29 21:28:45 +00:00
end
end