text_modules_controller.rb 2.1 KB

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