2014-02-03 19:24:49 +00:00
|
|
|
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
2013-06-12 15:59:58 +00:00
|
|
|
|
2012-04-29 21:28:45 +00:00
|
|
|
class RssController < ApplicationController
|
2015-05-07 11:23:55 +00:00
|
|
|
before_action :authentication_check
|
2012-04-29 21:28:45 +00:00
|
|
|
|
2012-09-20 12:08:02 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
|
|
Resource:
|
2013-08-06 22:10:28 +00:00
|
|
|
GET /api/v1/rss_fetch
|
2012-09-20 12:08:02 +00:00
|
|
|
|
|
|
|
|
Response:
|
|
|
|
|
{
|
|
|
|
|
...
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Test:
|
2013-08-06 22:10:28 +00:00
|
|
|
curl http://localhost/api/v1/rss_fetch.json -v -u #{login}:#{password} -H "Content-Type: application/json" -X GET
|
2012-09-20 12:08:02 +00:00
|
|
|
|
|
|
|
|
=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])
|
2015-05-07 10:11:45 +00:00
|
|
|
if items.nil?
|
2015-07-03 15:18:01 +00:00
|
|
|
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
|
2015-04-27 13:42:53 +00:00
|
|
|
render json: { items: items }
|
2012-04-29 21:28:45 +00:00
|
|
|
end
|
|
|
|
|
|
2013-06-12 15:59:58 +00:00
|
|
|
end
|