recent_view_controller.rb 918 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
  2. class RecentViewController < ApplicationController
  3. before_filter :authentication_check
  4. =begin
  5. Resource:
  6. GET /api/v1/recent_viewed
  7. Response:
  8. {
  9. ...
  10. }
  11. Test:
  12. curl http://localhost/api/v1/recent_view -v -u #{login}:#{password} -H "Content-Type: application/json" -X GET
  13. =end
  14. def index
  15. recent_viewed = RecentView.list_full( current_user, 10 )
  16. # return result
  17. render :json => recent_viewed
  18. end
  19. =begin
  20. Resource:
  21. POST /api/v1/recent_viewed
  22. Payload:
  23. {
  24. "object": "Ticket",
  25. "o_id": 123,
  26. }
  27. Response:
  28. {}
  29. Test:
  30. curl http://localhost/api/v1/recent_view -v -u #{login}:#{password} -H "Content-Type: application/json" -X POST -d '{"object": "Ticket","o_id": 123}'
  31. =end
  32. def create
  33. RecentView.log( params[:object], params[:o_id], current_user )
  34. # return result
  35. render :json => { :message => 'ok' }
  36. end
  37. end