report_profiles_controller.rb 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class ReportProfilesController < ApplicationController
  3. prepend_before_action :authenticate_and_authorize!
  4. =begin
  5. Format:
  6. JSON
  7. Example:
  8. {
  9. "id":1,
  10. "name":"some report_profile",
  11. "condition":{"c_a":1,"c_b":2},
  12. "updated_at":"2012-09-14T17:51:53Z",
  13. "created_at":"2012-09-14T17:51:53Z",
  14. "updated_by_id":2.
  15. "created_by_id":2,
  16. }
  17. =end
  18. =begin
  19. Resource:
  20. GET /api/report_profiles.json
  21. Response:
  22. [
  23. {
  24. "id": 1,
  25. "name": "some_name1",
  26. ...
  27. },
  28. {
  29. "id": 2,
  30. "name": "some_name2",
  31. ...
  32. }
  33. ]
  34. Test:
  35. curl http://localhost/api/report_profiles.json -v -u #{login}:#{password}
  36. =end
  37. def index
  38. model_index_render(Report::Profile, params)
  39. end
  40. =begin
  41. Resource:
  42. GET /api/report_profiles/#{id}.json
  43. Response:
  44. {
  45. "id": 1,
  46. "name": "name_1",
  47. ...
  48. }
  49. Test:
  50. curl http://localhost/api/report_profiles/#{id}.json -v -u #{login}:#{password}
  51. =end
  52. def show
  53. model_show_render(Report::Profile, params)
  54. end
  55. =begin
  56. Resource:
  57. POST /api/report_profiles.json
  58. Payload:
  59. {
  60. "name":"some report_profile",
  61. "condition":{"c_a":1,"c_b":2},
  62. }
  63. Response:
  64. {
  65. "id": 1,
  66. "name": "some_name",
  67. ...
  68. }
  69. Test:
  70. curl http://localhost/api/report_profiles.json -v -u #{login}:#{password} -H "Content-Type: application/json" -X POST -d '{"name": "some_name","active": true, "note": "some note"}'
  71. =end
  72. def create
  73. model_create_render(Report::Profile, params)
  74. end
  75. =begin
  76. Resource:
  77. PUT /api/report_profiles/{id}.json
  78. Payload:
  79. {
  80. "name":"some report_profile",
  81. "condition":{"c_a":1,"c_b":2},
  82. }
  83. Response:
  84. {
  85. "id": 1,
  86. "name": "some_name",
  87. ...
  88. }
  89. Test:
  90. curl http://localhost/api/report_profiles.json -v -u #{login}:#{password} -H "Content-Type: application/json" -X PUT -d '{"name": "some_name","active": true, "note": "some note"}'
  91. =end
  92. def update
  93. model_update_render(Report::Profile, params)
  94. end
  95. def search
  96. model_search_render(Report::Profile, params)
  97. end
  98. =begin
  99. Resource:
  100. DELETE /api/report_profiles/{id}.json
  101. Response:
  102. {}
  103. Test:
  104. curl http://localhost/api/report_profiles.json -v -u #{login}:#{password} -H "Content-Type: application/json" -X DELETE
  105. =end
  106. def destroy
  107. model_destroy_render(Report::Profile, params)
  108. end
  109. end