organizations_controller.rb 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. class OrganizationsController < ApplicationController
  2. before_filter :authentication_check
  3. =begin
  4. Format:
  5. JSON
  6. Example:
  7. {
  8. "id":1,
  9. "name":"Znuny GmbH",
  10. "note":"",
  11. "active":true,
  12. "shared":true,
  13. "updated_at":"2012-09-14T17:51:53Z",
  14. "created_at":"2012-09-14T17:51:53Z",
  15. "created_by_id":2,
  16. }
  17. =end
  18. =begin
  19. Resource:
  20. GET /api/organizations.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/organizations.json -v -u #{login}:#{password}
  36. =end
  37. def index
  38. model_index_render(Organization, params)
  39. end
  40. =begin
  41. Resource:
  42. GET /api/organizations/#{id}.json
  43. Response:
  44. {
  45. "id": 1,
  46. "name": "name_1",
  47. ...
  48. }
  49. Test:
  50. curl http://localhost/api/organizations/#{id}.json -v -u #{login}:#{password}
  51. =end
  52. def show
  53. model_show_render(Organization, params)
  54. end
  55. =begin
  56. Resource:
  57. POST /api/organizations.json
  58. Payload:
  59. {
  60. "name": "some_name",
  61. "active": true,
  62. "note": "some note",
  63. "shared": true
  64. }
  65. Response:
  66. {
  67. "id": 1,
  68. "name": "some_name",
  69. ...
  70. }
  71. Test:
  72. curl http://localhost/api/organizations.json -v -u #{login}:#{password} -H "Content-Type: application/json" -X POST -d '{"name": "some_name","active": true,"shared": true,"note": "some note"}'
  73. =end
  74. def create
  75. model_create_render(Organization, params)
  76. end
  77. =begin
  78. Resource:
  79. PUT /api/organizations/{id}.json
  80. Payload:
  81. {
  82. "id": 1
  83. "name": "some_name",
  84. "active": true,
  85. "note": "some note",
  86. "shared": true
  87. }
  88. Response:
  89. {
  90. "id": 1,
  91. "name": "some_name",
  92. ...
  93. }
  94. Test:
  95. curl http://localhost/api/organizations.json -v -u #{login}:#{password} -H "Content-Type: application/json" -X PUT -d '{"id": 1,"name": "some_name","active": true,"shared": true,"note": "some note"}'
  96. =end
  97. def update
  98. model_update_render(Organization, params)
  99. end
  100. =begin
  101. Resource:
  102. Response:
  103. Test:
  104. =end
  105. def destroy
  106. model_destory_render(Organization, params)
  107. end
  108. end