groups_controller.rb 2.0 KB

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