overviews_controller.rb 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class OverviewsController < ApplicationController
  3. include CanPrioritize
  4. prepend_before_action { authentication_check && authorize! }
  5. =begin
  6. Format:
  7. JSON
  8. Example:
  9. {
  10. "id":1,
  11. "name":"some overview",
  12. "meta":{"m_a":1,"m_b":2},
  13. "condition":{"c_a":1,"c_b":2},
  14. "order":{"o_a":1,"o_b":2},
  15. "group_by":"group",
  16. "view":{"v_a":1,"v_b":2},
  17. "user_ids": null,
  18. "role_id": null,
  19. "updated_at":"2012-09-14T17:51:53Z",
  20. "created_at":"2012-09-14T17:51:53Z",
  21. "updated_by_id":2.
  22. "created_by_id":2,
  23. }
  24. =end
  25. =begin
  26. Resource:
  27. GET /api/v1/overviews
  28. Response:
  29. [
  30. {
  31. "id": 1,
  32. "name": "some_name1",
  33. ...
  34. },
  35. {
  36. "id": 2,
  37. "name": "some_name2",
  38. ...
  39. }
  40. ]
  41. Test:
  42. curl http://localhost/api/v1/overviews -v -u #{login}:#{password}
  43. =end
  44. def index
  45. model_index_render(Overview, params)
  46. end
  47. =begin
  48. Resource:
  49. GET /api/v1/overviews/#{id}
  50. Response:
  51. {
  52. "id": 1,
  53. "name": "name_1",
  54. ...
  55. }
  56. Test:
  57. curl http://localhost/api/v1/overviews/#{id} -v -u #{login}:#{password}
  58. =end
  59. def show
  60. model_show_render(Overview, params)
  61. end
  62. =begin
  63. Resource:
  64. POST /api/v1/overviews
  65. Payload:
  66. {
  67. "name":"some overview",
  68. "meta":{"m_a":1,"m_b":2},
  69. "condition":{"c_a":1,"c_b":2},
  70. "order":{"o_a":1,"o_b":2},
  71. "group_by":"group",
  72. "view":{"v_a":1,"v_b":2},
  73. "user_ids": null,
  74. "role_id": null,
  75. }
  76. Response:
  77. {
  78. "id": 1,
  79. "name": "some_name",
  80. ...
  81. }
  82. Test:
  83. curl http://localhost/api/v1/overviews -v -u #{login}:#{password} -H "Content-Type: application/json" -X POST -d '{"name": "some_name","active": true, "note": "some note"}'
  84. =end
  85. def create
  86. model_create_render(Overview, params)
  87. end
  88. =begin
  89. Resource:
  90. PUT /api/v1/overviews/{id}
  91. Payload:
  92. {
  93. "name":"some overview",
  94. "meta":{"m_a":1,"m_b":2},
  95. "condition":{"c_a":1,"c_b":2},
  96. "order":{"o_a":1,"o_b":2},
  97. "group_by":"group",
  98. "view":{"v_a":1,"v_b":2},
  99. "user_ids": null,
  100. "role_id": null,
  101. }
  102. Response:
  103. {
  104. "id": 1,
  105. "name": "some_name",
  106. ...
  107. }
  108. Test:
  109. curl http://localhost/api/v1/overviews -v -u #{login}:#{password} -H "Content-Type: application/json" -X PUT -d '{"name": "some_name","active": true, "note": "some note"}'
  110. =end
  111. def update
  112. model_update_render(Overview, params)
  113. end
  114. =begin
  115. Resource:
  116. DELETE /api/v1/overviews/{id}
  117. Response:
  118. {}
  119. Test:
  120. curl http://localhost/api/v1/overviews/#{id} -v -u #{login}:#{password} -H "Content-Type: application/json" -X DELETE
  121. =end
  122. def destroy
  123. model_destroy_render(Overview, params)
  124. end
  125. end