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
|
|
|
|
2014-08-27 13:06:09 +00:00
|
|
|
class RecentViewController < ApplicationController
|
2012-07-19 21:31:57 +00:00
|
|
|
before_filter :authentication_check
|
|
|
|
|
2012-09-20 12:08:02 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
Resource:
|
2013-08-06 22:10:28 +00:00
|
|
|
GET /api/v1/recent_viewed
|
2012-09-20 12:08:02 +00:00
|
|
|
|
|
|
|
Response:
|
|
|
|
{
|
|
|
|
...
|
|
|
|
}
|
|
|
|
|
|
|
|
Test:
|
2014-08-27 13:06:09 +00:00
|
|
|
curl http://localhost/api/v1/recent_view -v -u #{login}:#{password} -H "Content-Type: application/json" -X GET
|
2012-09-20 12:08:02 +00:00
|
|
|
|
|
|
|
=end
|
|
|
|
|
2014-08-23 23:56:45 +00:00
|
|
|
def index
|
2014-08-26 14:30:16 +00:00
|
|
|
recent_viewed = RecentView.list_full( current_user, 10 )
|
2012-07-19 21:31:57 +00:00
|
|
|
|
|
|
|
# return result
|
2015-04-27 13:42:53 +00:00
|
|
|
render json: recent_viewed
|
2012-07-19 21:31:57 +00:00
|
|
|
end
|
2012-09-20 12:08:02 +00:00
|
|
|
|
2014-08-23 23:56:45 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
Resource:
|
|
|
|
POST /api/v1/recent_viewed
|
|
|
|
|
|
|
|
Payload:
|
|
|
|
{
|
|
|
|
"object": "Ticket",
|
|
|
|
"o_id": 123,
|
|
|
|
}
|
|
|
|
|
|
|
|
Response:
|
|
|
|
{}
|
|
|
|
|
|
|
|
Test:
|
2014-08-27 13:06:09 +00:00
|
|
|
curl http://localhost/api/v1/recent_view -v -u #{login}:#{password} -H "Content-Type: application/json" -X POST -d '{"object": "Ticket","o_id": 123}'
|
2014-08-23 23:56:45 +00:00
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def create
|
|
|
|
|
|
|
|
RecentView.log( params[:object], params[:o_id], current_user )
|
|
|
|
|
|
|
|
# return result
|
2015-04-27 13:42:53 +00:00
|
|
|
render json: { message: 'ok' }
|
2014-08-23 23:56:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|