2016-10-19 03:11:36 +00:00
|
|
|
# Copyright (C) 2012-2016 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
|
2017-02-15 12:29:25 +00:00
|
|
|
prepend_before_action :authentication_check
|
2012-07-19 21:31:57 +00:00
|
|
|
|
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
|
|
|
|
|
2015-04-27 14:15:29 +00:00
|
|
|
end
|