groups_controller.rb 2.2 KB

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