signatures_controller.rb 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class SignaturesController < ApplicationController
  3. prepend_before_action :authenticate_and_authorize!
  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. model_create_render(Signature, params)
  76. end
  77. =begin
  78. Resource:
  79. PUT /api/v1/signatures/{id}.json
  80. Payload:
  81. {
  82. "name": "some name",
  83. "note": "",
  84. "active":true,
  85. }
  86. Response:
  87. {
  88. "id": 1,
  89. "name": "some_name",
  90. ...
  91. }
  92. Test:
  93. 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"}'
  94. =end
  95. def update
  96. model_update_render(Signature, params)
  97. end
  98. =begin
  99. Resource:
  100. Response:
  101. Test:
  102. =end
  103. def destroy
  104. model_destroy_render(Signature, params)
  105. end
  106. end