signatures_controller.rb 2.0 KB

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